Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 14584672 | 924 days ago | IN | 0 ETH | 0.15177455 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
DIAMOND
Compiler Version
v0.8.7+commit.e28d00a7
Contract Source Code (Solidity)
/** *Submitted for verification at Etherscan.io on 2022-04-14 */ // Sources flattened with hardhat v2.8.0 https://hardhat.org // File @openzeppelin/contracts-upgradeable/token/ERC20/[email protected] // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `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); } // File @openzeppelin/contracts-upgradeable/token/ERC20/extensions/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File @openzeppelin/contracts-upgradeable/utils/[email protected] // 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); } } } } // File @openzeppelin/contracts-upgradeable/proxy/utils/[email protected] // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // File @openzeppelin/contracts-upgradeable/utils/[email protected] // 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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // File @openzeppelin/contracts-upgradeable/token/ERC20/[email protected] // OpenZeppelin Contracts (last updated v4.5.0) (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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _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 {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[45] private __gap; } // File @openzeppelin/contracts-upgradeable/access/[email protected] // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // File @openzeppelin/contracts-upgradeable/utils/[email protected] // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File @openzeppelin/contracts-upgradeable/utils/introspection/[email protected] // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File @openzeppelin/contracts-upgradeable/utils/introspection/[email protected] // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // File @openzeppelin/contracts-upgradeable/access/[email protected] // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol) pragma solidity ^0.8.0; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // File @openzeppelin/contracts-upgradeable/security/[email protected] // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // File @openzeppelin/contracts-upgradeable/token/ERC20/extensions/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // File @openzeppelin/contracts-upgradeable/utils/cryptography/[email protected] // OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSAUpgradeable { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // File @openzeppelin/contracts-upgradeable/utils/cryptography/[email protected] // OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712Upgradeable is Initializable { /* solhint-disable var-name-mixedcase */ bytes32 private _HASHED_NAME; bytes32 private _HASHED_VERSION; bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /* 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]. */ function __EIP712_init(string memory name, string memory version) internal onlyInitializing { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash()); } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712NameHash() internal virtual view returns (bytes32) { return _HASHED_NAME; } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712VersionHash() internal virtual view returns (bytes32) { return _HASHED_VERSION; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // File @openzeppelin/contracts-upgradeable/utils/[email protected] // 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 CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // File @openzeppelin/contracts-upgradeable/token/ERC20/extensions/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; mapping(address => CountersUpgradeable.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH; /** * @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. */ function __ERC20Permit_init(string memory name) internal onlyInitializing { __EIP712_init_unchained(name, "1"); __ERC20Permit_init_unchained(name); } function __ERC20Permit_init_unchained(string memory) internal onlyInitializing { _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSAUpgradeable.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { CountersUpgradeable.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // File contracts/interfaces/IDIAMOND.sol pragma solidity ^0.8.0; interface IDIAMOND { function mint(address to, uint256 amount) external; function burn(address from, uint256 amount) external; } // File contracts/DIAMOND.sol pragma solidity ^0.8.4; contract DIAMOND is Initializable, ERC20Upgradeable, AccessControlUpgradeable, PausableUpgradeable, ERC20PermitUpgradeable, IDIAMOND { bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); /// @custom:oz-upgrades-unsafe-allow constructor constructor() initializer {} function initialize() initializer public { __ERC20_init("DIAMOND", "DIAMOND"); __AccessControl_init(); __Pausable_init(); __ERC20Permit_init("DIAMOND"); _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(PAUSER_ROLE, msg.sender); _grantRole(MINTER_ROLE, msg.sender); _grantRole(BURNER_ROLE, msg.sender); } function pause() public onlyRole(PAUSER_ROLE) { _pause(); } function unpause() public onlyRole(PAUSER_ROLE) { _unpause(); } function mint(address to, uint256 amount) external override onlyRole(MINTER_ROLE) { _mint(to, amount); } function burn(address to, uint256 amount) external override onlyRole(BURNER_ROLE) { _burn(to, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal whenNotPaused override { super._beforeTokenTransfer(from, to, amount); } } // File @openzeppelin/contracts/utils/cryptography/[email protected] // OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = _efficientHash(computedHash, proofElement); } else { // Hash(current element of the proof + current computed hash) computedHash = _efficientHash(proofElement, computedHash); } } return computedHash; } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } } // File @openzeppelin/contracts-upgradeable/access/[email protected] // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract 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 onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _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); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // File @openzeppelin/contracts-upgradeable/security/[email protected] // 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 ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // File @openzeppelin/contracts-upgradeable/token/ERC721/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File @openzeppelin/contracts-upgradeable/token/ERC721/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File @openzeppelin/contracts-upgradeable/token/ERC721/extensions/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File contracts/interfaces/ERC721AUpgradeable.sol // Creator: Chiru Labs pragma solidity ^0.8.4; error ApprovalCallerNotOwnerNorApproved(); error ApprovalQueryForNonexistentToken(); error ApproveToCaller(); error ApprovalToCurrentOwner(); error BalanceQueryForZeroAddress(); error MintToZeroAddress(); error MintZeroQuantity(); error OwnerQueryForNonexistentToken(); error TransferCallerNotOwnerNorApproved(); error TransferFromIncorrectOwner(); error TransferToNonERC721ReceiverImplementer(); error TransferToZeroAddress(); error URIQueryForNonexistentToken(); /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..). * * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721AUpgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Compiler will pack this into a single 256bit word. struct TokenOwnership { // The address of the owner. address addr; // Keeps track of the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; } // Compiler will pack this into a single 256bit word. struct AddressData { // Realistically, 2**64-1 is more than enough. uint64 balance; // Keeps track of mint count with minimal overhead for tokenomics. uint64 numberMinted; // Keeps track of burn count with minimal overhead for tokenomics. uint64 numberBurned; // For miscellaneous variable(s) pertaining to the address // (e.g. number of whitelist mint slots used). // If there are multiple variables, please pack them into a uint64. uint64 aux; } // The tokenId of the next token to be minted. uint256 internal _currentIndex; // The number of tokens burned. uint256 internal _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; function __ERC721A_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC721A_init_unchained(name_, symbol_); } function __ERC721A_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } /** * To change the starting tokenId, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 1; } /** * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens. */ function totalSupply() public view returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex - _startTokenId() times unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view returns (uint256) { // Counter underflow is impossible as _currentIndex does not decrement, // and it is initialized to _startTokenId() unchecked { return _currentIndex - _startTokenId(); } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return uint256(_addressData[owner].balance); } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return uint256(_addressData[owner].numberMinted); } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return uint256(_addressData[owner].numberBurned); } /** * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return _addressData[owner].aux; } /** * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal { _addressData[owner].aux = aux; } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr && curr < _currentIndex) { TokenOwnership memory ownership = _ownerships[curr]; if (!ownership.burned) { if (ownership.addr != address(0)) { return ownership; } // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. while (true) { curr--; ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } } } revert OwnerQueryForNonexistentToken(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return _ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721AUpgradeable.ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorApproved(); } _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == _msgSender()) revert ApproveToCaller(); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { _transfer(from, to, tokenId); if (to.isContract() && !_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 end = updatedIndex + quantity; if (safe && to.isContract()) { do { emit Transfer(address(0), to, updatedIndex); if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (updatedIndex != end); // Reentrancy protection if (_currentIndex != startTokenId) revert(); } else { do { emit Transfer(address(0), to, updatedIndex++); } while (updatedIndex != end); } _currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Equivalent to _mint(to, quantity, '', false). */ function _mint(address to, uint256 quantity) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 end = updatedIndex + quantity; do { emit Transfer(address(0), to, updatedIndex++); } while (updatedIndex != end); _currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); if (prevOwnership.addr != from) revert TransferFromIncorrectOwner(); bool isApprovedOrOwner = (_msgSender() == from || isApprovedForAll(from, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, from); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; TokenOwnership storage currSlot = _ownerships[tokenId]; currSlot.addr = to; currSlot.startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; TokenOwnership storage nextSlot = _ownerships[nextTokenId]; if (nextSlot.addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev This is equivalent to _burn(tokenId, false) */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); address from = prevOwnership.addr; if (approvalCheck) { bool isApprovedOrOwner = (_msgSender() == from || isApprovedForAll(from, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, from); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { AddressData storage addressData = _addressData[from]; addressData.balance -= 1; addressData.numberBurned += 1; // Keep track of who burned the token, and the timestamp of burning. TokenOwnership storage currSlot = _ownerships[tokenId]; currSlot.addr = from; currSlot.startTimestamp = uint64(block.timestamp); currSlot.burned = true; // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; TokenOwnership storage nextSlot = _ownerships[nextTokenId]; if (nextSlot.addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * And also called before burning one token. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * And also called after one token has been burned. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /// @dev Returns the tokenIds of the address. O(totalSupply) in complexity. function tokensOfOwner(address owner) external view returns (uint256[] memory) { unchecked { uint256[] memory a = new uint256[](balanceOf(owner)); uint256 end = _currentIndex; uint256 tokenIdsIdx; address currOwnershipAddr; for (uint256 i; i < end; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.burned) { continue; } if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { a[tokenIdsIdx++] = i; } } return a; } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[42] private __gap; } // File contracts/interfaces/IDiamondHeist.sol pragma solidity ^0.8.0; interface IDiamondHeist is IERC721Upgradeable, IERC721MetadataUpgradeable { // struct to store each token's traits struct LlamaDog { bool isLlama; uint8 body; uint8 hat; uint8 eye; uint8 mouth; uint8 clothes; uint8 tail; uint8 alphaIndex; } function getPaidTokens() external view returns (uint256); function getTokenTraits(uint256 tokenId) external view returns (LlamaDog memory); function isLlama(uint256 tokenId) external view returns(bool); } // File contracts/interfaces/IStaking.sol pragma solidity ^0.8.0; interface IStaking { function addManyToStaking(address account, uint16[] calldata tokenIds) external; } // File contracts/interfaces/ITraits.sol pragma solidity ^0.8.0; interface ITraits { function tokenURI(uint256 tokenId) external view returns (string memory); } // File contracts/DiamondHeist.sol /** . ' , ' , . ' . _________ _________ _________ _ /_|_____|_\ _ _ /_|_____|_\ _ _ /_|_____|_\ _ '. \ / .' '. \ / .' '. \ / .' '.\ /.' '.\ /.' '.\ /.' '.' '.' '.' ██████╗ ██╗ █████╗ ███╗ ███╗ ██████╗ ███╗ ██╗██████╗ ██╔══██╗██║██╔══██╗████╗ ████║██╔═══██╗████╗ ██║██╔══██╗ ██║ ██║██║███████║██╔████╔██║██║ ██║██╔██╗ ██║██║ ██║ ██║ ██║██║██╔══██║██║╚██╔╝██║██║ ██║██║╚██╗██║██║ ██║ ██████╔╝██║██║ ██║██║ ╚═╝ ██║╚██████╔╝██║ ╚████║██████╔╝ ╚═════╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═════╝ ██╗ ██╗███████╗██╗███████╗████████╗ ██║ ██║██╔════╝██║██╔════╝╚══██╔══╝ <'l __ ███████║█████╗ ██║███████╗ ██║ ll (___()'`; ██╔══██║██╔══╝ ██║╚════██║ ██║ llama~ /, /` ██║ ██║███████╗██║███████║ ██║ || || \\"--\\ ╚═╝ ╚═╝╚══════╝╚═╝╚══════╝ ╚═╝ '' '' */ pragma solidity ^0.8.0; contract DiamondHeist is ERC721AUpgradeable, IDiamondHeist, OwnableUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable { event LlamaMinted(uint256 indexed tokenId); event DogMinted(uint256 indexed tokenId); event LlamaBurned(uint256 indexed tokenId); event DogBurned(uint256 indexed tokenId); // max number of tokens that can be minted - 37,500 in production uint256 public constant MAX_TOKENS = 37500; // number of tokens that can be claimed for a fee - 20% of MAX_TOKENS uint256 public PAID_TOKENS; uint256 public MINT_PRICE; // whitelist, 10 mints, get a discount, 1 free uint16 public constant MAX_COMMUNITY_AMOUNT = 5; uint256 public COMMUNITY_SALE_MINT_PRICE; bytes32 public whitelistMerkleRoot; mapping(address => uint256) public claimed; // mapping from tokenId to a struct containing the token's traits mapping(uint256 => LlamaDog) public tokenTraits; // mapping from hashed(tokenTrait) to the tokenId it's associated with // used to ensure there are no duplicates mapping(uint256 => uint256) public existingCombinations; // list of probabilities for each trait type uint8[][14] public rarities; // list of aliases for Walker's Alias algorithm uint8[][14] public aliases; // reference to the Staking for choosing random Dog thieves IStaking public staking; // reference to $DIAMOND for burning on mint IDIAMOND public diamond; // reference to Traits ITraits public traits; /// @custom:oz-upgrades-unsafe-allow constructor constructor() initializer {} function initialize() initializer public { __ERC721A_init("Diamond Heist", "DIAMONDHEIST"); __Pausable_init(); __Ownable_init(); __ReentrancyGuard_init(); _pause(); PAID_TOKENS = 7500; MINT_PRICE = .06 ether; COMMUNITY_SALE_MINT_PRICE = .04 ether; // Llama/Body rarities[0] = [255, 61, 122, 30, 183, 224, 142, 30, 214, 173, 214, 122]; aliases[0] = [0, 0, 0, 7, 7, 0, 5, 6, 7, 8, 8, 9]; // Llama/Hat rarities[1] = [114, 254, 191, 152, 242, 152, 191, 229, 242, 114, 254, 76, 76, 203, 191]; aliases[1] = [6, 0, 6, 6, 1, 6, 4, 6, 6, 6, 8, 6, 8, 10, 13]; // Llama/Eye rarities[2] = [165, 66, 198, 255, 165, 211, 168, 165, 107, 99, 186, 175, 165]; aliases[2] = [6, 6, 6, 0, 6, 3, 5, 6, 6, 8, 8, 10, 11]; // Llama/Mouth rarities[3] = [140, 224, 28, 112, 112, 112, 254, 229, 160, 221, 140]; aliases[3] = [7, 7, 7, 7, 7, 8, 0, 6, 7, 8, 9]; // Llama/Clothes rarities[4] = [229, 254, 191, 216, 127, 152, 152, 165, 76, 114, 254, 152, 203, 76, 191]; aliases[4] = [1, 0, 1, 2, 3, 2, 2, 4, 2, 4, 7, 4, 10, 7, 12]; // Llama/Tail rarities[5] = [127, 255, 127, 127, 229, 102, 255, 255, 178, 51]; aliases[5] = [7, 0, 7, 7, 7, 7, 0, 0, 7, 8]; // Llama/alphaIndex rarities[6] = [255]; aliases[6] = [0]; // Dog/Body rarities[7] = [140, 254, 28, 224, 56, 181, 244, 84, 219, 28, 193]; aliases[7] = [1, 0, 1, 1, 5, 1, 5, 5, 6, 10, 8]; // Dog/Hat rarities[8] = [99, 165, 255, 178, 33, 232, 102, 33, 198, 232, 209, 198, 132]; aliases[8] = [6, 6, 0, 2, 6, 6, 3, 6, 6, 6, 6, 6, 10]; // Dog/Eye rarities[9] = [254, 30, 224, 153, 203, 30, 153, 214, 91, 91, 214, 153]; aliases[9] = [0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 4]; // Dog/Mouth rarities[10] = [254, 122, 61, 30, 61, 122, 142, 91, 91, 183, 244, 244]; aliases[10] = [0, 0, 0, 0, 8, 8, 0, 9, 6, 8, 9, 9]; // Dog/Clothes rarities[11] = [254, 107, 107, 35, 152, 198, 35, 107, 117, 132, 107, 107, 107, 107]; aliases[11] = [0, 4, 5, 5, 0, 4, 5, 5, 5, 8, 8, 8, 9, 9]; // Dog/Tail rarities[12] = [140, 254, 84, 84, 84, 203, 140, 196, 196, 140, 140]; aliases[12] = [1, 0, 5, 5, 5, 1, 5, 5, 5, 5, 5]; // Dog/alphaIndex rarities[13] = [254, 101, 153, 51]; aliases[13] = [0, 0, 0, 1]; } modifier requireContractsSet() { require( address(traits) != address(0) && address(staking) != address(0), "Contracts not set" ); _; } function setContracts(ITraits _traits, IStaking _staking, IDIAMOND _diamond) external onlyOwner { traits = _traits; staking = _staking; diamond = _diamond; } function setWhiteListMerkleRoot(bytes32 _root) external onlyOwner { whitelistMerkleRoot = _root; } modifier isValidMerkleProof(bytes32[] memory proof) { require( MerkleProof.verify( proof, whitelistMerkleRoot, bytes32(uint256(uint160(_msgSender()))) ), "INVALID_MERKLE_PROOF" ); _; } /** EXTERNAL */ /** * Returns the total amount of tokens minted in the contract. */ function minted() external view returns (uint256) { return _totalMinted(); } function communitySaleLeft(bytes32[] memory merkleProof) external view isValidMerkleProof(merkleProof) returns (uint256) { if (_totalMinted() >= PAID_TOKENS) return 0; return MAX_COMMUNITY_AMOUNT - claimed[_msgSender()]; } /** * mint a token - 90% Llama, 10% Dog * The first 20% are free to claim, the remaining cost $DIAMOND */ function mintGame(uint256 amount, bool stake) internal whenNotPaused nonReentrant returns (uint16[] memory tokenIds) { require(tx.origin == _msgSender(), "ONLY_EOA"); require(_totalMinted() + amount <= MAX_TOKENS, "MINT_ENDED"); require(amount > 0 && amount <= 15, "MINT_AMOUNT_INVALID"); uint256 totalDiamondCost = 0; tokenIds = new uint16[](amount); uint16 token = uint16(_totalMinted()); for (uint256 i = 0; i < amount; i++) { token++; generate(token, random(token)); tokenIds[i] = token; totalDiamondCost += mintCost(token); } if (totalDiamondCost > 0) diamond.burn(_msgSender(), totalDiamondCost); _mint(stake ? address(staking) : _msgSender(), amount, "", false); if (stake) staking.addManyToStaking(_msgSender(), tokenIds); return tokenIds; } /** * mint a token - 90% Llama, 10% Dog * The first 20% are free to claim, the remaining cost $DIAMOND */ function mint(uint256 amount, bool stake) external payable { if (_totalMinted() < PAID_TOKENS) { // we have to still pay in ETH, we can make a transaction that pays both in ETH and DIAMOND // check how many tokens should be paid in ETH, the DIAMOND will be burned in mintGame function require(msg.value == (amount > (PAID_TOKENS - _totalMinted()) ? (PAID_TOKENS - _totalMinted()) : amount) * MINT_PRICE, "MINT_PAID_PRICE_INVALID"); } else { require(msg.value == 0, "MINT_PAID_IN_DIAMONDS"); } mintGame(amount, stake); } function mintCommunitySale( bytes32[] memory merkleProof, uint256 amount, bool stake ) external payable isValidMerkleProof(merkleProof) { require( claimed[_msgSender()] + amount <= MAX_COMMUNITY_AMOUNT, "MINT_COMMUNITY_ENDED" ); require(_totalMinted() + amount <= PAID_TOKENS, "MINT_ENDED"); require(msg.value == COMMUNITY_SALE_MINT_PRICE * (claimed[_msgSender()] == 0 ? amount - 1 : amount), "MINT_COMMUNITY_PRICE_INVALID"); claimed[_msgSender()] += amount; mintGame(amount, stake); } /** * 0 - 20% = eth * 20 - 40% = 200 DIAMONDS * 40 - 60% = 300 DIAMONDS * 60 - 80% = 400 DIAMONDS * 80 - 100% = 500 DIAMONDS * @param tokenId the ID to check the cost of to mint * @return the cost of the given token ID */ function mintCost(uint256 tokenId) public view returns (uint256) { if (tokenId <= PAID_TOKENS) return 0; // 1 / 5 = PAID_TOKENS if (tokenId <= (MAX_TOKENS * 2) / 5) return 200 ether; if (tokenId <= (MAX_TOKENS * 3) / 5) return 300 ether; if (tokenId <= (MAX_TOKENS * 4) / 5) return 400 ether; return 500 ether; } function isApprovedForAll(address owner, address operator) public view override(ERC721AUpgradeable, IERC721Upgradeable) returns (bool) { return (address(staking) == operator || ERC721AUpgradeable.isApprovedForAll(owner, operator)); } /** INTERNAL */ /** * generates traits for a specific token, checking to make sure it's unique * @param tokenId the id of the token to generate traits for * @param seed a pseudorandom 256 bit number to derive traits from * @return t - a struct of traits for the given token ID */ function generate(uint256 tokenId, uint256 seed) internal returns (LlamaDog memory t) { t = selectTraits(tokenId, seed); if (existingCombinations[structToHash(t)] == 0) { tokenTraits[tokenId] = t; existingCombinations[structToHash(t)] = tokenId; if (t.isLlama) { emit LlamaMinted(tokenId); } else { emit DogMinted(tokenId); } return t; } return generate(tokenId, random(seed)); } /** * uses A.J. Walker's Alias algorithm for O(1) rarity table lookup * ensuring O(1) instead of O(n) reduces mint cost by more than 50% * probability & alias tables are generated off-chain beforehand * @param seed portion of the 256 bit seed to remove trait correlation * @param traitType the trait type to select a trait for * @return the ID of the randomly selected trait */ function selectTrait(uint16 seed, uint8 traitType) internal view returns (uint8) { uint8 trait = uint8(seed) % uint8(rarities[traitType].length); // If a selected random trait probability is selected (biased coin) return that trait if (seed >> 8 <= rarities[traitType][trait]) return trait; return aliases[traitType][trait]; } /** * selects the species and all of its traits based on the seed value * @param seed a pseudorandom 256 bit number to derive traits from * @return t - a struct of randomly selected traits */ function selectTraits(uint256 tokenId, uint256 seed) internal view returns (LlamaDog memory t) { // if tokenId < PAID_TOKENS, 2 in 10 chance of a dog, otherwise 1 in 10 chance of a dog t.isLlama = tokenId < PAID_TOKENS ? (seed & 0xFFFF) % 10 < 9 : (seed & 0xFFFF) % 10 < 1; uint8 shift = t.isLlama ? 0 : 7; // what happens here is that we check the 16 least signficial bits of the seed // and then remove them from the seed, so that the next 16 bits are used for the next trait // Before: EBD302F8B72AB0883F98D59C3BB7C25C61E30A77AB5F93924D234A620A32 // After: EBD302F8B72AB0883F98D59C3BB7C25C61E30A77AB5F93924D234A62 // trait 1: 0A32 -> 00001010 00110010 seed >>= 16; t.body = selectTrait(uint16(seed & 0xFFFF), 0 + shift); seed >>= 16; t.hat = selectTrait(uint16(seed & 0xFFFF), 1 + shift); seed >>= 16; t.eye = selectTrait(uint16(seed & 0xFFFF), 2 + shift); seed >>= 16; t.mouth = selectTrait(uint16(seed & 0xFFFF), 3 + shift); seed >>= 16; t.clothes = selectTrait(uint16(seed & 0xFFFF), 4 + shift); seed >>= 16; t.tail = selectTrait(uint16(seed & 0xFFFF), 5 + shift); seed >>= 16; t.alphaIndex = selectTrait(uint16(seed & 0xFFFF), 6 + shift); } /** * converts a struct to a 256 bit hash to check for uniqueness * @param s the struct to pack into a hash * @return the 256 bit hash of the struct */ function structToHash(LlamaDog memory s) internal pure returns (uint256) { return uint256( bytes32( abi.encodePacked( s.isLlama, s.body, s.hat, s.eye, s.mouth, s.clothes, s.tail, s.alphaIndex ) ) ); } /** * generates a pseudorandom number * @param seed a value ensure different outcomes for different sources in the same block * @return a pseudorandom value */ function random(uint256 seed) internal view returns (uint256) { return uint256( keccak256( abi.encodePacked( tx.origin, blockhash(block.number - 1), block.timestamp, seed ) ) ); } /** READ */ function getTokenTraits(uint256 tokenId) external view override returns (LlamaDog memory) { require( _exists(tokenId), "ERC721Metadata: token traits query for nonexistent token" ); return tokenTraits[tokenId]; } function getPaidTokens() external view override returns (uint256) { return PAID_TOKENS; } /** * checks if a token is a Wizards * @param tokenId the ID of the token to check * @return wizard - whether or not a token is a Wizards */ function isLlama(uint256 tokenId) external view override returns (bool) { IDiamondHeist.LlamaDog memory s = tokenTraits[tokenId]; return s.isLlama; } /** ADMIN */ /** * allows owner to withdraw funds from minting */ function withdraw() external onlyOwner { payable(owner()).transfer(address(this).balance); } /** * updates the number of tokens for sale */ function setPaidTokens(uint256 _paidTokens) external onlyOwner { PAID_TOKENS = _paidTokens; } /** * updates the mint price */ function setMintPrice(uint256 _mintPrice) external onlyOwner { MINT_PRICE = _mintPrice; COMMUNITY_SALE_MINT_PRICE = _mintPrice / 4 * 3; } /** * enables owner to pause / unpause minting */ function setPaused(bool _paused) external requireContractsSet onlyOwner { if (_paused) _pause(); else _unpause(); } /** RENDER */ function tokenURI(uint256 tokenId) public view override(ERC721AUpgradeable, IERC721MetadataUpgradeable) returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); return traits.tokenURI(tokenId); } } // File @openzeppelin/contracts/utils/[email protected] // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File @openzeppelin/contracts/access/[email protected] // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File @openzeppelin/contracts/token/ERC721/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File @openzeppelin/contracts/security/[email protected] // 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; } } // File @openzeppelin/contracts/security/[email protected] // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // File contracts/Staking.sol pragma solidity ^0.8.0; contract Staking is IStaking, Ownable, ReentrancyGuard, IERC721Receiver, Pausable { // maximum alpha score for a Dog uint8 public constant MAX_ALPHA = 8; // struct to store a stake's token, owner, and earning values struct Stake { uint16 tokenId; uint80 value; address owner; } uint256 private totalAlphaStaked; uint256 public numLlamaStaked; event TokenStaked(address indexed owner, uint256 indexed tokenId, bool indexed isLlama, uint256 value); event LlamaClaimed(uint256 indexed tokenId, bool indexed unstaked, uint256 earned); event DogClaimed(uint256 indexed tokenId, bool indexed unstaked, uint256 earned); // reference to the DiamondHeist NFT contract IDiamondHeist public game; // reference to the $DIAMOND contract for minting $DIAMOND earnings IDIAMOND public diamond; // maps tokenId to stake for llamas mapping(uint256 => Stake) public staking; // maps alpha to all Dog stakes with that alpha mapping(uint256 => Stake[]) public dogStaking; // tracks location of each Dog in Staking mapping(uint256 => uint256) public dogIndices; // any rewards distributed when no dogs are staked uint256 public unaccountedRewards = 0; // amount of $DIAMOND due for each alpha point staked uint256 public diamondPerAlpha = 0; // llama earn 100 $DIAMOND per day uint256 public constant DAILY_DIAMOND_RATE = 100 ether; // llamas must have 2 days worth of $DIAMOND to unstake or else they're still staked uint256 public constant MINIMUM_TO_EXIT = 2 days; // dogs take a 20% tax on all $DIAMOND claimed uint256 public constant DIAMOND_CLAIM_TAX_PERCENTAGE = 20; // there will only ever be (roughly) 24 million $DIAMOND earned through staking uint256 public constant MAXIMUM_GLOBAL_DIAMOND = 24000000 ether; // amount of $DIAMOND earned so far uint256 public totalDiamondEarned; // the last time $DIAMOND was claimed uint256 public lastClaimTimestamp; // emergency rescue to allow unstaking without any checks but without $DIAMOND bool public rescueEnabled = false; modifier onlyDuringDay { require((block.timestamp % (6*3600)) > (3*3600), "ONLY DURING DAY"); _; } constructor() { _pause(); } modifier requireContractsSet() { require(address(game) != address(0) && address(diamond) != address(0), "CONTRACTS NOT SET"); _; } function setContracts(IDiamondHeist _diamondheist, IDIAMOND _diamond) external onlyOwner { game = _diamondheist; diamond = _diamond; } /** STAKING */ /** * Stakes Llamas and Dogs * @param account the address of the staker * @param tokenIds the IDs of the Llamas and Dogs to stake */ function addManyToStaking(address account, uint16[] calldata tokenIds) external override whenNotPaused nonReentrant { require(tx.origin == _msgSender() || _msgSender() == address(game), "Only EOA"); require(account == tx.origin, "account to sender mismatch"); for (uint i = 0; i < tokenIds.length; i++) { if (tokenIds[i] == 0) { continue; } if (_msgSender() != address(game)) { // dont do this step if its a mint + stake require(game.ownerOf(tokenIds[i]) == _msgSender(), "You don't own this token"); game.transferFrom(_msgSender(), address(this), tokenIds[i]); } if (game.isLlama(tokenIds[i])) _addLlama(account, tokenIds[i]); else _addDog(account, tokenIds[i]); } } /** * adds a single Llamas to the Staking * @param account the address of the staker * @param tokenId the ID of the Llamas to add to the Staking */ function _addLlama(address account, uint256 tokenId) internal whenNotPaused _updateEarnings { staking[tokenId] = Stake({ owner: account, tokenId: uint16(tokenId), value: uint80(block.timestamp) }); numLlamaStaked += 1; emit TokenStaked(account, tokenId, true, block.timestamp); } /** * Stake a Dog * @param account the address of the staker * @param tokenId the ID of the Dog to add to Staking */ function _addDog(address account, uint256 tokenId) internal { uint256 alpha = _alphaForDog(tokenId); totalAlphaStaked += alpha; // Portion of earnings ranges from 8 to 5 dogIndices[tokenId] = dogStaking[alpha].length; // Store the location of the dog in the Staking dogStaking[alpha].push(Stake({ owner: account, tokenId: uint16(tokenId), value: uint80(diamondPerAlpha) })); // Add the dog to the Staking emit TokenStaked(account, tokenId, false, diamondPerAlpha); } /** CLAIMING / UNSTAKING */ /** * realize $DIAMOND earnings and optionally unstake tokens from the Staking / Staking * to unstake a Llamas it will require it has 2 days worth of $DIAMOND unclaimed * @param tokenIds the IDs of the tokens to claim earnings from * @param unstake whether or not to unstake ALL of the tokens listed in tokenIds */ function claimMany(uint16[] calldata tokenIds, bool unstake) external whenNotPaused _updateEarnings onlyDuringDay nonReentrant { require(tx.origin == _msgSender() || _msgSender() == address(game), "Only EOA"); uint256 owed = 0; for (uint i = 0; i < tokenIds.length; i++) { if (game.isLlama(tokenIds[i])) owed += _claimLlama(tokenIds[i], unstake); else owed += _claimDog(tokenIds[i], unstake); } if (owed == 0) return; diamond.mint(_msgSender(), owed); } /** * realize $DIAMOND earnings for a single Llamas and optionally unstake it * if not unstaking, pay a 20% tax to the staked Dogs * if unstaking, there is a 50% chance all $DIAMOND is stolen * @param tokenId the ID of the Llamas to claim earnings from * @param unstake whether or not to unstake the Llamas * @return owed - the amount of $DIAMOND earned */ function _claimLlama(uint256 tokenId, bool unstake) internal returns (uint256 owed) { Stake memory stake = staking[tokenId]; require(stake.owner == _msgSender(), "Don't own the given token"); require(!(unstake && block.timestamp - stake.value < MINIMUM_TO_EXIT), "Wait 2 days to unstake"); if (totalDiamondEarned < MAXIMUM_GLOBAL_DIAMOND) { owed = (block.timestamp - stake.value) * DAILY_DIAMOND_RATE / 1 days; } else if (stake.value > lastClaimTimestamp) { // $DIAMOND production stopped already owed = 0; } else { // stop earning additional $DIAMOND if it's all been earned owed = (lastClaimTimestamp - stake.value) * DAILY_DIAMOND_RATE / 1 days; } if (unstake) { if (random(tokenId) & 1 == 1) { // 50% chance of all $DIAMOND stolen _payDogTax(owed); owed = 0; } delete staking[tokenId]; numLlamaStaked -= 1; // Always transfer last to guard against reentrance game.safeTransferFrom(address(this), _msgSender(), tokenId, ""); // send back Llamas } else { _payDogTax(owed * DIAMOND_CLAIM_TAX_PERCENTAGE / 100); // percentage tax to staked dogs owed = owed * (100 - DIAMOND_CLAIM_TAX_PERCENTAGE) / 100; // remainder goes to Llamas owner staking[tokenId] = Stake({ owner: _msgSender(), tokenId: uint16(tokenId), value: uint80(block.timestamp) }); // reset stake } emit LlamaClaimed(tokenId, unstake, owed); } /** * realize $DIAMOND earnings for a single Dog and optionally unstake it * Dogs earn $DIAMOND proportional to their Alpha rank * @param tokenId the ID of the Dog to claim earnings from * @param unstake whether or not to unstake the Dog * @return owed - the amount of $DIAMOND earned */ function _claimDog(uint256 tokenId, bool unstake) internal returns (uint256 owed) { require(game.ownerOf(tokenId) == address(this), "Not staked"); uint256 alpha = _alphaForDog(tokenId); Stake memory stake = dogStaking[alpha][dogIndices[tokenId]]; require(stake.owner == _msgSender(), "Doesn't own token"); owed = (alpha) * (diamondPerAlpha - stake.value); // Calculate portion of tokens based on Alpha if (unstake) { totalAlphaStaked -= alpha; // Remove Alpha from total staked Stake memory lastStake = dogStaking[alpha][dogStaking[alpha].length - 1]; dogStaking[alpha][dogIndices[tokenId]] = lastStake; // Shuffle last Dog to current position dogIndices[lastStake.tokenId] = dogIndices[tokenId]; dogStaking[alpha].pop(); // Remove duplicate delete dogIndices[tokenId]; // Delete old mapping // Always remove last to guard against reentrance game.safeTransferFrom(address(this), _msgSender(), tokenId, ""); // Send back Dog } else { dogStaking[alpha][dogIndices[tokenId]] = Stake({ owner: _msgSender(), tokenId: uint16(tokenId), value: uint80(diamondPerAlpha) }); // reset stake } emit DogClaimed(tokenId, unstake, owed); } /** * emergency unstake tokens * @param tokenIds the IDs of the tokens to claim earnings from */ function rescue(uint256[] calldata tokenIds) external nonReentrant { require(rescueEnabled, "RESCUE DISABLED"); uint256 tokenId; Stake memory stake; Stake memory lastStake; uint256 alpha; for (uint i = 0; i < tokenIds.length; i++) { tokenId = tokenIds[i]; if (game.isLlama(tokenId)) { stake = staking[tokenId]; require(stake.owner == _msgSender(), "SWIPER, NO SWIPING"); delete staking[tokenId]; numLlamaStaked -= 1; game.safeTransferFrom(address(this), _msgSender(), tokenId, ""); // send back Llamas emit LlamaClaimed(tokenId, true, 0); } else { alpha = _alphaForDog(tokenId); stake = dogStaking[alpha][dogIndices[tokenId]]; require(stake.owner == _msgSender(), "SWIPER, NO SWIPING"); totalAlphaStaked -= alpha; // Remove Alpha from total staked lastStake = dogStaking[alpha][dogStaking[alpha].length - 1]; dogStaking[alpha][dogIndices[tokenId]] = lastStake; // Shuffle last Dog to current position dogIndices[lastStake.tokenId] = dogIndices[tokenId]; dogStaking[alpha].pop(); // Remove duplicate delete dogIndices[tokenId]; // Delete old mapping game.safeTransferFrom(address(this), _msgSender(), tokenId, ""); // Send back Dog emit DogClaimed(tokenId, true, 0); } } } /** * add $DIAMOND to claimable pot for the Staking * @param amount $DIAMOND to add to the pot */ function _payDogTax(uint256 amount) internal { if (totalAlphaStaked == 0) { // if there's no staked dogs unaccountedRewards += amount; // keep track of $DIAMOND due to dogs return; } // makes sure to include any unaccounted $DIAMOND diamondPerAlpha += (amount + unaccountedRewards) / totalAlphaStaked; unaccountedRewards = 0; } /** * tracks $DIAMOND earnings to ensure it stops once 2.4 billion is eclipsed */ modifier _updateEarnings() { if (totalDiamondEarned < MAXIMUM_GLOBAL_DIAMOND) { totalDiamondEarned += (block.timestamp - lastClaimTimestamp) * numLlamaStaked * DAILY_DIAMOND_RATE / 1 days; lastClaimTimestamp = block.timestamp; } _; } /** ADMIN */ /** * allows owner to enable "rescue mode" * simplifies accounting, prioritizes tokens out in emergency */ function setRescueEnabled(bool _enabled) external onlyOwner { rescueEnabled = _enabled; } /** * enables owner to pause / unpause contract */ function setPaused(bool _paused) external requireContractsSet onlyOwner { if (_paused) _pause(); else _unpause(); } /** READ ONLY */ /** * gets the alpha score for a Dog * @param tokenId the ID of the Dog to get the alpha score for * @return the alpha score of the Dog (5-8) */ function _alphaForDog(uint256 tokenId) internal view returns (uint8) { IDiamondHeist.LlamaDog memory s = game.getTokenTraits(tokenId); return MAX_ALPHA - s.alphaIndex; // alpha index is 0-3 } /** * generates a pseudorandom number * @param seed a value ensure different outcomes for different sources in the same block * @return a pseudorandom value */ function random(uint256 seed) internal view returns (uint256) { return uint256(keccak256(abi.encodePacked( tx.origin, blockhash(block.number - 1), block.timestamp, seed ))); } function onERC721Received( address, address from, uint256, bytes calldata ) external pure override returns (bytes4) { require(from == address(0x0), "Cannot send tokens to Staking directly"); return IERC721Receiver.onERC721Received.selector; } } // File @openzeppelin/contracts/utils/[email protected] // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File contracts/Traits.sol pragma solidity ^0.8.0; contract Traits is Ownable, ITraits { using Strings for uint256; // struct to store each trait's data for metadata and rendering struct Trait { string name; string png; } // mapping from trait type (index) to its name string[9] _traitTypes = [ "Body", "Hat", "Eye", "Mouth", "Clothes", "Tail", "Alpha" ]; // storage of each traits name and base64 PNG data mapping(uint8 => mapping(uint8 => Trait)) public traitData; // mapping from alphaIndex to its score string[4] _alphas = [ "8", "7", "6", "5" ]; IDiamondHeist public diamondheist; string private llamaDescription; string private dogDescription; constructor() {} /** ADMIN */ function setGame(address _diamondheist) external onlyOwner { diamondheist = IDiamondHeist(_diamondheist); } /** * administrative to upload the names and images associated with each trait * @param traitType the trait type to upload the traits for (see traitTypes for a mapping) * @param traits the names and base64 encoded PNGs for each trait */ function uploadTraits(uint8 traitType, uint8[] calldata traitIds, Trait[] calldata traits) external onlyOwner { require(traitIds.length == traits.length, "Mismatched inputs"); for (uint i = 0; i < traits.length; i++) { traitData[traitType][traitIds[i]] = Trait( traits[i].name, traits[i].png ); } } /** RENDER */ /** * generates an <image> element using base64 encoded PNGs * @param trait the trait storing the PNG data * @return the <image> element */ function drawTrait(Trait memory trait) internal pure returns (string memory) { return string(abi.encodePacked( '<image x="4" y="4" width="32" height="32" image-rendering="pixelated" preserveAspectRatio="xMidYMid" xlink:href="data:image/png;base64,', trait.png, '"/>' )); } /** * generates an entire SVG by composing multiple <image> elements of PNGs * @param tokenId the ID of the token to generate an SVG for * @return a valid SVG of the Llama / Dog */ function drawSVG(uint256 tokenId) public view returns (string memory) { IDiamondHeist.LlamaDog memory s = diamondheist.getTokenTraits(tokenId); uint8 shift = s.isLlama ? 0 : 7; string memory svgString = string(abi.encodePacked( drawTrait(traitData[0 + shift][s.body]), drawTrait(traitData[1 + shift][s.hat]), drawTrait(traitData[2 + shift][s.eye]), drawTrait(traitData[3 + shift][s.mouth]), drawTrait(traitData[4 + shift][s.clothes]), drawTrait(traitData[5 + shift][s.tail]) )); return string(abi.encodePacked( '<svg id="diamondheist" width="100%" height="100%" version="1.1" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">', svgString, "</svg>" )); } /** * generates an attribute for the attributes array in the ERC721 metadata standard * @param traitType the trait type to reference as the metadata key * @param value the token's trait associated with the key * @return a JSON dictionary for the single attribute */ function attributeForTypeAndValue(string memory traitType, string memory value) internal pure returns (string memory) { return string(abi.encodePacked( '{"trait_type":"', traitType, '","value":"', value, '"}' )); } /** * generates an attribute for the attributes array in the ERC721 metadata standard * @param traitType the trait type to reference as the metadata key * @param value the token's trait associated with the key * @return a JSON dictionary for the single attribute */ function attributeForTypeAndValueNumber(string memory traitType, string memory value) internal pure returns (string memory) { return string(abi.encodePacked( '{"display_type": "number", "trait_type":"', traitType, '","value":"', value, '"}' )); } /** * generates an array composed of all the individual traits and values * @param tokenId the ID of the token to compose the metadata for * @return a JSON array of all of the attributes for given token ID */ function compileAttributes(uint256 tokenId) public view returns (string memory) { IDiamondHeist.LlamaDog memory s = diamondheist.getTokenTraits(tokenId); string memory traits; if (s.isLlama) { traits = string(abi.encodePacked( attributeForTypeAndValue(_traitTypes[0], traitData[0][s.body].name),",", attributeForTypeAndValue(_traitTypes[1], traitData[1][s.hat].name),",", attributeForTypeAndValue(_traitTypes[2], traitData[2][s.eye].name),",", attributeForTypeAndValue(_traitTypes[3], traitData[3][s.mouth].name),",", attributeForTypeAndValue(_traitTypes[4], traitData[4][s.clothes].name),",", attributeForTypeAndValue(_traitTypes[5], traitData[5][s.tail].name),"," // traitData 6 = alpha score, but not visible )); } else { traits = string(abi.encodePacked( attributeForTypeAndValue(_traitTypes[0], traitData[7][s.body].name),",", attributeForTypeAndValue(_traitTypes[1], traitData[8][s.hat].name),",", attributeForTypeAndValue(_traitTypes[2], traitData[9][s.eye].name),",", attributeForTypeAndValue(_traitTypes[3], traitData[10][s.mouth].name),",", attributeForTypeAndValue(_traitTypes[4], traitData[11][s.clothes].name),",", attributeForTypeAndValue(_traitTypes[5], traitData[12][s.tail].name),",", attributeForTypeAndValueNumber("Alpha Score", _alphas[s.alphaIndex]),"," )); } return string(abi.encodePacked( '[', traits, '{"trait_type":"Generation","value":', tokenId <= diamondheist.getPaidTokens() ? '"Gen 0"' : '"Gen 1"', '},{"trait_type":"Type","value":', s.isLlama ? '"Llama"' : '"Dog"', '}]' )); } /** * generates a base64 encoded metadata response without referencing off-chain content * @param tokenId the ID of the token to generate the metadata for * @return a base64 encoded JSON dictionary of the token's metadata and SVG */ function tokenURI(uint256 tokenId) public view override returns (string memory) { IDiamondHeist.LlamaDog memory s = diamondheist.getTokenTraits(tokenId); string memory metadata = string(abi.encodePacked( '{"name": "', s.isLlama ? 'Llama #' : 'Dog #', tokenId.toString(), '", "description": "', s.isLlama ? llamaDescription : dogDescription, '", "image": "data:image/svg+xml;base64,', base64(bytes(drawSVG(tokenId))), '", "attributes":', compileAttributes(tokenId), "}" )); return string(abi.encodePacked( "data:application/json;base64,", base64(bytes(metadata)) )); } function setDescription(string memory _llama, string memory _dog) external onlyOwner { llamaDescription = _llama; dogDescription = _dog; } /** BASE 64 - Written by Brech Devos */ string internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function base64(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ""; // load the table into memory string memory table = TABLE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { dataPtr := add(dataPtr, 3) // read 3 bytes let input := mload(dataPtr) // write 4 characters mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr( 6, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and( input, 0x3F))))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"BURNER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b50600054610100900460ff166200002f5760005460ff161562000039565b62000039620000de565b620000a15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b600054610100900460ff16158015620000c4576000805461ffff19166101011790555b8015620000d7576000805461ff00191690555b506200010b565b6000620000f630620000fc60201b62000b1e1760201c565b15905090565b6001600160a01b03163b151590565b611fa1806200011b6000396000f3fe608060405234801561001057600080fd5b50600436106101da5760003560e01c806370a0823111610104578063a217fddf116100a2578063d539139311610071578063d5391393146103d1578063d547741f146103f8578063dd62ed3e1461040b578063e63ab1e91461044457600080fd5b8063a217fddf14610390578063a457c2d714610398578063a9059cbb146103ab578063d505accf146103be57600080fd5b80638456cb59116100de5780638456cb591461035a57806391d148541461036257806395d89b41146103755780639dc29fac1461037d57600080fd5b806370a08231146103165780637ecebe001461033f5780638129fc1c1461035257600080fd5b80632f2ff15d1161017c578063395093511161014b57806339509351146102dd5780633f4ba83a146102f057806340c10f19146102f85780635c975abb1461030b57600080fd5b80632f2ff15d1461029e578063313ce567146102b35780633644e515146102c257806336568abe146102ca57600080fd5b806318160ddd116101b857806318160ddd1461022f57806323b872dd14610241578063248a9ca314610254578063282c51f31461027757600080fd5b806301ffc9a7146101df57806306fdde0314610207578063095ea7b31461021c575b600080fd5b6101f26101ed366004611d10565b610459565b60405190151581526020015b60405180910390f35b61020f610490565b6040516101fe9190611daf565b6101f261022a366004611caa565b610522565b6067545b6040519081526020016101fe565b6101f261024f366004611bfb565b61053a565b610233610262366004611cd4565b60009081526097602052604090206001015490565b6102337f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a84881565b6102b16102ac366004611ced565b61055e565b005b604051601281526020016101fe565b610233610589565b6102b16102d8366004611ced565b610598565b6101f26102eb366004611caa565b61061b565b6102b161065a565b6102b1610306366004611caa565b61067e565b60c95460ff166101f2565b610233610324366004611bad565b6001600160a01b031660009081526065602052604090205490565b61023361034d366004611bad565b6106b3565b6102b16106d2565b6102b1610881565b6101f2610370366004611ced565b6108a2565b61020f6108cd565b6102b161038b366004611caa565b6108dc565b610233600081565b6101f26103a6366004611caa565b610911565b6101f26103b9366004611caa565b6109a3565b6102b16103cc366004611c37565b6109b1565b6102337f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b6102b1610406366004611ced565b610af8565b610233610419366004611bc8565b6001600160a01b03918216600090815260666020908152604080832093909416825291909152205490565b610233600080516020611f4c83398151915281565b60006001600160e01b03198216637965db0b60e01b148061048a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606068805461049f90611ebe565b80601f01602080910402602001604051908101604052809291908181526020018280546104cb90611ebe565b80156105185780601f106104ed57610100808354040283529160200191610518565b820191906000526020600020905b8154815290600101906020018083116104fb57829003601f168201915b5050505050905090565b600033610530818585610b2d565b5060019392505050565b600033610548858285610c51565b610553858585610ce3565b506001949350505050565b60008281526097602052604090206001015461057a8133610ebc565b6105848383610f20565b505050565b6000610593610fa6565b905090565b6001600160a01b038116331461060d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6106178282611021565b5050565b3360008181526066602090815260408083206001600160a01b03871684529091528120549091906105309082908690610655908790611e2d565b610b2d565b600080516020611f4c8339815191526106738133610ebc565b61067b611088565b50565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a66106a98133610ebc565b610584838361111b565b6001600160a01b038116600090815261012f602052604081205461048a565b600054610100900460ff166106ed5760005460ff16156106f1565b303b155b6107545760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610604565b600054610100900460ff16158015610776576000805461ffff19166101011790555b6107be604051806040016040528060078152602001661112505353d39160ca1b815250604051806040016040528060078152602001661112505353d39160ca1b815250611206565b6107c6611237565b6107ce611260565b6107f6604051806040016040528060078152602001661112505353d39160ca1b81525061128f565b610801600033610f20565b610819600080516020611f4c83398151915233610f20565b6108437f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a633610f20565b61086d7f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a84833610f20565b801561067b576000805461ff001916905550565b600080516020611f4c83398151915261089a8133610ebc565b61067b6112e2565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606069805461049f90611ebe565b7f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a8486109078133610ebc565b610584838361135d565b3360008181526066602090815260408083206001600160a01b0387168452909152812054909190838110156109965760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610604565b6105538286868403610b2d565b600033610530818585610ce3565b83421115610a015760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610604565b600061013054888888610a138c6114b7565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610a6e826114e0565b90506000610a7e8287878761152e565b9050896001600160a01b0316816001600160a01b031614610ae15760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610604565b610aec8a8a8a610b2d565b50505050505050505050565b600082815260976020526040902060010154610b148133610ebc565b6105848383611021565b6001600160a01b03163b151590565b6001600160a01b038316610b8f5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610604565b6001600160a01b038216610bf05760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610604565b6001600160a01b0383811660008181526066602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152606660209081526040808320938616835292905220546000198114610cdd5781811015610cd05760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610604565b610cdd8484848403610b2d565b50505050565b6001600160a01b038316610d475760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610604565b6001600160a01b038216610da95760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610604565b610db4838383611556565b6001600160a01b03831660009081526065602052604090205481811015610e2c5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610604565b6001600160a01b03808516600090815260656020526040808220858503905591851681529081208054849290610e63908490611e2d565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610eaf91815260200190565b60405180910390a3610cdd565b610ec682826108a2565b61061757610ede816001600160a01b0316601461159c565b610ee983602061159c565b604051602001610efa929190611d3a565b60408051601f198184030181529082905262461bcd60e51b825261060491600401611daf565b610f2a82826108a2565b6106175760008281526097602090815260408083206001600160a01b03851684529091529020805460ff19166001179055610f623390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006105937f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f610fd560fb5490565b60fc546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b61102b82826108a2565b156106175760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60c95460ff166110d15760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610604565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b0382166111715760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610604565b61117d60008383611556565b806067600082825461118f9190611e2d565b90915550506001600160a01b038216600090815260656020526040812080548392906111bc908490611e2d565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b600054610100900460ff1661122d5760405162461bcd60e51b815260040161060490611de2565b610617828261173f565b600054610100900460ff1661125e5760405162461bcd60e51b815260040161060490611de2565b565b600054610100900460ff166112875760405162461bcd60e51b815260040161060490611de2565b61125e61178d565b600054610100900460ff166112b65760405162461bcd60e51b815260040161060490611de2565b6112d981604051806040016040528060018152602001603160f81b8152506117c0565b61067b81611801565b60c95460ff16156113285760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610604565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586110fe3390565b6001600160a01b0382166113bd5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610604565b6113c982600083611556565b6001600160a01b0382166000908152606560205260409020548181101561143d5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610604565b6001600160a01b038316600090815260656020526040812083830390556067805484929061146c908490611e64565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6001600160a01b038116600090815261012f602052604090208054600181018255905b50919050565b600061048a6114ed610fa6565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061153f87878787611850565b9150915061154c8161193d565b5095945050505050565b60c95460ff16156105845760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610604565b606060006115ab836002611e45565b6115b6906002611e2d565b67ffffffffffffffff8111156115ce576115ce611f35565b6040519080825280601f01601f1916602001820160405280156115f8576020820181803683370190505b509050600360fc1b8160008151811061161357611613611f1f565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061164257611642611f1f565b60200101906001600160f81b031916908160001a9053506000611666846002611e45565b611671906001611e2d565b90505b60018111156116e9576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106116a5576116a5611f1f565b1a60f81b8282815181106116bb576116bb611f1f565b60200101906001600160f81b031916908160001a90535060049490941c936116e281611ea7565b9050611674565b5083156117385760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610604565b9392505050565b600054610100900460ff166117665760405162461bcd60e51b815260040161060490611de2565b8151611779906068906020850190611af8565b508051610584906069906020840190611af8565b600054610100900460ff166117b45760405162461bcd60e51b815260040161060490611de2565b60c9805460ff19169055565b600054610100900460ff166117e75760405162461bcd60e51b815260040161060490611de2565b81516020928301208151919092012060fb9190915560fc55565b600054610100900460ff166118285760405162461bcd60e51b815260040161060490611de2565b507f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c961013055565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156118875750600090506003611934565b8460ff16601b1415801561189f57508460ff16601c14155b156118b05750600090506004611934565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611904573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661192d57600060019250925050611934565b9150600090505b94509492505050565b600081600481111561195157611951611f09565b141561195a5750565b600181600481111561196e5761196e611f09565b14156119bc5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610604565b60028160048111156119d0576119d0611f09565b1415611a1e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610604565b6003816004811115611a3257611a32611f09565b1415611a8b5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610604565b6004816004811115611a9f57611a9f611f09565b141561067b5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610604565b828054611b0490611ebe565b90600052602060002090601f016020900481019282611b265760008555611b6c565b82601f10611b3f57805160ff1916838001178555611b6c565b82800160010185558215611b6c579182015b82811115611b6c578251825591602001919060010190611b51565b50611b78929150611b7c565b5090565b5b80821115611b785760008155600101611b7d565b80356001600160a01b0381168114611ba857600080fd5b919050565b600060208284031215611bbf57600080fd5b61173882611b91565b60008060408385031215611bdb57600080fd5b611be483611b91565b9150611bf260208401611b91565b90509250929050565b600080600060608486031215611c1057600080fd5b611c1984611b91565b9250611c2760208501611b91565b9150604084013590509250925092565b600080600080600080600060e0888a031215611c5257600080fd5b611c5b88611b91565b9650611c6960208901611b91565b95506040880135945060608801359350608088013560ff81168114611c8d57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215611cbd57600080fd5b611cc683611b91565b946020939093013593505050565b600060208284031215611ce657600080fd5b5035919050565b60008060408385031215611d0057600080fd5b82359150611bf260208401611b91565b600060208284031215611d2257600080fd5b81356001600160e01b03198116811461173857600080fd5b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611d72816017850160208801611e7b565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611da3816028840160208801611e7b565b01602801949350505050565b6020815260008251806020840152611dce816040850160208701611e7b565b601f01601f19169190910160400192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008219821115611e4057611e40611ef3565b500190565b6000816000190483118215151615611e5f57611e5f611ef3565b500290565b600082821015611e7657611e76611ef3565b500390565b60005b83811015611e96578181015183820152602001611e7e565b83811115610cdd5750506000910152565b600081611eb657611eb6611ef3565b506000190190565b600181811c90821680611ed257607f821691505b602082108114156114da57634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfe65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862aa2646970667358221220151c9cb2badae00d19153f766d0e23a5e3c73259f7180f2d47c0544ff29f8b1664736f6c63430008070033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c806370a0823111610104578063a217fddf116100a2578063d539139311610071578063d5391393146103d1578063d547741f146103f8578063dd62ed3e1461040b578063e63ab1e91461044457600080fd5b8063a217fddf14610390578063a457c2d714610398578063a9059cbb146103ab578063d505accf146103be57600080fd5b80638456cb59116100de5780638456cb591461035a57806391d148541461036257806395d89b41146103755780639dc29fac1461037d57600080fd5b806370a08231146103165780637ecebe001461033f5780638129fc1c1461035257600080fd5b80632f2ff15d1161017c578063395093511161014b57806339509351146102dd5780633f4ba83a146102f057806340c10f19146102f85780635c975abb1461030b57600080fd5b80632f2ff15d1461029e578063313ce567146102b35780633644e515146102c257806336568abe146102ca57600080fd5b806318160ddd116101b857806318160ddd1461022f57806323b872dd14610241578063248a9ca314610254578063282c51f31461027757600080fd5b806301ffc9a7146101df57806306fdde0314610207578063095ea7b31461021c575b600080fd5b6101f26101ed366004611d10565b610459565b60405190151581526020015b60405180910390f35b61020f610490565b6040516101fe9190611daf565b6101f261022a366004611caa565b610522565b6067545b6040519081526020016101fe565b6101f261024f366004611bfb565b61053a565b610233610262366004611cd4565b60009081526097602052604090206001015490565b6102337f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a84881565b6102b16102ac366004611ced565b61055e565b005b604051601281526020016101fe565b610233610589565b6102b16102d8366004611ced565b610598565b6101f26102eb366004611caa565b61061b565b6102b161065a565b6102b1610306366004611caa565b61067e565b60c95460ff166101f2565b610233610324366004611bad565b6001600160a01b031660009081526065602052604090205490565b61023361034d366004611bad565b6106b3565b6102b16106d2565b6102b1610881565b6101f2610370366004611ced565b6108a2565b61020f6108cd565b6102b161038b366004611caa565b6108dc565b610233600081565b6101f26103a6366004611caa565b610911565b6101f26103b9366004611caa565b6109a3565b6102b16103cc366004611c37565b6109b1565b6102337f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b6102b1610406366004611ced565b610af8565b610233610419366004611bc8565b6001600160a01b03918216600090815260666020908152604080832093909416825291909152205490565b610233600080516020611f4c83398151915281565b60006001600160e01b03198216637965db0b60e01b148061048a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606068805461049f90611ebe565b80601f01602080910402602001604051908101604052809291908181526020018280546104cb90611ebe565b80156105185780601f106104ed57610100808354040283529160200191610518565b820191906000526020600020905b8154815290600101906020018083116104fb57829003601f168201915b5050505050905090565b600033610530818585610b2d565b5060019392505050565b600033610548858285610c51565b610553858585610ce3565b506001949350505050565b60008281526097602052604090206001015461057a8133610ebc565b6105848383610f20565b505050565b6000610593610fa6565b905090565b6001600160a01b038116331461060d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6106178282611021565b5050565b3360008181526066602090815260408083206001600160a01b03871684529091528120549091906105309082908690610655908790611e2d565b610b2d565b600080516020611f4c8339815191526106738133610ebc565b61067b611088565b50565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a66106a98133610ebc565b610584838361111b565b6001600160a01b038116600090815261012f602052604081205461048a565b600054610100900460ff166106ed5760005460ff16156106f1565b303b155b6107545760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610604565b600054610100900460ff16158015610776576000805461ffff19166101011790555b6107be604051806040016040528060078152602001661112505353d39160ca1b815250604051806040016040528060078152602001661112505353d39160ca1b815250611206565b6107c6611237565b6107ce611260565b6107f6604051806040016040528060078152602001661112505353d39160ca1b81525061128f565b610801600033610f20565b610819600080516020611f4c83398151915233610f20565b6108437f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a633610f20565b61086d7f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a84833610f20565b801561067b576000805461ff001916905550565b600080516020611f4c83398151915261089a8133610ebc565b61067b6112e2565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606069805461049f90611ebe565b7f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a8486109078133610ebc565b610584838361135d565b3360008181526066602090815260408083206001600160a01b0387168452909152812054909190838110156109965760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610604565b6105538286868403610b2d565b600033610530818585610ce3565b83421115610a015760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610604565b600061013054888888610a138c6114b7565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610a6e826114e0565b90506000610a7e8287878761152e565b9050896001600160a01b0316816001600160a01b031614610ae15760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610604565b610aec8a8a8a610b2d565b50505050505050505050565b600082815260976020526040902060010154610b148133610ebc565b6105848383611021565b6001600160a01b03163b151590565b6001600160a01b038316610b8f5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610604565b6001600160a01b038216610bf05760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610604565b6001600160a01b0383811660008181526066602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152606660209081526040808320938616835292905220546000198114610cdd5781811015610cd05760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610604565b610cdd8484848403610b2d565b50505050565b6001600160a01b038316610d475760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610604565b6001600160a01b038216610da95760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610604565b610db4838383611556565b6001600160a01b03831660009081526065602052604090205481811015610e2c5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610604565b6001600160a01b03808516600090815260656020526040808220858503905591851681529081208054849290610e63908490611e2d565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610eaf91815260200190565b60405180910390a3610cdd565b610ec682826108a2565b61061757610ede816001600160a01b0316601461159c565b610ee983602061159c565b604051602001610efa929190611d3a565b60408051601f198184030181529082905262461bcd60e51b825261060491600401611daf565b610f2a82826108a2565b6106175760008281526097602090815260408083206001600160a01b03851684529091529020805460ff19166001179055610f623390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006105937f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f610fd560fb5490565b60fc546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b61102b82826108a2565b156106175760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60c95460ff166110d15760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610604565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b0382166111715760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610604565b61117d60008383611556565b806067600082825461118f9190611e2d565b90915550506001600160a01b038216600090815260656020526040812080548392906111bc908490611e2d565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b600054610100900460ff1661122d5760405162461bcd60e51b815260040161060490611de2565b610617828261173f565b600054610100900460ff1661125e5760405162461bcd60e51b815260040161060490611de2565b565b600054610100900460ff166112875760405162461bcd60e51b815260040161060490611de2565b61125e61178d565b600054610100900460ff166112b65760405162461bcd60e51b815260040161060490611de2565b6112d981604051806040016040528060018152602001603160f81b8152506117c0565b61067b81611801565b60c95460ff16156113285760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610604565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586110fe3390565b6001600160a01b0382166113bd5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610604565b6113c982600083611556565b6001600160a01b0382166000908152606560205260409020548181101561143d5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610604565b6001600160a01b038316600090815260656020526040812083830390556067805484929061146c908490611e64565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6001600160a01b038116600090815261012f602052604090208054600181018255905b50919050565b600061048a6114ed610fa6565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061153f87878787611850565b9150915061154c8161193d565b5095945050505050565b60c95460ff16156105845760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610604565b606060006115ab836002611e45565b6115b6906002611e2d565b67ffffffffffffffff8111156115ce576115ce611f35565b6040519080825280601f01601f1916602001820160405280156115f8576020820181803683370190505b509050600360fc1b8160008151811061161357611613611f1f565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061164257611642611f1f565b60200101906001600160f81b031916908160001a9053506000611666846002611e45565b611671906001611e2d565b90505b60018111156116e9576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106116a5576116a5611f1f565b1a60f81b8282815181106116bb576116bb611f1f565b60200101906001600160f81b031916908160001a90535060049490941c936116e281611ea7565b9050611674565b5083156117385760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610604565b9392505050565b600054610100900460ff166117665760405162461bcd60e51b815260040161060490611de2565b8151611779906068906020850190611af8565b508051610584906069906020840190611af8565b600054610100900460ff166117b45760405162461bcd60e51b815260040161060490611de2565b60c9805460ff19169055565b600054610100900460ff166117e75760405162461bcd60e51b815260040161060490611de2565b81516020928301208151919092012060fb9190915560fc55565b600054610100900460ff166118285760405162461bcd60e51b815260040161060490611de2565b507f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c961013055565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156118875750600090506003611934565b8460ff16601b1415801561189f57508460ff16601c14155b156118b05750600090506004611934565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611904573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661192d57600060019250925050611934565b9150600090505b94509492505050565b600081600481111561195157611951611f09565b141561195a5750565b600181600481111561196e5761196e611f09565b14156119bc5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610604565b60028160048111156119d0576119d0611f09565b1415611a1e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610604565b6003816004811115611a3257611a32611f09565b1415611a8b5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610604565b6004816004811115611a9f57611a9f611f09565b141561067b5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610604565b828054611b0490611ebe565b90600052602060002090601f016020900481019282611b265760008555611b6c565b82601f10611b3f57805160ff1916838001178555611b6c565b82800160010185558215611b6c579182015b82811115611b6c578251825591602001919060010190611b51565b50611b78929150611b7c565b5090565b5b80821115611b785760008155600101611b7d565b80356001600160a01b0381168114611ba857600080fd5b919050565b600060208284031215611bbf57600080fd5b61173882611b91565b60008060408385031215611bdb57600080fd5b611be483611b91565b9150611bf260208401611b91565b90509250929050565b600080600060608486031215611c1057600080fd5b611c1984611b91565b9250611c2760208501611b91565b9150604084013590509250925092565b600080600080600080600060e0888a031215611c5257600080fd5b611c5b88611b91565b9650611c6960208901611b91565b95506040880135945060608801359350608088013560ff81168114611c8d57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215611cbd57600080fd5b611cc683611b91565b946020939093013593505050565b600060208284031215611ce657600080fd5b5035919050565b60008060408385031215611d0057600080fd5b82359150611bf260208401611b91565b600060208284031215611d2257600080fd5b81356001600160e01b03198116811461173857600080fd5b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611d72816017850160208801611e7b565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611da3816028840160208801611e7b565b01602801949350505050565b6020815260008251806020840152611dce816040850160208701611e7b565b601f01601f19169190910160400192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008219821115611e4057611e40611ef3565b500190565b6000816000190483118215151615611e5f57611e5f611ef3565b500290565b600082821015611e7657611e76611ef3565b500390565b60005b83811015611e96578181015183820152602001611e7e565b83811115610cdd5750506000910152565b600081611eb657611eb6611ef3565b506000190190565b600181811c90821680611ed257607f821691505b602082108114156114da57634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfe65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862aa2646970667358221220151c9cb2badae00d19153f766d0e23a5e3c73259f7180f2d47c0544ff29f8b1664736f6c63430008070033
Deployed Bytecode Sourcemap
70741:1455:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;40119:215;;;;;;:::i;:::-;;:::i;:::-;;;4234:14:1;;4227:22;4209:41;;4197:2;4182:18;40119:215:0;;;;;;;;18443:100;;;:::i;:::-;;;;;;;:::i;20794:201::-;;;;;;:::i;:::-;;:::i;19563:108::-;19651:12;;19563:108;;;4407:25:1;;;4395:2;4380:18;19563:108:0;4261:177:1;21575:295:0;;;;;;:::i;:::-;;:::i;41579:131::-;;;;;;:::i;:::-;41653:7;41680:12;;;:6;:12;;;;;:22;;;;41579:131;71019:62;;71057:24;71019:62;;41972:147;;;;;;:::i;:::-;;:::i;:::-;;19405:93;;;19488:2;15136:36:1;;15124:2;15109:18;19405:93:0;14994:184:1;69674:115:0;;;:::i;43020:218::-;;;;;;:::i;:::-;;:::i;22279:240::-;;;;;;:::i;:::-;;:::i;71657:77::-;;;:::i;71742:118::-;;;;;;:::i;:::-;;:::i;46789:86::-;46860:7;;;;46789:86;;19734:127;;;;;;:::i;:::-;-1:-1:-1;;;;;19835:18:0;19808:7;19835:18;;;:9;:18;;;;;;;19734:127;69416:128;;;;;;:::i;:::-;;:::i;71180:388::-;;;:::i;71576:73::-;;;:::i;40426:147::-;;;;;;:::i;:::-;;:::i;18662:104::-;;;:::i;71868:118::-;;;;;;:::i;:::-;;:::i;39506:49::-;;39551:4;39506:49;;23022:438;;;;;;:::i;:::-;;:::i;20067:193::-;;;;;;:::i;:::-;;:::i;68694:656::-;;;;;;:::i;:::-;;:::i;70950:62::-;;70988:24;70950:62;;42364:149;;;;;;:::i;:::-;;:::i;20323:151::-;;;;;;:::i;:::-;-1:-1:-1;;;;;20439:18:0;;;20412:7;20439:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;20323:151;70881:62;;-1:-1:-1;;;;;;;;;;;70881:62:0;;40119:215;40204:4;-1:-1:-1;;;;;;40228:58:0;;-1:-1:-1;;;40228:58:0;;:98;;-1:-1:-1;;;;;;;;;;36920:51:0;;;40290:36;40221:105;40119:215;-1:-1:-1;;40119:215:0:o;18443:100::-;18497:13;18530:5;18523:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;18443:100;:::o;20794:201::-;20877:4;15574:10;20933:32;15574:10;20949:7;20958:6;20933:8;:32::i;:::-;-1:-1:-1;20983:4:0;;20794:201;-1:-1:-1;;;20794:201:0:o;21575:295::-;21706:4;15574:10;21764:38;21780:4;15574:10;21795:6;21764:15;:38::i;:::-;21813:27;21823:4;21829:2;21833:6;21813:9;:27::i;:::-;-1:-1:-1;21858:4:0;;21575:295;-1:-1:-1;;;;21575:295:0:o;41972:147::-;41653:7;41680:12;;;:6;:12;;;;;:22;;;39997:30;40008:4;15574:10;39997;:30::i;:::-;42086:25:::1;42097:4;42103:7;42086:10;:25::i;:::-;41972:147:::0;;;:::o;69674:115::-;69734:7;69761:20;:18;:20::i;:::-;69754:27;;69674:115;:::o;43020:218::-;-1:-1:-1;;;;;43116:23:0;;15574:10;43116:23;43108:83;;;;-1:-1:-1;;;43108:83:0;;14238:2:1;43108:83:0;;;14220:21:1;14277:2;14257:18;;;14250:30;14316:34;14296:18;;;14289:62;-1:-1:-1;;;14367:18:1;;;14360:45;14422:19;;43108:83:0;;;;;;;;;43204:26;43216:4;43222:7;43204:11;:26::i;:::-;43020:218;;:::o;22279:240::-;15574:10;22367:4;22448:18;;;:11;:18;;;;;;;;-1:-1:-1;;;;;22448:27:0;;;;;;;;;;22367:4;;15574:10;22423:66;;15574:10;;22448:27;;:40;;22478:10;;22448:40;:::i;:::-;22423:8;:66::i;71657:77::-;-1:-1:-1;;;;;;;;;;;39997:30:0;70919:24;15574:10;39997;:30::i;:::-;71716:10:::1;:8;:10::i;:::-;71657:77:::0;:::o;71742:118::-;70988:24;39997:30;70988:24;15574:10;39997;:30::i;:::-;71835:17:::1;71841:2;71845:6;71835:5;:17::i;69416:128::-:0;-1:-1:-1;;;;;69512:14:0;;69485:7;69512:14;;;:7;:14;;;;;66392;69512:24;66300:114;71180:388;13790:13;;;;;;;:48;;13826:12;;;;13825:13;13790:48;;;14593:4;5366:19;:23;13806:16;13782:107;;;;-1:-1:-1;;;13782:107:0;;11030:2:1;13782:107:0;;;11012:21:1;11069:2;11049:18;;;11042:30;11108:34;11088:18;;;11081:62;-1:-1:-1;;;11159:18:1;;;11152:44;11213:19;;13782:107:0;10828:410:1;13782:107:0;13902:19;13925:13;;;;;;13924:14;13949:101;;;;13984:13;:20;;-1:-1:-1;;14019:19:0;;;;;13949:101;71232:34:::1;;;;;;;;;;;;;;-1:-1:-1::0;;;71232:34:0::1;;::::0;::::1;;;;;;;;;;;;;-1:-1:-1::0;;;71232:34:0::1;;::::0;:12:::1;:34::i;:::-;71277:22;:20;:22::i;:::-;71310:17;:15;:17::i;:::-;71338:29;;;;;;;;;;;;;;-1:-1:-1::0;;;71338:29:0::1;;::::0;:18:::1;:29::i;:::-;71380:42;39551:4;71411:10;71380;:42::i;:::-;71433:35;-1:-1:-1::0;;;;;;;;;;;71457:10:0::1;71433;:35::i;:::-;71479;70988:24;71503:10;71479;:35::i;:::-;71525;71057:24;71549:10;71525;:35::i;:::-;14080:14:::0;14076:68;;;14127:5;14111:21;;-1:-1:-1;;14111:21:0;;;13497:654;71180:388::o;71576:73::-;-1:-1:-1;;;;;;;;;;;39997:30:0;70919:24;15574:10;39997;:30::i;:::-;71633:8:::1;:6;:8::i;40426:147::-:0;40512:4;40536:12;;;:6;:12;;;;;;;;-1:-1:-1;;;;;40536:29:0;;;;;;;;;;;;;;;40426:147::o;18662:104::-;18718:13;18751:7;18744:14;;;;;:::i;71868:118::-;71057:24;39997:30;71057:24;15574:10;39997;:30::i;:::-;71961:17:::1;71967:2;71971:6;71961:5;:17::i;23022:438::-:0;15574:10;23115:4;23198:18;;;:11;:18;;;;;;;;-1:-1:-1;;;;;23198:27:0;;;;;;;;;;23115:4;;15574:10;23244:35;;;;23236:85;;;;-1:-1:-1;;;23236:85:0;;13832:2:1;23236:85:0;;;13814:21:1;13871:2;13851:18;;;13844:30;13910:34;13890:18;;;13883:62;-1:-1:-1;;;13961:18:1;;;13954:35;14006:19;;23236:85:0;13630:401:1;23236:85:0;23357:60;23366:5;23373:7;23401:15;23382:16;:34;23357:8;:60::i;20067:193::-;20146:4;15574:10;20202:28;15574:10;20219:2;20223:6;20202:9;:28::i;68694:656::-;68938:8;68919:15;:27;;68911:69;;;;-1:-1:-1;;;68911:69:0;;9517:2:1;68911:69:0;;;9499:21:1;9556:2;9536:18;;;9529:30;9595:31;9575:18;;;9568:59;9644:18;;68911:69:0;9315:353:1;68911:69:0;68993:18;69035:16;;69053:5;69060:7;69069:5;69076:16;69086:5;69076:9;:16::i;:::-;69024:79;;;;;;4730:25:1;;;;-1:-1:-1;;;;;4829:15:1;;;4809:18;;;4802:43;4881:15;;;;4861:18;;;4854:43;4913:18;;;4906:34;4956:19;;;4949:35;5000:19;;;4993:35;;;4702:19;;69024:79:0;;;;;;;;;;;;69014:90;;;;;;68993:111;;69117:12;69132:28;69149:10;69132:16;:28::i;:::-;69117:43;;69173:14;69190:39;69215:4;69221:1;69224;69227;69190:24;:39::i;:::-;69173:56;;69258:5;-1:-1:-1;;;;;69248:15:0;:6;-1:-1:-1;;;;;69248:15:0;;69240:58;;;;-1:-1:-1;;;69240:58:0;;11848:2:1;69240:58:0;;;11830:21:1;11887:2;11867:18;;;11860:30;11926:32;11906:18;;;11899:60;11976:18;;69240:58:0;11646:354:1;69240:58:0;69311:31;69320:5;69327:7;69336:5;69311:8;:31::i;:::-;68900:450;;;68694:656;;;;;;;:::o;42364:149::-;41653:7;41680:12;;;:6;:12;;;;;:22;;;39997:30;40008:4;15574:10;39997;:30::i;:::-;42479:26:::1;42491:4;42497:7;42479:11;:26::i;5071:326::-:0;-1:-1:-1;;;;;5366:19:0;;:23;;;5071:326::o;26658:380::-;-1:-1:-1;;;;;26794:19:0;;26786:68;;;;-1:-1:-1;;;26786:68:0;;13015:2:1;26786:68:0;;;12997:21:1;13054:2;13034:18;;;13027:30;13093:34;13073:18;;;13066:62;-1:-1:-1;;;13144:18:1;;;13137:34;13188:19;;26786:68:0;12813:400:1;26786:68:0;-1:-1:-1;;;;;26873:21:0;;26865:68;;;;-1:-1:-1;;;26865:68:0;;8756:2:1;26865:68:0;;;8738:21:1;8795:2;8775:18;;;8768:30;8834:34;8814:18;;;8807:62;-1:-1:-1;;;8885:18:1;;;8878:32;8927:19;;26865:68:0;8554:398:1;26865:68:0;-1:-1:-1;;;;;26946:18:0;;;;;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;:36;;;26998:32;;4407:25:1;;;26998:32:0;;4380:18:1;26998:32:0;;;;;;;26658:380;;;:::o;27325:453::-;-1:-1:-1;;;;;20439:18:0;;;27460:24;20439:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;-1:-1:-1;;27527:37:0;;27523:248;;27609:6;27589:16;:26;;27581:68;;;;-1:-1:-1;;;27581:68:0;;9159:2:1;27581:68:0;;;9141:21:1;9198:2;9178:18;;;9171:30;9237:31;9217:18;;;9210:59;9286:18;;27581:68:0;8957:353:1;27581:68:0;27693:51;27702:5;27709:7;27737:6;27718:16;:25;27693:8;:51::i;:::-;27449:329;27325:453;;;:::o;23939:671::-;-1:-1:-1;;;;;24070:18:0;;24062:68;;;;-1:-1:-1;;;24062:68:0;;12609:2:1;24062:68:0;;;12591:21:1;12648:2;12628:18;;;12621:30;12687:34;12667:18;;;12660:62;-1:-1:-1;;;12738:18:1;;;12731:35;12783:19;;24062:68:0;12407:401:1;24062:68:0;-1:-1:-1;;;;;24149:16:0;;24141:64;;;;-1:-1:-1;;;24141:64:0;;7240:2:1;24141:64:0;;;7222:21:1;7279:2;7259:18;;;7252:30;7318:34;7298:18;;;7291:62;-1:-1:-1;;;7369:18:1;;;7362:33;7412:19;;24141:64:0;7038:399:1;24141:64:0;24218:38;24239:4;24245:2;24249:6;24218:20;:38::i;:::-;-1:-1:-1;;;;;24291:15:0;;24269:19;24291:15;;;:9;:15;;;;;;24325:21;;;;24317:72;;;;-1:-1:-1;;;24317:72:0;;9875:2:1;24317:72:0;;;9857:21:1;9914:2;9894:18;;;9887:30;9953:34;9933:18;;;9926:62;-1:-1:-1;;;10004:18:1;;;9997:36;10050:19;;24317:72:0;9673:402:1;24317:72:0;-1:-1:-1;;;;;24425:15:0;;;;;;;:9;:15;;;;;;24443:20;;;24425:38;;24485:13;;;;;;;;:23;;24457:6;;24425:15;24485:23;;24457:6;;24485:23;:::i;:::-;;;;;;;;24541:2;-1:-1:-1;;;;;24526:26:0;24535:4;-1:-1:-1;;;;;24526:26:0;;24545:6;24526:26;;;;4407:25:1;;4395:2;4380:18;;4261:177;24526:26:0;;;;;;;;24565:37;41972:147;40863:527;40952:22;40960:4;40966:7;40952;:22::i;:::-;40947:436;;41140:52;41179:7;-1:-1:-1;;;;;41140:52:0;41189:2;41140:30;:52::i;:::-;41265:49;41304:4;41311:2;41265:30;:49::i;:::-;41045:292;;;;;;;;;:::i;:::-;;;;-1:-1:-1;;41045:292:0;;;;;;;;;;-1:-1:-1;;;40991:380:0;;;;;;;:::i;44521:238::-;44605:22;44613:4;44619:7;44605;:22::i;:::-;44600:152;;44644:12;;;;:6;:12;;;;;;;;-1:-1:-1;;;;;44644:29:0;;;;;;;;;:36;;-1:-1:-1;;44644:36:0;44676:4;44644:36;;;44727:12;15574:10;;15494:98;44727:12;-1:-1:-1;;;;;44700:40:0;44718:7;-1:-1:-1;;;;;44700:40:0;44712:4;44700:40;;;;;;;;;;44521:238;;:::o;63123:162::-;63176:7;63203:74;61846:95;63237:17;64705:12;;;64620:105;63237:17;65060:15;;63474:73;;;;;;5298:25:1;;;5339:18;;;5332:34;;;5382:18;;;5375:34;;;63518:13:0;5425:18:1;;;5418:34;63541:4:0;5468:19:1;;;5461:61;63437:7:0;;5270:19:1;;63474:73:0;;;;;;;;;;;;63464:84;;;;;;63457:91;;63293:263;;;;;;44891:239;44975:22;44983:4;44989:7;44975;:22::i;:::-;44971:152;;;45046:5;45014:12;;;:6;:12;;;;;;;;-1:-1:-1;;;;;45014:29:0;;;;;;;;;;:37;;-1:-1:-1;;45014:37:0;;;45071:40;15574:10;;45014:12;;45071:40;;45046:5;45071:40;44891:239;;:::o;47848:120::-;46860:7;;;;47384:41;;;;-1:-1:-1;;;47384:41:0;;7644:2:1;47384:41:0;;;7626:21:1;7683:2;7663:18;;;7656:30;-1:-1:-1;;;7702:18:1;;;7695:50;7762:18;;47384:41:0;7442:344:1;47384:41:0;47907:7:::1;:15:::0;;-1:-1:-1;;47907:15:0::1;::::0;;47938:22:::1;15574:10:::0;47947:12:::1;47938:22;::::0;-1:-1:-1;;;;;4025:32:1;;;4007:51;;3995:2;3980:18;47938:22:0::1;;;;;;;47848:120::o:0;24897:399::-;-1:-1:-1;;;;;24981:21:0;;24973:65;;;;-1:-1:-1;;;24973:65:0;;14654:2:1;24973:65:0;;;14636:21:1;14693:2;14673:18;;;14666:30;14732:33;14712:18;;;14705:61;14783:18;;24973:65:0;14452:355:1;24973:65:0;25051:49;25080:1;25084:7;25093:6;25051:20;:49::i;:::-;25129:6;25113:12;;:22;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;;;25146:18:0;;;;;;:9;:18;;;;;:28;;25168:6;;25146:18;:28;;25168:6;;25146:28;:::i;:::-;;;;-1:-1:-1;;25190:37:0;;4407:25:1;;;-1:-1:-1;;;;;25190:37:0;;;25207:1;;25190:37;;4395:2:1;4380:18;25190:37:0;;;;;;;43020:218;;:::o;18054:149::-;14393:13;;;;;;;14385:69;;;;-1:-1:-1;;;14385:69:0;;;;;;;:::i;:::-;18157:38:::1;18180:5;18187:7;18157:22;:38::i;39195:66::-:0;14393:13;;;;;;;14385:69;;;;-1:-1:-1;;;14385:69:0;;;;;;;:::i;:::-;39195:66::o;46485:99::-;14393:13;;;;;;;14385:69;;;;-1:-1:-1;;;14385:69:0;;;;;;;:::i;:::-;46549:27:::1;:25;:27::i;68242:172::-:0;14393:13;;;;;;;14385:69;;;;-1:-1:-1;;;14385:69:0;;;;;;;:::i;:::-;68327:34:::1;68351:4;68327:34;;;;;;;;;;;;;-1:-1:-1::0;;;68327:34:0::1;;::::0;:23:::1;:34::i;:::-;68372;68401:4;68372:28;:34::i;47589:118::-:0;46860:7;;;;47114:9;47106:38;;;;-1:-1:-1;;;47106:38:0;;10685:2:1;47106:38:0;;;10667:21:1;10724:2;10704:18;;;10697:30;-1:-1:-1;;;10743:18:1;;;10736:46;10799:18;;47106:38:0;10483:340:1;47106:38:0;47649:7:::1;:14:::0;;-1:-1:-1;;47649:14:0::1;47659:4;47649:14;::::0;;47679:20:::1;47686:12;15574:10:::0;;15494:98;25629:591;-1:-1:-1;;;;;25713:21:0;;25705:67;;;;-1:-1:-1;;;25705:67:0;;12207:2:1;25705:67:0;;;12189:21:1;12246:2;12226:18;;;12219:30;12285:34;12265:18;;;12258:62;-1:-1:-1;;;12336:18:1;;;12329:31;12377:19;;25705:67:0;12005:397:1;25705:67:0;25785:49;25806:7;25823:1;25827:6;25785:20;:49::i;:::-;-1:-1:-1;;;;;25872:18:0;;25847:22;25872:18;;;:9;:18;;;;;;25909:24;;;;25901:71;;;;-1:-1:-1;;;25901:71:0;;7993:2:1;25901:71:0;;;7975:21:1;8032:2;8012:18;;;8005:30;8071:34;8051:18;;;8044:62;-1:-1:-1;;;8122:18:1;;;8115:32;8164:19;;25901:71:0;7791:398:1;25901:71:0;-1:-1:-1;;;;;26008:18:0;;;;;;:9;:18;;;;;26029:23;;;26008:44;;26074:12;:22;;26046:6;;26008:18;26074:22;;26046:6;;26074:22;:::i;:::-;;;;-1:-1:-1;;26114:37:0;;4407:25:1;;;26140:1:0;;-1:-1:-1;;;;;26114:37:0;;;;;4395:2:1;4380:18;26114:37:0;;;;;;;41972:147;;;:::o;69927:218::-;-1:-1:-1;;;;;70059:14:0;;69987:15;70059:14;;;:7;:14;;;;;66392;;66529:1;66511:19;;;;66392:14;70120:17;70004:141;69927:218;;;:::o;64198:178::-;64275:7;64302:66;64335:20;:18;:20::i;:::-;64357:10;60188:57;;-1:-1:-1;;;60188:57:0;;;2931:27:1;2974:11;;;2967:27;;;3010:12;;;3003:28;;;60151:7:0;;3047:12:1;;60188:57:0;;;;;;;;;;;;60178:68;;;;;;60171:75;;60058:196;;;;;58356:279;58484:7;58505:17;58524:18;58546:25;58557:4;58563:1;58566;58569;58546:10;:25::i;:::-;58504:67;;;;58582:18;58594:5;58582:11;:18::i;:::-;-1:-1:-1;58618:9:0;58356:279;-1:-1:-1;;;;;58356:279:0:o;71994:199::-;46860:7;;;;47114:9;47106:38;;;;-1:-1:-1;;;47106:38:0;;10685:2:1;47106:38:0;;;10667:21:1;10724:2;10704:18;;;10697:30;-1:-1:-1;;;10743:18:1;;;10736:46;10799:18;;47106:38:0;10483:340:1;34323:451:0;34398:13;34424:19;34456:10;34460:6;34456:1;:10;:::i;:::-;:14;;34469:1;34456:14;:::i;:::-;34446:25;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;34446:25:0;;34424:47;;-1:-1:-1;;;34482:6:0;34489:1;34482:9;;;;;;;;:::i;:::-;;;;:15;-1:-1:-1;;;;;34482:15:0;;;;;;;;;-1:-1:-1;;;34508:6:0;34515:1;34508:9;;;;;;;;:::i;:::-;;;;:15;-1:-1:-1;;;;;34508:15:0;;;;;;;;-1:-1:-1;34539:9:0;34551:10;34555:6;34551:1;:10;:::i;:::-;:14;;34564:1;34551:14;:::i;:::-;34539:26;;34534:135;34571:1;34567;:5;34534:135;;;-1:-1:-1;;;34619:5:0;34627:3;34619:11;34606:25;;;;;;;:::i;:::-;;;;34594:6;34601:1;34594:9;;;;;;;;:::i;:::-;;;;:37;-1:-1:-1;;;;;34594:37:0;;;;;;;;-1:-1:-1;34656:1:0;34646:11;;;;;34574:3;;;:::i;:::-;;;34534:135;;;-1:-1:-1;34687:10:0;;34679:55;;;;-1:-1:-1;;;34679:55:0;;6879:2:1;34679:55:0;;;6861:21:1;;;6898:18;;;6891:30;6957:34;6937:18;;;6930:62;7009:18;;34679:55:0;6677:356:1;34679:55:0;34759:6;34323:451;-1:-1:-1;;;34323:451:0:o;18211:162::-;14393:13;;;;;;;14385:69;;;;-1:-1:-1;;;14385:69:0;;;;;;;:::i;:::-;18324:13;;::::1;::::0;:5:::1;::::0;:13:::1;::::0;::::1;::::0;::::1;:::i;:::-;-1:-1:-1::0;18348:17:0;;::::1;::::0;:7:::1;::::0;:17:::1;::::0;::::1;::::0;::::1;:::i;46592:97::-:0;14393:13;;;;;;;14385:69;;;;-1:-1:-1;;;14385:69:0;;;;;;;:::i;:::-;46666:7:::1;:15:::0;;-1:-1:-1;;46666:15:0::1;::::0;;46592:97::o;62730:302::-;14393:13;;;;;;;14385:69;;;;-1:-1:-1;;;14385:69:0;;;;;;;:::i;:::-;62864:22;;::::1;::::0;;::::1;::::0;62921:25;;;;;::::1;::::0;62957:12:::1;:25:::0;;;;62993:15:::1;:31:::0;62730:302::o;68422:206::-;14393:13;;;;;;;14385:69;;;;-1:-1:-1;;;14385:69:0;;;;;;;:::i;:::-;-1:-1:-1;68531:95:0::1;68512:16;:114:::0;68422:206::o;56585:1632::-;56716:7;;57650:66;57637:79;;57633:163;;;-1:-1:-1;57749:1:0;;-1:-1:-1;57753:30:0;57733:51;;57633:163;57810:1;:7;;57815:2;57810:7;;:18;;;;;57821:1;:7;;57826:2;57821:7;;57810:18;57806:102;;;-1:-1:-1;57861:1:0;;-1:-1:-1;57865:30:0;57845:51;;57806:102;58022:24;;;58005:14;58022:24;;;;;;;;;5760:25:1;;;5833:4;5821:17;;5801:18;;;5794:45;;;;5855:18;;;5848:34;;;5898:18;;;5891:34;;;58022:24:0;;5732:19:1;;58022:24:0;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;58022:24:0;;-1:-1:-1;;58022:24:0;;;-1:-1:-1;;;;;;;58061:20:0;;58057:103;;58114:1;58118:29;58098:50;;;;;;;58057:103;58180:6;-1:-1:-1;58188:20:0;;-1:-1:-1;56585:1632:0;;;;;;;;:::o;51294:643::-;51372:20;51363:5;:29;;;;;;;;:::i;:::-;;51359:571;;;51294:643;:::o;51359:571::-;51470:29;51461:5;:38;;;;;;;;:::i;:::-;;51457:473;;;51516:34;;-1:-1:-1;;;51516:34:0;;6526:2:1;51516:34:0;;;6508:21:1;6565:2;6545:18;;;6538:30;6604:26;6584:18;;;6577:54;6648:18;;51516:34:0;6324:348:1;51457:473:0;51581:35;51572:5;:44;;;;;;;;:::i;:::-;;51568:362;;;51633:41;;-1:-1:-1;;;51633:41:0;;8396:2:1;51633:41:0;;;8378:21:1;8435:2;8415:18;;;8408:30;8474:33;8454:18;;;8447:61;8525:18;;51633:41:0;8194:355:1;51568:362:0;51705:30;51696:5;:39;;;;;;;;:::i;:::-;;51692:238;;;51752:44;;-1:-1:-1;;;51752:44:0;;10282:2:1;51752:44:0;;;10264:21:1;10321:2;10301:18;;;10294:30;10360:34;10340:18;;;10333:62;-1:-1:-1;;;10411:18:1;;;10404:32;10453:19;;51752:44:0;10080:398:1;51692:238:0;51827:30;51818:5;:39;;;;;;;;:::i;:::-;;51814:116;;;51874:44;;-1:-1:-1;;;51874:44:0;;11445:2:1;51874:44:0;;;11427:21:1;11484:2;11464:18;;;11457:30;11523:34;11503:18;;;11496:62;-1:-1:-1;;;11574:18:1;;;11567:32;11616:19;;51874:44:0;11243:398:1;-1:-1:-1;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;14:173:1;82:20;;-1:-1:-1;;;;;131:31:1;;121:42;;111:70;;177:1;174;167:12;111:70;14:173;;;:::o;192:186::-;251:6;304:2;292:9;283:7;279:23;275:32;272:52;;;320:1;317;310:12;272:52;343:29;362:9;343:29;:::i;383:260::-;451:6;459;512:2;500:9;491:7;487:23;483:32;480:52;;;528:1;525;518:12;480:52;551:29;570:9;551:29;:::i;:::-;541:39;;599:38;633:2;622:9;618:18;599:38;:::i;:::-;589:48;;383:260;;;;;:::o;648:328::-;725:6;733;741;794:2;782:9;773:7;769:23;765:32;762:52;;;810:1;807;800:12;762:52;833:29;852:9;833:29;:::i;:::-;823:39;;881:38;915:2;904:9;900:18;881:38;:::i;:::-;871:48;;966:2;955:9;951:18;938:32;928:42;;648:328;;;;;:::o;981:693::-;1092:6;1100;1108;1116;1124;1132;1140;1193:3;1181:9;1172:7;1168:23;1164:33;1161:53;;;1210:1;1207;1200:12;1161:53;1233:29;1252:9;1233:29;:::i;:::-;1223:39;;1281:38;1315:2;1304:9;1300:18;1281:38;:::i;:::-;1271:48;;1366:2;1355:9;1351:18;1338:32;1328:42;;1417:2;1406:9;1402:18;1389:32;1379:42;;1471:3;1460:9;1456:19;1443:33;1516:4;1509:5;1505:16;1498:5;1495:27;1485:55;;1536:1;1533;1526:12;1485:55;981:693;;;;-1:-1:-1;981:693:1;;;;1559:5;1611:3;1596:19;;1583:33;;-1:-1:-1;1663:3:1;1648:19;;;1635:33;;981:693;-1:-1:-1;;981:693:1:o;1679:254::-;1747:6;1755;1808:2;1796:9;1787:7;1783:23;1779:32;1776:52;;;1824:1;1821;1814:12;1776:52;1847:29;1866:9;1847:29;:::i;:::-;1837:39;1923:2;1908:18;;;;1895:32;;-1:-1:-1;;;1679:254:1:o;1938:180::-;1997:6;2050:2;2038:9;2029:7;2025:23;2021:32;2018:52;;;2066:1;2063;2056:12;2018:52;-1:-1:-1;2089:23:1;;1938:180;-1:-1:-1;1938:180:1:o;2123:254::-;2191:6;2199;2252:2;2240:9;2231:7;2227:23;2223:32;2220:52;;;2268:1;2265;2258:12;2220:52;2304:9;2291:23;2281:33;;2333:38;2367:2;2356:9;2352:18;2333:38;:::i;2382:286::-;2440:6;2493:2;2481:9;2472:7;2468:23;2464:32;2461:52;;;2509:1;2506;2499:12;2461:52;2535:23;;-1:-1:-1;;;;;;2587:32:1;;2577:43;;2567:71;;2634:1;2631;2624:12;3070:786;3481:25;3476:3;3469:38;3451:3;3536:6;3530:13;3552:62;3607:6;3602:2;3597:3;3593:12;3586:4;3578:6;3574:17;3552:62;:::i;:::-;-1:-1:-1;;;3673:2:1;3633:16;;;3665:11;;;3658:40;3723:13;;3745:63;3723:13;3794:2;3786:11;;3779:4;3767:17;;3745:63;:::i;:::-;3828:17;3847:2;3824:26;;3070:786;-1:-1:-1;;;;3070:786:1:o;5936:383::-;6085:2;6074:9;6067:21;6048:4;6117:6;6111:13;6160:6;6155:2;6144:9;6140:18;6133:34;6176:66;6235:6;6230:2;6219:9;6215:18;6210:2;6202:6;6198:15;6176:66;:::i;:::-;6303:2;6282:15;-1:-1:-1;;6278:29:1;6263:45;;;;6310:2;6259:54;;5936:383;-1:-1:-1;;5936:383:1:o;13218:407::-;13420:2;13402:21;;;13459:2;13439:18;;;13432:30;13498:34;13493:2;13478:18;;13471:62;-1:-1:-1;;;13564:2:1;13549:18;;13542:41;13615:3;13600:19;;13218:407::o;15183:128::-;15223:3;15254:1;15250:6;15247:1;15244:13;15241:39;;;15260:18;;:::i;:::-;-1:-1:-1;15296:9:1;;15183:128::o;15316:168::-;15356:7;15422:1;15418;15414:6;15410:14;15407:1;15404:21;15399:1;15392:9;15385:17;15381:45;15378:71;;;15429:18;;:::i;:::-;-1:-1:-1;15469:9:1;;15316:168::o;15489:125::-;15529:4;15557:1;15554;15551:8;15548:34;;;15562:18;;:::i;:::-;-1:-1:-1;15599:9:1;;15489:125::o;15619:258::-;15691:1;15701:113;15715:6;15712:1;15709:13;15701:113;;;15791:11;;;15785:18;15772:11;;;15765:39;15737:2;15730:10;15701:113;;;15832:6;15829:1;15826:13;15823:48;;;-1:-1:-1;;15867:1:1;15849:16;;15842:27;15619:258::o;15882:136::-;15921:3;15949:5;15939:39;;15958:18;;:::i;:::-;-1:-1:-1;;;15994:18:1;;15882:136::o;16023:380::-;16102:1;16098:12;;;;16145;;;16166:61;;16220:4;16212:6;16208:17;16198:27;;16166:61;16273:2;16265:6;16262:14;16242:18;16239:38;16236:161;;;16319:10;16314:3;16310:20;16307:1;16300:31;16354:4;16351:1;16344:15;16382:4;16379:1;16372:15;16408:127;16469:10;16464:3;16460:20;16457:1;16450:31;16500:4;16497:1;16490:15;16524:4;16521:1;16514:15;16540:127;16601:10;16596:3;16592:20;16589:1;16582:31;16632:4;16629:1;16622:15;16656:4;16653:1;16646:15;16672:127;16733:10;16728:3;16724:20;16721:1;16714:31;16764:4;16761:1;16754:15;16788:4;16785:1;16778:15;16804:127;16865:10;16860:3;16856:20;16853:1;16846:31;16896:4;16893:1;16886:15;16920:4;16917:1;16910:15
Swarm Source
ipfs://151c9cb2badae00d19153f766d0e23a5e3c73259f7180f2d47c0544ff29f8b16
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.