Contract Name:
ContractsRegister
Contract Source Code:
// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
import { IContractsRegister } from "../interfaces/IContractsRegister.sol";
import { Errors } from "../libraries/Errors.sol";
import { ACLTrait } from "./ACLTrait.sol";
/// @title Pool & Credit Manager registry
/// @notice Stores addresses of Pools and Credit Managers
contract ContractsRegister is IContractsRegister, ACLTrait {
/// @dev List of all registered pools
address[] public override pools;
/// @dev Mapping storing whether an address is a pool
mapping(address => bool) public override isPool;
/// @dev List of all registered Credit Managers
address[] public override creditManagers;
/// @dev Mapping storing whether an address is a Credit Manager
mapping(address => bool) public override isCreditManager;
/// @dev Contract version
uint256 public constant version = 1;
constructor(address addressProvider) ACLTrait(addressProvider) {}
/// @dev Adds a pool to the list
/// @param newPoolAddress Address of the new pool
function addPool(address newPoolAddress)
external
configuratorOnly // T:[CR-1]
{
require(
newPoolAddress != address(0),
Errors.ZERO_ADDRESS_IS_NOT_ALLOWED
);
require(!isPool[newPoolAddress], Errors.CR_POOL_ALREADY_ADDED); // T:[CR-2]
pools.push(newPoolAddress); // T:[CR-3]
isPool[newPoolAddress] = true; // T:[CR-3]
emit NewPoolAdded(newPoolAddress); // T:[CR-4]
}
/// @dev Returns the array of registered pool addresses
function getPools() external view override returns (address[] memory) {
return pools;
}
/// @return Returns the number of registered pools
function getPoolsCount() external view override returns (uint256) {
return pools.length; // T:[CR-3]
}
/// @dev Adds credit accounts manager address to the registry
/// @param newCreditManager Address of the new Credit Manager
function addCreditManager(address newCreditManager)
external
configuratorOnly // T:[CR-1]
{
require(
newCreditManager != address(0),
Errors.ZERO_ADDRESS_IS_NOT_ALLOWED
);
require(
!isCreditManager[newCreditManager],
Errors.CR_CREDIT_MANAGER_ALREADY_ADDED
); // T:[CR-5]
creditManagers.push(newCreditManager); // T:[CR-6]
isCreditManager[newCreditManager] = true; // T:[CR-6]
emit NewCreditManagerAdded(newCreditManager); // T:[CR-7]
}
/// @dev Returns the array of registered credit manager addresses
function getCreditManagers()
external
view
override
returns (address[] memory)
{
return creditManagers;
}
/// @return Returns the number of registered credit managers
function getCreditManagersCount() external view override returns (uint256) {
return creditManagers.length; // T:[CR-6]
}
}
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
import { IVersion } from "./IVersion.sol";
interface IContractsRegisterEvents {
/// @dev Emits when a new pool is registered in the system
event NewPoolAdded(address indexed pool);
/// @dev Emits when a new Credit Manager is registered in the system
event NewCreditManagerAdded(address indexed creditManager);
}
interface IContractsRegister is IContractsRegisterEvents, IVersion {
//
// POOLS
//
/// @dev Returns the array of registered pools
function getPools() external view returns (address[] memory);
/// @dev Returns a pool address from the list under the passed index
/// @param i Index of the pool to retrieve
function pools(uint256 i) external view returns (address);
/// @return Returns the number of registered pools
function getPoolsCount() external view returns (uint256);
/// @dev Returns true if the passed address is a pool
function isPool(address) external view returns (bool);
//
// CREDIT MANAGERS
//
/// @dev Returns the array of registered Credit Managers
function getCreditManagers() external view returns (address[] memory);
/// @dev Returns a Credit Manager's address from the list under the passed index
/// @param i Index of the Credit Manager to retrieve
function creditManagers(uint256 i) external view returns (address);
/// @return Returns the number of registered Credit Managers
function getCreditManagersCount() external view returns (uint256);
/// @dev Returns true if the passed address is a Credit Manager
function isCreditManager(address) external view returns (bool);
}
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
/// @title Errors library
library Errors {
//
// COMMON
//
string public constant ZERO_ADDRESS_IS_NOT_ALLOWED = "Z0";
string public constant NOT_IMPLEMENTED = "NI";
string public constant INCORRECT_PATH_LENGTH = "PL";
string public constant INCORRECT_ARRAY_LENGTH = "CR";
string public constant REGISTERED_CREDIT_ACCOUNT_MANAGERS_ONLY = "CP";
string public constant REGISTERED_POOLS_ONLY = "RP";
string public constant INCORRECT_PARAMETER = "IP";
//
// MATH
//
string public constant MATH_MULTIPLICATION_OVERFLOW = "M1";
string public constant MATH_ADDITION_OVERFLOW = "M2";
string public constant MATH_DIVISION_BY_ZERO = "M3";
//
// POOL
//
string public constant POOL_CONNECTED_CREDIT_MANAGERS_ONLY = "PS0";
string public constant POOL_INCOMPATIBLE_CREDIT_ACCOUNT_MANAGER = "PS1";
string public constant POOL_MORE_THAN_EXPECTED_LIQUIDITY_LIMIT = "PS2";
string public constant POOL_INCORRECT_WITHDRAW_FEE = "PS3";
string public constant POOL_CANT_ADD_CREDIT_MANAGER_TWICE = "PS4";
//
// ACCOUNT FACTORY
//
string public constant AF_CANT_CLOSE_CREDIT_ACCOUNT_IN_THE_SAME_BLOCK =
"AF1";
string public constant AF_MINING_IS_FINISHED = "AF2";
string public constant AF_CREDIT_ACCOUNT_NOT_IN_STOCK = "AF3";
string public constant AF_EXTERNAL_ACCOUNTS_ARE_FORBIDDEN = "AF4";
//
// ADDRESS PROVIDER
//
string public constant AS_ADDRESS_NOT_FOUND = "AP1";
//
// CONTRACTS REGISTER
//
string public constant CR_POOL_ALREADY_ADDED = "CR1";
string public constant CR_CREDIT_MANAGER_ALREADY_ADDED = "CR2";
//
// CREDIT ACCOUNT
//
string public constant CA_CONNECTED_CREDIT_MANAGER_ONLY = "CA1";
string public constant CA_FACTORY_ONLY = "CA2";
//
// ACL
//
string public constant ACL_CALLER_NOT_PAUSABLE_ADMIN = "ACL1";
string public constant ACL_CALLER_NOT_CONFIGURATOR = "ACL2";
//
// WETH GATEWAY
//
string public constant WG_DESTINATION_IS_NOT_WETH_COMPATIBLE = "WG1";
string public constant WG_RECEIVE_IS_NOT_ALLOWED = "WG2";
string public constant WG_NOT_ENOUGH_FUNDS = "WG3";
//
// TOKEN DISTRIBUTOR
//
string public constant TD_WALLET_IS_ALREADY_CONNECTED_TO_VC = "TD1";
string public constant TD_INCORRECT_WEIGHTS = "TD2";
string public constant TD_NON_ZERO_BALANCE_AFTER_DISTRIBUTION = "TD3";
string public constant TD_CONTRIBUTOR_IS_NOT_REGISTERED = "TD4";
}
// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
import { Pausable } from "@openzeppelin/contracts/security/Pausable.sol";
import { AddressProvider } from "./AddressProvider.sol";
import { IACL } from "../interfaces/IACL.sol";
import { ZeroAddressException, CallerNotConfiguratorException, CallerNotPausableAdminException, CallerNotUnPausableAdminException } from "../interfaces/IErrors.sol";
/// @title ACL Trait
/// @notice Utility class for ACL consumers
abstract contract ACLTrait is Pausable {
// ACL contract to check rights
IACL public immutable _acl;
/// @dev constructor
/// @param addressProvider Address of address repository
constructor(address addressProvider) {
if (addressProvider == address(0)) revert ZeroAddressException(); // F:[AA-2]
_acl = IACL(AddressProvider(addressProvider).getACL());
}
/// @dev Reverts if msg.sender is not configurator
modifier configuratorOnly() {
if (!_acl.isConfigurator(msg.sender))
revert CallerNotConfiguratorException();
_;
}
///@dev Pause contract
function pause() external {
if (!_acl.isPausableAdmin(msg.sender))
revert CallerNotPausableAdminException();
_pause();
}
/// @dev Unpause contract
function unpause() external {
if (!_acl.isUnpausableAdmin(msg.sender))
revert CallerNotUnPausableAdminException();
_unpause();
}
}
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
/// @title Version interface
/// @notice Defines contract version
interface IVersion {
/// @notice Contract version
function version() external view returns (uint256);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
import { IAddressProvider } from "../interfaces/IAddressProvider.sol";
import { Claimable } from "./access/Claimable.sol";
import { Errors } from "../libraries/Errors.sol";
// Repositories & services
bytes32 constant CONTRACTS_REGISTER = "CONTRACTS_REGISTER";
bytes32 constant ACL = "ACL";
bytes32 constant PRICE_ORACLE = "PRICE_ORACLE";
bytes32 constant ACCOUNT_FACTORY = "ACCOUNT_FACTORY";
bytes32 constant DATA_COMPRESSOR = "DATA_COMPRESSOR";
bytes32 constant TREASURY_CONTRACT = "TREASURY_CONTRACT";
bytes32 constant GEAR_TOKEN = "GEAR_TOKEN";
bytes32 constant WETH_TOKEN = "WETH_TOKEN";
bytes32 constant WETH_GATEWAY = "WETH_GATEWAY";
bytes32 constant LEVERAGED_ACTIONS = "LEVERAGED_ACTIONS";
/// @title AddressRepository
/// @notice Stores addresses of deployed contracts
contract AddressProvider is Claimable, IAddressProvider {
// Mapping from contract keys to respective addresses
mapping(bytes32 => address) public addresses;
/// @dev Contract version
function version() external view virtual override returns (uint256) {
return 2;
}
constructor() {
// @dev Emits first event for contract discovery
emit AddressSet("ADDRESS_PROVIDER", address(this));
}
/// @return Address of ACL contract
function getACL() external view returns (address) {
return _getAddress(ACL); // F:[AP-3]
}
/// @dev Sets address of ACL contract
/// @param _address Address of ACL contract
function setACL(
address _address
)
external
onlyOwner // F:[AP-12]
{
_setAddress(ACL, _address); // F:[AP-3]
}
/// @return Address of ContractsRegister
function getContractsRegister() external view returns (address) {
return _getAddress(CONTRACTS_REGISTER); // F:[AP-4]
}
/// @dev Sets address of ContractsRegister
/// @param _address Address of ContractsRegister
function setContractsRegister(
address _address
)
external
onlyOwner // F:[AP-12]
{
_setAddress(CONTRACTS_REGISTER, _address); // F:[AP-4]
}
/// @return Address of PriceOracleV2
function getPriceOracle() external view override returns (address) {
return _getAddress(PRICE_ORACLE); // F:[AP-5]
}
/// @dev Sets address of PriceOracleV2
/// @param _address Address of PriceOracleV2
function setPriceOracle(
address _address
)
external
onlyOwner // F:[AP-12]
{
_setAddress(PRICE_ORACLE, _address); // F:[AP-5]
}
/// @return Address of AccountFactory
function getAccountFactory() external view returns (address) {
return _getAddress(ACCOUNT_FACTORY); // F:[AP-6]
}
/// @dev Sets address of AccountFactory
/// @param _address Address of AccountFactory
function setAccountFactory(
address _address
)
external
onlyOwner // F:[AP-12]
{
_setAddress(ACCOUNT_FACTORY, _address); // F:[AP-6]
}
/// @return Address of DataCompressor
function getDataCompressor() external view override returns (address) {
return _getAddress(DATA_COMPRESSOR); // F:[AP-7]
}
/// @dev Sets address of AccountFactory
/// @param _address Address of AccountFactory
function setDataCompressor(
address _address
)
external
onlyOwner // F:[AP-12]
{
_setAddress(DATA_COMPRESSOR, _address); // F:[AP-7]
}
/// @return Address of Treasury contract
function getTreasuryContract() external view returns (address) {
return _getAddress(TREASURY_CONTRACT); // F:[AP-8]
}
/// @dev Sets address of Treasury Contract
/// @param _address Address of Treasury Contract
function setTreasuryContract(
address _address
)
external
onlyOwner // F:[AP-12]
{
_setAddress(TREASURY_CONTRACT, _address); // F:[AP-8]
}
/// @return Address of GEAR token
function getGearToken() external view override returns (address) {
return _getAddress(GEAR_TOKEN); // F:[AP-9]
}
/// @dev Sets address of GEAR token
/// @param _address Address of GEAR token
function setGearToken(
address _address
)
external
onlyOwner // F:[AP-12]
{
_setAddress(GEAR_TOKEN, _address); // F:[AP-9]
}
/// @return Address of WETH token
function getWethToken() external view override returns (address) {
return _getAddress(WETH_TOKEN); // F:[AP-10]
}
/// @dev Sets address of WETH token
/// @param _address Address of WETH token
function setWethToken(
address _address
)
external
onlyOwner // F:[AP-12]
{
_setAddress(WETH_TOKEN, _address); // F:[AP-10]
}
/// @return Address of WETH token
function getWETHGateway() external view override returns (address) {
return _getAddress(WETH_GATEWAY); // F:[AP-11]
}
/// @dev Sets address of WETH token
/// @param _address Address of WETH token
function setWETHGateway(
address _address
)
external
onlyOwner // F:[AP-12]
{
_setAddress(WETH_GATEWAY, _address); // F:[AP-11]
}
/// @return Address of PathFinder
function getLeveragedActions() external view returns (address) {
return _getAddress(LEVERAGED_ACTIONS); // T:[AP-7]
}
/// @dev Sets address of PathFinder
/// @param _address Address of PathFinder
function setLeveragedActions(
address _address
)
external
onlyOwner // T:[AP-15]
{
_setAddress(LEVERAGED_ACTIONS, _address); // T:[AP-7]
}
/// @return Address of key, reverts if the key doesn't exist
function _getAddress(bytes32 key) internal view returns (address) {
address result = addresses[key];
require(result != address(0), Errors.AS_ADDRESS_NOT_FOUND); // F:[AP-1]
return result; // F:[AP-3, 4, 5, 6, 7, 8, 9, 10, 11]
}
/// @dev Sets address to map by its key
/// @param key Key in string format
/// @param value Address
function _setAddress(bytes32 key, address value) internal {
addresses[key] = value; // F:[AP-3, 4, 5, 6, 7, 8, 9, 10, 11]
emit AddressSet(key, value); // F:[AP-2]
}
}
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
import { IVersion } from "./IVersion.sol";
interface IACLExceptions {
/// @dev Thrown when attempting to delete an address from a set that is not a pausable admin
error AddressNotPausableAdminException(address addr);
/// @dev Thrown when attempting to delete an address from a set that is not a unpausable admin
error AddressNotUnpausableAdminException(address addr);
}
interface IACLEvents {
/// @dev Emits when a new admin is added that can pause contracts
event PausableAdminAdded(address indexed newAdmin);
/// @dev Emits when a Pausable admin is removed
event PausableAdminRemoved(address indexed admin);
/// @dev Emits when a new admin is added that can unpause contracts
event UnpausableAdminAdded(address indexed newAdmin);
/// @dev Emits when an Unpausable admin is removed
event UnpausableAdminRemoved(address indexed admin);
}
/// @title ACL interface
interface IACL is IACLEvents, IACLExceptions, IVersion {
/// @dev Returns true if the address is a pausable admin and false if not
/// @param addr Address to check
function isPausableAdmin(address addr) external view returns (bool);
/// @dev Returns true if the address is unpausable admin and false if not
/// @param addr Address to check
function isUnpausableAdmin(address addr) external view returns (bool);
/// @dev Returns true if an address has configurator rights
/// @param account Address to check
function isConfigurator(address account) external view returns (bool);
/// @dev Returns address of configurator
function owner() external view returns (address);
}
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
/// @dev Common contract exceptions
/// @dev Thrown on attempting to set an important address to zero address
error ZeroAddressException();
/// @dev Thrown on attempting to call a non-implemented function
error NotImplementedException();
/// @dev Thrown on attempting to set an EOA as an important contract in the system
error AddressIsNotContractException(address);
/// @dev Thrown on attempting to use a non-ERC20 contract or an EOA as a token
error IncorrectTokenContractException();
/// @dev Thrown on attempting to set a token price feed to an address that is not a
/// correct price feed
error IncorrectPriceFeedException();
/// @dev Thrown on attempting to call an access restricted function as a non-Configurator
error CallerNotConfiguratorException();
/// @dev Thrown on attempting to call an access restricted function as a non-Configurator
error CallerNotControllerException();
/// @dev Thrown on attempting to pause a contract as a non-Pausable admin
error CallerNotPausableAdminException();
/// @dev Thrown on attempting to pause a contract as a non-Unpausable admin
error CallerNotUnPausableAdminException();
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
import { IVersion } from "./IVersion.sol";
interface IAddressProviderEvents {
/// @dev Emits when an address is set for a contract role
event AddressSet(bytes32 indexed service, address indexed newAddress);
}
/// @title Optimised for front-end Address Provider interface
interface IAddressProvider is IAddressProviderEvents, IVersion {
/// @return Address of ACL contract
function getACL() external view returns (address);
/// @return Address of ContractsRegister
function getContractsRegister() external view returns (address);
/// @return Address of AccountFactory
function getAccountFactory() external view returns (address);
/// @return Address of DataCompressor
function getDataCompressor() external view returns (address);
/// @return Address of GEAR token
function getGearToken() external view returns (address);
/// @return Address of WETH token
function getWethToken() external view returns (address);
/// @return Address of WETH Gateway
function getWETHGateway() external view returns (address);
/// @return Address of PriceOracleV2
function getPriceOracle() external view returns (address);
/// @return Address of DAO Treasury Multisig
function getTreasuryContract() external view returns (address);
/// @return Address of PathFinder
function getLeveragedActions() external view returns (address);
}
// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
/// @title Claimable
/// @dev Implements logic for a two-step ownership transfer on top of Ownable
contract Claimable is Ownable {
/// @dev The new owner that has not claimed ownership yet
address public pendingOwner;
/// @dev A modifier that restricts the function to the pending owner only
modifier onlyPendingOwner() {
if (msg.sender != pendingOwner) {
revert("Claimable: Sender is not pending owner");
}
_;
}
/// @dev Sets pending owner to the new owner, but does not
/// transfer ownership yet
/// @param newOwner The address to become the future owner
function transferOwnership(address newOwner) public override onlyOwner {
require(
newOwner != address(0),
"Claimable: new owner is the zero address"
);
pendingOwner = newOwner;
}
/// @dev Used by the pending owner to claim ownership after transferOwnership
function claimOwnership() external onlyPendingOwner {
_transferOwnership(pendingOwner);
pendingOwner = address(0);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling 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);
}
}