Contract Overview
Contract Name:
UPMintPublic
Compiler Version
v0.8.7+commit.e28d00a7
// File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/access/IAccessControl.sol // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev 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); } // File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: contracts/Helpers/Safe.sol pragma solidity ^0.8.4; abstract contract Safe { using SafeERC20 for IERC20; address target; constructor(address _target) { target = _target; } function _withdrawFunds() internal returns (bool) { (bool sent, ) = address(target).call{value: address(this).balance}(""); require(sent, "Safe: Failed to send Ether"); return sent; } function _withdrawFundsERC20(address tokenAddress) internal returns (bool) { IERC20 token = IERC20(tokenAddress); token.safeTransfer(target, token.balanceOf(address(this))); return true; } } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/security/ReentrancyGuard.sol // 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/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/AccessControl.sol // OpenZeppelin Contracts (last updated v4.6.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 AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol // OpenZeppelin Contracts (last updated v4.6.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 ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(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 = allowance(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 Updates `owner` s allowance for `spender` based on spent `amount`. * * 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 {} } // File: contracts/UP.sol pragma solidity ^0.8.4; contract UP is ERC20, AccessControl { bytes32 public constant MINT_ROLE = keccak256("MINT_ROLE"); bytes32 public constant LEGACY_MINT_ROLE = keccak256("LEGACY_MINT_ROLE"); address public UP_CONTROLLER = address(0); event SetUPController(address _setter, address _newController); modifier onlyMint() { require(hasRole(MINT_ROLE, msg.sender), "UP: ONLY_MINT"); _; } modifier onlyAdmin() { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "UP: ONLY_ADMIN"); _; } constructor() ERC20("UPong", "UPong") { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } /// @notice UPv1 legacy receive() external payable {} function burn(uint256 amount) public { _burn(_msgSender(), amount); } function burnFrom(address account, uint256 amount) public { _spendAllowance(account, _msgSender(), amount); _burn(account, amount); } /// @notice Retrocompatible function with v1 function justBurn(uint256 amount) external { burn(amount); } /// @notice Mints token and have logic for supporting legacy mint logic function mint(address to, uint256 amount) public payable onlyMint returns (bool) { /// LEGACY_MINT_ROLE retrocompatible with UPv1 if (hasRole(LEGACY_MINT_ROLE, msg.sender) && UP_CONTROLLER != address(0)) { (bool success, ) = UP_CONTROLLER.call{value: msg.value}( abi.encodeWithSignature(("mintUP(address)"), to) ); require(success, "UP: LEGACY_MINT_FAILED"); } else { _mint(to, amount); } /// Legacy UPv1 return return true; } /// @notice Sets a controller address that will receive the funds from LEGACY_MINT_ROLE function setController(address newController) public onlyAdmin { UP_CONTROLLER = newController; emit SetUPController(msg.sender, newController); } function withdrawFunds() public { require(UP_CONTROLLER != address(0)); (bool success, ) = UP_CONTROLLER.call{value: address(this).balance}(""); require(success); } } // File: @openzeppelin/contracts/security/Pausable.sol // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // File: contracts/UPController.sol pragma solidity ^0.8.4; /// @title UP Controller /// @author dxffffff & A Fistful of Stray Cat Hair /// @notice This controller back up the UP token and has the logic for borrowing tokens. contract UPController is AccessControl, Safe, Pausable { bytes32 public constant REBALANCER_ROLE = keccak256("REBALANCER_ROLE"); bytes32 public constant REDEEMER_ROLE = keccak256("REDEEMER_ROLE"); address payable public UP_TOKEN = payable(address(0)); uint256 public nativeBorrowed = 0; uint256 public upBorrowed = 0; event SyntheticMint(address _from, uint256 _amount, uint256 _newUpBorrowed); event BorrowNative(address _from, uint256 _amount, uint256 _newNativeBorrowed); event Repay(uint256 _nativeAmount, uint256 _upAmount); event Redeem(uint256 _upAmount, uint256 _redeemAmount); modifier onlyRebalancer() { require(hasRole(REBALANCER_ROLE, msg.sender), "UPController: ONLY_REBALANCER"); _; } modifier onlyAdmin() { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "UPController: ONLY_ADMIN"); _; } modifier onlyRedeemer() { require(hasRole(REDEEMER_ROLE, msg.sender), "UPController: ONLY_REDEEMER"); _; } constructor(address _UP, address _fundsTarget) Safe(_fundsTarget) { require(_UP != address(0), "UPController: Invalid UP address"); UP_TOKEN = payable(_UP); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } receive() external payable {} /// @notice Returns price of UP token based on its reserves function getVirtualPrice() public view returns (uint256) { if (getNativeBalance() == 0) return 0; return ((getNativeBalance() * 1e18) / actualTotalSupply()); } /// @notice Returns price of UP token based on its reserves minus amount sent to the contract function getVirtualPrice(uint256 sentValue) public view returns (uint256) { if (getNativeBalance() == 0) return 0; uint256 nativeBalance = getNativeBalance() - sentValue; return ((nativeBalance * 1e18) / actualTotalSupply()); } /// @notice Computed the actual native balances of the contract function getNativeBalance() public view returns (uint256) { return address(this).balance + nativeBorrowed; } /// @notice Computed total supply of UP token function actualTotalSupply() public view returns (uint256) { return UP(UP_TOKEN).totalSupply() - upBorrowed; } /// @notice Borrows native token from the back up reserves function borrowNative(uint256 _borrowAmount, address _to) public onlyRebalancer whenNotPaused { require(address(this).balance >= _borrowAmount, "UPController: NOT_ENOUGH_BALANCE"); (bool success, ) = _to.call{value: _borrowAmount}(""); nativeBorrowed += _borrowAmount; require(success, "UPController: BORROW_NATIVE_FAILED"); emit BorrowNative(_to, _borrowAmount, nativeBorrowed); } /// @notice Borrows UP token minting it function borrowUP(uint256 _borrowAmount, address _to) public onlyRebalancer whenNotPaused { upBorrowed += _borrowAmount; UP(UP_TOKEN).mint(_to, _borrowAmount); emit SyntheticMint(msg.sender, _borrowAmount, upBorrowed); } function mintSyntheticUP(uint256 _mintAmount, address _to) public onlyRebalancer whenNotPaused { borrowUP(_mintAmount, _to); } /// @notice Mints UP based on virtual price - UPv1 logic function mintUP(address to) external payable whenNotPaused { require(msg.sender == UP_TOKEN, "UPController: NON_UP_CONTRACT"); uint256 mintAmount = (msg.value * 1e18) / getVirtualPrice(msg.value); UP(UP_TOKEN).mint(to, mintAmount); } /// @notice Allows to return back borrowed amounts to the controller function repay(uint256 upAmount) public payable onlyRebalancer whenNotPaused { UP(UP_TOKEN).burnFrom(msg.sender, upAmount); upBorrowed -= upAmount <= upBorrowed ? upAmount : upBorrowed; nativeBorrowed -= msg.value <= nativeBorrowed ? msg.value : nativeBorrowed; emit Repay(msg.value, upAmount); } /// @notice Swaps UP token by native token function redeem(uint256 upAmount) public onlyRedeemer whenNotPaused { require(upAmount > 0, "UPController: AMOUNT_EQ_0"); uint256 redeemAmount = (getVirtualPrice() * upAmount) / 1e18; UP(UP_TOKEN).burnFrom(msg.sender, upAmount); (bool success, ) = msg.sender.call{value: redeemAmount}(""); require(success, "UPController: REDEEM_FAILED"); emit Redeem(upAmount, redeemAmount); } function pause() public onlyAdmin { _pause(); } function unpause() public onlyAdmin { _unpause(); } function withdrawFunds() public onlyAdmin returns (bool) { return _withdrawFunds(); } function withdrawFundsERC20(address tokenAddress) public onlyAdmin returns (bool) { return _withdrawFundsERC20(tokenAddress); } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: contracts/UPMintPublic.sol pragma solidity ^0.8.4; /// @title UP Public Mint /// @author dxffffff & A Fistful of Stray Cat Hair /// @notice This contract is for the public minting of UP token, allowing users to deposit native tokens and receive UP tokens. contract UPMintPublic is Ownable, Pausable, ReentrancyGuard, Safe { uint256 public mintRate; // with 2 decimals - 150 = 1.50% address payable public UP_TOKEN = payable(address(0)); address payable public UP_CONTROLLER = payable(address(0)); event NewPublicMintRate(uint256 _newMintRate); event PublicMint( address indexed _from, address _to, uint256 _amount, uint256 _price, uint256 _value ); event UpdateController(address _upController); constructor( address _UP, address _UPController, uint256 _mintRate, address _targetFunds ) Safe(_targetFunds) { require(_UP != address(0), "UPMintPublic: Invalid UP address"); UP_TOKEN = payable(_UP); UP_CONTROLLER = payable(_UPController); setMintRate(_mintRate); } /// @notice Payable function that mints UP at the mint rate, deposits the native tokens to the UP Controller, Sends UP to the Msg.sender /// @param to Destination address for minted tokens function mintUP(address to) public payable virtual whenNotPaused nonReentrant { require(msg.value > 0, "UPMintPublic: INVALID_PAYABLE_AMOUNT"); uint256 currentPrice = UPController(UP_CONTROLLER).getVirtualPrice(); require(currentPrice > 0, "UPMintPublic: UP_PRICE_0"); uint256 discountedAmount = msg.value - ((msg.value * (mintRate * 100)) / 1000000); uint256 mintAmount = (discountedAmount * 1e18) / currentPrice; UP(UP_TOKEN).mint(to, mintAmount); (bool successTransfer, ) = address(UP_CONTROLLER).call{value: msg.value}(""); require(successTransfer, "UPMintPublic: FAIL_SENDING_NATIVE"); emit PublicMint(msg.sender, to, mintAmount, currentPrice, msg.value); } /// @notice Permissioned function that sets the public rint of UP. /// @param _mintRate - mint rate in percent terms, _mintRate = 5 = 5%. function setMintRate(uint256 _mintRate) public onlyOwner { require(_mintRate <= 10000, "UPMintPublic: MINT_RATE_GT_10000"); require(_mintRate > 0, "UPMintPublic: MINT_RATE_EQ_0"); mintRate = _mintRate; emit NewPublicMintRate(_mintRate); } /// @notice Permissioned function to update the address of the UP Controller /// @param _upController - the address of the new UP Controller function updateController(address _upController) public onlyOwner { require(_upController != address(0), "UPMintPublic: INVALID_ADDRESS"); UP_CONTROLLER = payable(_upController); emit UpdateController(_upController); } /// @notice Permissioned function to pause public minting function pause() public onlyOwner { _pause(); } /// @notice Permissioned function to unpause public minting function unpause() public onlyOwner { _unpause(); } /// @notice Permissioned function to withdraw any native coins accidentally deposited to the Public Mint contract. function withdrawFunds() public onlyOwner returns (bool) { return _withdrawFunds(); } /// @notice Permissioned function to withdraw any tokens accidentally deposited to the Public Mint contract. function withdrawFundsERC20(address tokenAddress) public onlyOwner returns (bool) { return _withdrawFundsERC20(tokenAddress); } }
[{"inputs":[{"internalType":"address","name":"_UP","type":"address"},{"internalType":"address","name":"_UPController","type":"address"},{"internalType":"uint256","name":"_mintRate","type":"uint256"},{"internalType":"address","name":"_targetFunds","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_newMintRate","type":"uint256"}],"name":"NewPublicMintRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"PublicMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_upController","type":"address"}],"name":"UpdateController","type":"event"},{"inputs":[],"name":"UP_CONTROLLER","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UP_TOKEN","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"mintUP","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mintRate","type":"uint256"}],"name":"setMintRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_upController","type":"address"}],"name":"updateController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawFunds","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"withdrawFundsERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6080604052600436106100dd5760003560e01c80638456cb591161007f578063aba2f2d411610059578063aba2f2d414610264578063ca0dcf1614610280578063dbe2193f146102ab578063f2fde38b146102d4576100dd565b80638456cb59146101e55780638da5cb5b146101fc578063a4125eb714610227576100dd565b80635c975abb116100bb5780635c975abb1461014d5780635df3937314610178578063715018a6146101a357806378093117146101ba576100dd565b806306cb5b66146100e257806324600fc31461010b5780633f4ba83a14610136575b600080fd5b3480156100ee57600080fd5b50610109600480360381019061010491906114fb565b6102fd565b005b34801561011757600080fd5b50610120610464565b60405161012d9190611955565b60405180910390f35b34801561014257600080fd5b5061014b6104ef565b005b34801561015957600080fd5b50610162610575565b60405161016f9190611955565b60405180910390f35b34801561018457600080fd5b5061018d61058b565b60405161019a91906118cc565b60405180910390f35b3480156101af57600080fd5b506101b86105b1565b005b3480156101c657600080fd5b506101cf610639565b6040516101dc91906118cc565b60405180910390f35b3480156101f157600080fd5b506101fa61065f565b005b34801561020857600080fd5b506102116106e5565b60405161021e91906118b1565b60405180910390f35b34801561023357600080fd5b5061024e600480360381019061024991906114fb565b61070e565b60405161025b9190611955565b60405180910390f35b61027e600480360381019061027991906114fb565b61079c565b005b34801561028c57600080fd5b50610295610b96565b6040516102a29190611b72565b60405180910390f35b3480156102b757600080fd5b506102d260048036038101906102cd9190611555565b610b9c565b005b3480156102e057600080fd5b506102fb60048036038101906102f691906114fb565b610ce1565b005b610305610dd9565b73ffffffffffffffffffffffffffffffffffffffff166103236106e5565b73ffffffffffffffffffffffffffffffffffffffff1614610379576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037090611ab2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156103e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103e0906119b2565b60405180910390fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507ffce593255b7647c9b730cf207aed89b0761a9c7ff374009a869068dffa08fb2a8160405161045991906118b1565b60405180910390a150565b600061046e610dd9565b73ffffffffffffffffffffffffffffffffffffffff1661048c6106e5565b73ffffffffffffffffffffffffffffffffffffffff16146104e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d990611ab2565b60405180910390fd5b6104ea610de1565b905090565b6104f7610dd9565b73ffffffffffffffffffffffffffffffffffffffff166105156106e5565b73ffffffffffffffffffffffffffffffffffffffff161461056b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056290611ab2565b60405180910390fd5b610573610eb7565b565b60008060149054906101000a900460ff16905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6105b9610dd9565b73ffffffffffffffffffffffffffffffffffffffff166105d76106e5565b73ffffffffffffffffffffffffffffffffffffffff161461062d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161062490611ab2565b60405180910390fd5b6106376000610f58565b565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610667610dd9565b73ffffffffffffffffffffffffffffffffffffffff166106856106e5565b73ffffffffffffffffffffffffffffffffffffffff16146106db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d290611ab2565b60405180910390fd5b6106e361101c565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000610718610dd9565b73ffffffffffffffffffffffffffffffffffffffff166107366106e5565b73ffffffffffffffffffffffffffffffffffffffff161461078c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078390611ab2565b60405180910390fd5b610795826110bf565b9050919050565b6107a4610575565b156107e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107db90611a52565b60405180910390fd5b6002600154141561082a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082190611b32565b60405180910390fd5b600260018190555060003411610875576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086c90611a72565b60405180910390fd5b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e25aa5fa6040518163ffffffff1660e01b815260040160206040518083038186803b1580156108df57600080fd5b505afa1580156108f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109179190611582565b90506000811161095c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610953906119f2565b60405180910390fd5b6000620f424060646003546109719190611bf0565b3461097c9190611bf0565b6109869190611bbf565b346109919190611c4a565b9050600082670de0b6b3a7640000836109aa9190611bf0565b6109b49190611bbf565b9050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1985836040518363ffffffff1660e01b8152600401610a139291906118e7565b602060405180830381600087803b158015610a2d57600080fd5b505af1158015610a41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a659190611528565b506000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1634604051610aae9061189c565b60006040518083038185875af1925050503d8060008114610aeb576040519150601f19603f3d011682016040523d82523d6000602084013e610af0565b606091505b5050905080610b34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2b90611b52565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167f68868a0c8c24438491cf13ccb4fb0e15c55dc72c300910366fbdcdd6c3e485fa86848734604051610b809493929190611910565b60405180910390a2505050506001808190555050565b60035481565b610ba4610dd9565b73ffffffffffffffffffffffffffffffffffffffff16610bc26106e5565b73ffffffffffffffffffffffffffffffffffffffff1614610c18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0f90611ab2565b60405180910390fd5b612710811115610c5d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5490611ad2565b60405180910390fd5b60008111610ca0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9790611a92565b60405180910390fd5b806003819055507f483c138ece842cd60a27e14c92b7d032d95bf28aec10e1170745595528fe9daf81604051610cd69190611b72565b60405180910390a150565b610ce9610dd9565b73ffffffffffffffffffffffffffffffffffffffff16610d076106e5565b73ffffffffffffffffffffffffffffffffffffffff1614610d5d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5490611ab2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610dcd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc4906119d2565b60405180910390fd5b610dd681610f58565b50565b600033905090565b600080600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1647604051610e2a9061189c565b60006040518083038185875af1925050503d8060008114610e67576040519150601f19603f3d011682016040523d82523d6000602084013e610e6c565b606091505b5050905080610eb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea790611a32565b60405180910390fd5b8091505090565b610ebf610575565b610efe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef590611992565b60405180910390fd5b60008060146101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa610f41610dd9565b604051610f4e91906118b1565b60405180910390a1565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611024610575565b15611064576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105b90611a52565b60405180910390fd5b6001600060146101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586110a8610dd9565b6040516110b591906118b1565b60405180910390a1565b60008082905061119a600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161112491906118b1565b60206040518083038186803b15801561113c57600080fd5b505afa158015611150573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111749190611582565b8373ffffffffffffffffffffffffffffffffffffffff166111a49092919063ffffffff16565b6001915050919050565b6112258363a9059cbb60e01b84846040516024016111c39291906118e7565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061122a565b505050565b600061128c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166112f19092919063ffffffff16565b90506000815111156112ec57808060200190518101906112ac9190611528565b6112eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112e290611b12565b60405180910390fd5b5b505050565b60606113008484600085611309565b90509392505050565b60608247101561134e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134590611a12565b60405180910390fd5b6113578561141d565b611396576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138d90611af2565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516113bf9190611885565b60006040518083038185875af1925050503d80600081146113fc576040519150601f19603f3d011682016040523d82523d6000602084013e611401565b606091505b5091509150611411828286611440565b92505050949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60608315611450578290506114a0565b6000835111156114635782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114979190611970565b60405180910390fd5b9392505050565b6000813590506114b6816120a7565b92915050565b6000815190506114cb816120be565b92915050565b6000813590506114e0816120d5565b92915050565b6000815190506114f5816120d5565b92915050565b60006020828403121561151157611510611d69565b5b600061151f848285016114a7565b91505092915050565b60006020828403121561153e5761153d611d69565b5b600061154c848285016114bc565b91505092915050565b60006020828403121561156b5761156a611d69565b5b6000611579848285016114d1565b91505092915050565b60006020828403121561159857611597611d69565b5b60006115a6848285016114e6565b91505092915050565b6115b881611c90565b82525050565b6115c781611c7e565b82525050565b6115d681611ca2565b82525050565b60006115e782611b8d565b6115f18185611ba3565b9350611601818560208601611cd8565b80840191505092915050565b600061161882611b98565b6116228185611bae565b9350611632818560208601611cd8565b61163b81611d6e565b840191505092915050565b6000611653601483611bae565b915061165e82611d7f565b602082019050919050565b6000611676601d83611bae565b915061168182611da8565b602082019050919050565b6000611699602683611bae565b91506116a482611dd1565b604082019050919050565b60006116bc601883611bae565b91506116c782611e20565b602082019050919050565b60006116df602683611bae565b91506116ea82611e49565b604082019050919050565b6000611702601a83611bae565b915061170d82611e98565b602082019050919050565b6000611725601083611bae565b915061173082611ec1565b602082019050919050565b6000611748602483611bae565b915061175382611eea565b604082019050919050565b600061176b601c83611bae565b915061177682611f39565b602082019050919050565b600061178e602083611bae565b915061179982611f62565b602082019050919050565b60006117b1602083611bae565b91506117bc82611f8b565b602082019050919050565b60006117d4600083611ba3565b91506117df82611fb4565b600082019050919050565b60006117f7601d83611bae565b915061180282611fb7565b602082019050919050565b600061181a602a83611bae565b915061182582611fe0565b604082019050919050565b600061183d601f83611bae565b91506118488261202f565b602082019050919050565b6000611860602183611bae565b915061186b82612058565b604082019050919050565b61187f81611cce565b82525050565b600061189182846115dc565b915081905092915050565b60006118a7826117c7565b9150819050919050565b60006020820190506118c660008301846115be565b92915050565b60006020820190506118e160008301846115af565b92915050565b60006040820190506118fc60008301856115be565b6119096020830184611876565b9392505050565b600060808201905061192560008301876115be565b6119326020830186611876565b61193f6040830185611876565b61194c6060830184611876565b95945050505050565b600060208201905061196a60008301846115cd565b92915050565b6000602082019050818103600083015261198a818461160d565b905092915050565b600060208201905081810360008301526119ab81611646565b9050919050565b600060208201905081810360008301526119cb81611669565b9050919050565b600060208201905081810360008301526119eb8161168c565b9050919050565b60006020820190508181036000830152611a0b816116af565b9050919050565b60006020820190508181036000830152611a2b816116d2565b9050919050565b60006020820190508181036000830152611a4b816116f5565b9050919050565b60006020820190508181036000830152611a6b81611718565b9050919050565b60006020820190508181036000830152611a8b8161173b565b9050919050565b60006020820190508181036000830152611aab8161175e565b9050919050565b60006020820190508181036000830152611acb81611781565b9050919050565b60006020820190508181036000830152611aeb816117a4565b9050919050565b60006020820190508181036000830152611b0b816117ea565b9050919050565b60006020820190508181036000830152611b2b8161180d565b9050919050565b60006020820190508181036000830152611b4b81611830565b9050919050565b60006020820190508181036000830152611b6b81611853565b9050919050565b6000602082019050611b876000830184611876565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000611bca82611cce565b9150611bd583611cce565b925082611be557611be4611d3a565b5b828204905092915050565b6000611bfb82611cce565b9150611c0683611cce565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611c3f57611c3e611d0b565b5b828202905092915050565b6000611c5582611cce565b9150611c6083611cce565b925082821015611c7357611c72611d0b565b5b828203905092915050565b6000611c8982611cae565b9050919050565b6000611c9b82611cae565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015611cf6578082015181840152602081019050611cdb565b83811115611d05576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b7f55504d696e745075626c69633a20494e56414c49445f41444452455353000000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f55504d696e745075626c69633a2055505f50524943455f300000000000000000600082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f536166653a204661696c656420746f2073656e64204574686572000000000000600082015250565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b7f55504d696e745075626c69633a20494e56414c49445f50415941424c455f414d60008201527f4f554e5400000000000000000000000000000000000000000000000000000000602082015250565b7f55504d696e745075626c69633a204d494e545f524154455f45515f3000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f55504d696e745075626c69633a204d494e545f524154455f47545f3130303030600082015250565b50565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f55504d696e745075626c69633a204641494c5f53454e44494e475f4e4154495660008201527f4500000000000000000000000000000000000000000000000000000000000000602082015250565b6120b081611c7e565b81146120bb57600080fd5b50565b6120c781611ca2565b81146120d257600080fd5b50565b6120de81611cce565b81146120e957600080fd5b5056fea264697066735822122069b2524a39709f8845e3094f42c605c69a3d07ad5f82146e564cf019c3beddc464736f6c63430008070033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for
interesting conversations.