MATIC Price: $0.609249 (+1.40%)
Gas: 31 GWei
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x60806040483609142023-10-05 15:17:06254 days ago1696519026IN
 Create: RoyaltySplitter
0 MATIC0.1044053965.57625413

Parent Transaction Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RoyaltySplitter

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 2000 runs

Other Settings:
default evmVersion, MIT license
File 1 of 17 : RoyaltySplitter.sol
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity 0.8.18;

import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {
    OwnableUpgradeable,
    ContextUpgradeable
} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {AddressUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import {ERC165Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";
import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {BytesLibrary} from "@manifoldxyz/royalty-registry-solidity/contracts/libraries/BytesLibrary.sol";
import {
    IRoyaltySplitter,
    IERC165,
    Recipient
} from "@manifoldxyz/royalty-registry-solidity/contracts/overrides/IRoyaltySplitter.sol";
import {ERC2771HandlerAbstract} from "@sandbox-smart-contracts/dependency-metatx/contracts/ERC2771HandlerAbstract.sol";
import {IRoyaltyManager} from "./interfaces/IRoyaltyManager.sol";

/// @title RoyaltySplitter
/// @author The Sandbox
/// @notice RoyaltySplitter contract is deployed by the RoyaltyManager contract for a creator to get his royalty's share.
contract RoyaltySplitter is
    Initializable,
    OwnableUpgradeable,
    IRoyaltySplitter,
    ERC165Upgradeable,
    ERC2771HandlerAbstract
{
    using BytesLibrary for bytes;
    using AddressUpgradeable for address payable;
    using AddressUpgradeable for address;
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    uint256 internal constant TOTAL_BASIS_POINTS = 10000;

    address payable public recipient;
    IRoyaltyManager public royaltyManager;

    event ETHTransferred(address indexed account, uint256 amount);
    event ERC20Transferred(address indexed erc20Contract, address indexed account, uint256 amount);
    event RecipientSet(address indexed recipientAddress);

    /// @dev this protects the implementation contract from behing initialized.
    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    /// @notice Query if a contract implements interface `id`.
    /// @param interfaceId the interface identifier, as specified in ERC-165.
    /// @return isSupported `true` if the contract implements `id`.
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(IERC165, ERC165Upgradeable)
        returns (bool isSupported)
    {
        return (interfaceId == type(IRoyaltySplitter).interfaceId || super.supportsInterface(interfaceId));
    }

    /// @notice initialize the contract
    /// @dev can only be run once.
    /// @param recipientAddress the wallet of the creator when the contract is deployed
    /// @param _royaltyManager the address of the royalty manager contract
    function initialize(address payable recipientAddress, address _royaltyManager) external initializer {
        royaltyManager = IRoyaltyManager(_royaltyManager); // set manager before Ownable_init for _isTrustedForwarder
        _setRecipient(recipientAddress);
        __Ownable_init();
        __ERC165_init();
    }

    /// @notice sets recipient for the splitter
    /// @dev only the owner can call this.
    /// @param recipients the array of recipients which should only have one recipient.
    function setRecipients(Recipient[] calldata recipients) external override onlyOwner {
        require(recipients.length == 1, "Invalid recipents length");
        _setRecipient(recipients[0].recipient);
    }

    function _setRecipient(address payable recipientAddress) private {
        recipient = recipientAddress;
        emit RecipientSet(recipientAddress);
    }

    /// @notice to get recipients of royalty through this splitter and their splits of royalty.
    /// @return recipients array of royalty recipients through the splitter and their splits of royalty.
    function getRecipients() external view override returns (Recipient[] memory recipients) {
        Recipient memory commonRecipient = royaltyManager.getCommonRecipient();
        uint16 creatorSplit = royaltyManager.getCreatorSplit();
        recipients = new Recipient[](2);
        recipients[0].recipient = recipient;
        recipients[0].bps = creatorSplit;
        recipients[1] = commonRecipient;
        return recipients;
    }

    /// @notice Splits and forwards ETH to the royalty receivers
    /// @dev splits ETH every time it is sent to this contract as royalty.
    receive() external payable {
        _splitETH(msg.value);
    }

    /// @notice Splits and forwards ETH to the royalty receivers
    /// @dev normally ETH should be split automatically by receive function.
    function splitETH() external payable {
        _splitETH(address(this).balance);
    }

    function _splitETH(uint256 value) internal {
        if (value > 0) {
            Recipient memory commonRecipient = royaltyManager.getCommonRecipient();
            uint16 creatorSplit = royaltyManager.getCreatorSplit();
            Recipient[] memory _recipients = new Recipient[](2);
            _recipients[0].recipient = recipient;
            _recipients[0].bps = creatorSplit;
            _recipients[1] = commonRecipient;
            uint256 totalSent;
            uint256 amountToSend;
            unchecked {
                for (uint256 i = _recipients.length - 1; i > 0; i--) {
                    Recipient memory _recipient = _recipients[i];
                    amountToSend = (value * _recipient.bps) / TOTAL_BASIS_POINTS;
                    totalSent += amountToSend;
                    _recipient.recipient.sendValue(amountToSend);
                    emit ETHTransferred(_recipient.recipient, amountToSend);
                }
                // Favor the 1st recipient if there are any rounding issues
                amountToSend = value - totalSent;
            }
            _recipients[0].recipient.sendValue(amountToSend);
            emit ETHTransferred(_recipients[0].recipient, amountToSend);
        }
    }

    /// @notice split ERC20 Tokens owned by this contract.
    /// @dev can only be called by one of the recipients
    /// @param erc20Contract the address of the tokens to be split.
    function splitERC20Tokens(IERC20 erc20Contract) external {
        require(_splitERC20Tokens(erc20Contract), "Split: ERC20 split failed");
    }

    function _splitERC20Tokens(IERC20 erc20Contract) internal returns (bool success) {
        try erc20Contract.balanceOf(address(this)) returns (uint256 balance) {
            if (balance == 0) {
                return false;
            }
            Recipient memory commonRecipient = royaltyManager.getCommonRecipient();
            uint16 creatorSplit = royaltyManager.getCreatorSplit();
            require(
                commonRecipient.recipient == _msgSender() || recipient == _msgSender(),
                "Split: Can only be called by one of the recipients"
            );
            Recipient[] memory _recipients = new Recipient[](2);
            _recipients[0].recipient = recipient;
            _recipients[0].bps = creatorSplit;
            _recipients[1] = commonRecipient;
            uint256 amountToSend;
            uint256 totalSent;
            unchecked {
                for (uint256 i = _recipients.length - 1; i > 0; i--) {
                    Recipient memory _recipient = _recipients[i];
                    (success, amountToSend) = balance.tryMul(_recipient.bps);
                    require(success, "RoyaltySplitter: Multiplication Overflow");

                    amountToSend /= TOTAL_BASIS_POINTS;
                    totalSent += amountToSend;

                    erc20Contract.safeTransfer(_recipient.recipient, amountToSend);
                    emit ERC20Transferred(address(erc20Contract), _recipient.recipient, amountToSend);
                }
                // Favor the 1st recipient if there are any rounding issues
                amountToSend = balance - totalSent;
            }
            erc20Contract.safeTransfer(_recipients[0].recipient, amountToSend);
            emit ERC20Transferred(address(erc20Contract), _recipients[0].recipient, amountToSend);
            return true;
        } catch {
            return false;
        }
    }

    /// @notice verify whether a forwarder address is the trustedForwarder address, using the manager setting
    /// @dev this function is used to avoid having a trustedForwarder variable inside the splitter
    /// @return isTrusted bool whether the forwarder is the trusted address
    function _isTrustedForwarder(address forwarder)
        internal
        view
        override(ERC2771HandlerAbstract)
        returns (bool isTrusted)
    {
        return (forwarder == royaltyManager.getTrustedForwarder());
    }

    function _msgSender()
        internal
        view
        virtual
        override(ContextUpgradeable, ERC2771HandlerAbstract)
        returns (address sender)
    {
        return ERC2771HandlerAbstract._msgSender();
    }

    function _msgData()
        internal
        view
        virtual
        override(ContextUpgradeable, ERC2771HandlerAbstract)
        returns (bytes calldata messageData)
    {
        return ERC2771HandlerAbstract._msgData();
    }
}

File 2 of 17 : BytesLibrary.sol
// SPDX-License-Identifier: MIT OR Apache-2.0

pragma solidity ^0.8.0;

/**
 * @notice A library for manipulation of byte arrays.
 */
library BytesLibrary {
    /**
     * @dev Replace the address at the given location in a byte array if the contents at that location
     * match the expected address.
     */
    function replaceAtIf(bytes memory data, uint256 startLocation, address expectedAddress, address newAddress)
        internal
        pure
    {
        bytes memory expectedData = abi.encodePacked(expectedAddress);
        bytes memory newData = abi.encodePacked(newAddress);
        // An address is 20 bytes long
        for (uint256 i = 0; i < 20; i++) {
            uint256 dataLocation = startLocation + i;
            require(data[dataLocation] == expectedData[i], "Bytes: Data provided does not include the expectedAddress");
            data[dataLocation] = newData[i];
        }
    }

    /**
     * @dev Checks if the call data starts with the given function signature.
     */
    function startsWith(bytes memory callData, bytes4 functionSig) internal pure returns (bool) {
        // A signature is 4 bytes long
        if (callData.length < 4) {
            return false;
        }
        for (uint256 i = 0; i < 4; i++) {
            if (callData[i] != functionSig[i]) {
                return false;
            }
        }

        return true;
    }
}

File 3 of 17 : IRoyaltySplitter.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

struct Recipient {
    address payable recipient;
    uint16 bps;
}

interface IRoyaltySplitter is IERC165 {
    /**
     * @dev Set the splitter recipients. Total bps must total 10000.
     */
    function setRecipients(Recipient[] calldata recipients) external;

    /**
     * @dev Get the splitter recipients;
     */
    function getRecipients() external view returns (Recipient[] memory);
}

File 4 of 17 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _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);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 5 of 17 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 6 of 17 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 7 of 17 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 8 of 17 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 9 of 17 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 10 of 17 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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 11 of 17 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 12 of 17 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 13 of 17 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 14 of 17 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 15 of 17 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 16 of 17 : ERC2771HandlerAbstract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @dev minimal ERC2771 handler to keep bytecode-size down
/// based on: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/metatx/ERC2771Context.sol
abstract contract ERC2771HandlerAbstract {
    /// @notice return true if the forwarder is the trusted forwarder
    /// @param forwarder trusted forwarder address to check
    /// @return true if the address is the same as the trusted forwarder
    function isTrustedForwarder(address forwarder) external view returns (bool) {
        return _isTrustedForwarder(forwarder);
    }

    /// @notice if the call is from the trusted forwarder the sender is extracted from calldata, msg.sender otherwise
    /// @return sender the calculated address of the sender
    function _msgSender() internal view virtual returns (address sender) {
        if (_isTrustedForwarder(msg.sender) && msg.data.length >= 20) {
            // The assembly code is more direct than the Solidity version using `abi.decode`.
            // solhint-disable-next-line no-inline-assembly
            assembly {
                sender := shr(96, calldataload(sub(calldatasize(), 20)))
            }
        } else {
            sender = msg.sender;
        }
    }

    /// @notice if the call is from the trusted forwarder the sender is removed from calldata
    /// @return the calldata without the sender
    function _msgData() internal view virtual returns (bytes calldata) {
        if (_isTrustedForwarder(msg.sender) && msg.data.length >= 20) {
            return msg.data[:msg.data.length - 20];
        } else {
            return msg.data;
        }
    }

    /// @notice return true if the forwarder is the trusted forwarder
    /// @param forwarder trusted forwarder address to check
    /// @return true if the address is the same as the trusted forwarder
    /// @dev this function must be IMPLEMENTED
    function _isTrustedForwarder(address forwarder) internal view virtual returns (bool);
}

File 17 of 17 : IRoyaltyManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Recipient} from "@manifoldxyz/royalty-registry-solidity/contracts/overrides/IRoyaltySplitter.sol";

/// @title IRoyaltyManager
/// @notice interface for RoyaltyManager Contract
interface IRoyaltyManager {
    event RecipientSet(address indexed commonRecipient);

    event SplitSet(uint16 commonSplit);

    event RoyaltySet(uint16 royaltyBps, address indexed contractAddress);

    event TrustedForwarderSet(address indexed previousForwarder, address indexed newForwarder);

    event SplitterDeployed(address indexed creator, address indexed recipient, address splitterAddress);

    ///@notice sets the common recipient
    ///@param _commonRecipient is the common recipient for all the splitters
    function setRecipient(address payable _commonRecipient) external;

    ///@notice sets the common split
    ///@param commonSplit split for the common recipient
    function setSplit(uint16 commonSplit) external;

    ///@notice to be called by the splitters to get the common recipient and split
    ///@return recipient which has the common recipient and split
    function getCommonRecipient() external view returns (Recipient memory recipient);

    ///@notice returns the amount of basis points allocated to the creator
    ///@return creatorSplit the share of creator in bps
    function getCreatorSplit() external view returns (uint16 creatorSplit);

    ///@notice returns the commonRecipient and EIP2981 royalty split
    ///@return recipient address of common royalty recipient
    ///@return royaltySplit contract EIP2981 royalty bps
    function getRoyaltyInfo() external view returns (address payable recipient, uint16 royaltySplit);

    ///@notice deploys splitter for creator
    ///@param creator the address of the creator
    ///@param recipient the wallet of the recipient where they would receive their royalty
    ///@return creatorSplitterAddress splitter's address deployed for creator
    function deploySplitter(address creator, address payable recipient)
        external
        returns (address payable creatorSplitterAddress);

    ///@notice returns the address of splitter of a creator.
    ///@param creator the address of the creator
    ///@return creatorSplitterAddress splitter's address deployed for a creator
    function getCreatorRoyaltySplitter(address creator) external view returns (address payable creatorSplitterAddress);

    ///@notice returns the EIP2981 royalty split
    ///@param _contractAddress the address of the contract for which the royalty is required
    ///@return royaltyBps royalty bps of the contract
    function getContractRoyalty(address _contractAddress) external view returns (uint16 royaltyBps);

    ///@notice sets the trustedForwarder address to be used by the splitters
    ///@param _newForwarder is the new trusted forwarder address
    function setTrustedForwarder(address _newForwarder) external;

    ///@notice get the current trustedForwarder address
    ///@return trustedForwarder address of current trusted Forwarder
    function getTrustedForwarder() external view returns (address trustedForwarder);
}

Settings
{
  "evmVersion": "paris",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 2000
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc20Contract","type":"address"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Transferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ETHTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","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":true,"internalType":"address","name":"recipientAddress","type":"address"}],"name":"RecipientSet","type":"event"},{"inputs":[],"name":"getRecipients","outputs":[{"components":[{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"uint16","name":"bps","type":"uint16"}],"internalType":"struct Recipient[]","name":"recipients","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"recipientAddress","type":"address"},{"internalType":"address","name":"_royaltyManager","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recipient","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"royaltyManager","outputs":[{"internalType":"contract IRoyaltyManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"uint16","name":"bps","type":"uint16"}],"internalType":"struct Recipient[]","name":"recipients","type":"tuple[]"}],"name":"setRecipients","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"erc20Contract","type":"address"}],"name":"splitERC20Tokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"splitETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"isSupported","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b5061001961001e565b6100dd565b600054610100900460ff161561008a5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146100db576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b611b74806100ec6000396000f3fe6080604052600436106100cb5760003560e01c80638da5cb5b11610074578063d78d610b1161004e578063d78d610b14610208578063ee295d621461022a578063f2fde38b1461024a57600080fd5b80638da5cb5b146101c2578063c1426d0e146101e0578063d1aa25d01461020057600080fd5b8063572b6c05116100a5578063572b6c051461015557806366d003ac14610175578063715018a6146101ad57600080fd5b806301ffc9a7146100e057806320dc8ff714610115578063485cc9551461013557600080fd5b366100db576100d93461026a565b005b600080fd5b3480156100ec57600080fd5b506101006100fb36600461182a565b610590565b60405190151581526020015b60405180910390f35b34801561012157600080fd5b506100d9610130366004611888565b610629565b34801561014157600080fd5b506100d96101503660046118a5565b610683565b34801561016157600080fd5b50610100610170366004611888565b6107fc565b34801561018157600080fd5b50609754610195906001600160a01b031681565b6040516001600160a01b03909116815260200161010c565b3480156101b957600080fd5b506100d9610807565b3480156101ce57600080fd5b506033546001600160a01b0316610195565b3480156101ec57600080fd5b506100d96101fb3660046118de565b61081b565b6100d96108a8565b34801561021457600080fd5b5061021d6108b1565b60405161010c9190611953565b34801561023657600080fd5b50609854610195906001600160a01b031681565b34801561025657600080fd5b506100d9610265366004611888565b610a72565b801561058d5760985460408051638b49fde760e01b815281516000936001600160a01b031692638b49fde792600480820193918290030181865afa1580156102b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102da91906119c1565b90506000609860009054906101000a90046001600160a01b03166001600160a01b031663706ec2fe6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610331573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103559190611a2c565b6040805160028082526060820190925291925060009190816020015b604080518082019091526000808252602082015281526020019060019003908161037157505060975481519192506001600160a01b03169082906000906103ba576103ba611a47565b6020026020010151600001906001600160a01b031690816001600160a01b03168152505081816000815181106103f2576103f2611a47565b60200260200101516020019061ffff16908161ffff1681525050828160018151811061042057610420611a47565b60200260200101819052506000806000600184510390505b80156104e657600084828151811061045257610452611a47565b60200260200101519050612710816020015161ffff1689028161047757610477611a5d565b8251919004948501949350610495906001600160a01b031684610aff565b80600001516001600160a01b03167f1445764fe3fdfc2a9812ff42e9b65c2e7896d5162851f78f7d4a5578f7346ff1846040516104d491815260200190565b60405180910390a25060001901610438565b508186039050610526818460008151811061050357610503611a47565b6020026020010151600001516001600160a01b0316610aff90919063ffffffff16565b8260008151811061053957610539611a47565b6020026020010151600001516001600160a01b03167f1445764fe3fdfc2a9812ff42e9b65c2e7896d5162851f78f7d4a5578f7346ff18260405161057f91815260200190565b60405180910390a250505050505b50565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f16cf0c0500000000000000000000000000000000000000000000000000000000148061062357507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b61063281610c18565b61058d5760405162461bcd60e51b815260206004820152601960248201527f53706c69743a2045524332302073706c6974206661696c65640000000000000060448201526064015b60405180910390fd5b600054610100900460ff16158080156106a35750600054600160ff909116105b806106bd5750303b1580156106bd575060005460ff166001145b61072f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161067a565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558015610770576000805461ff0019166101001790555b6098805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384161790556107a183611114565b6107a961116b565b6107b16111f0565b80156107f7576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b60006106238261126d565b61080f61130f565b6108196000611388565b565b61082361130f565b600181146108735760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207265636970656e7473206c656e6774680000000000000000604482015260640161067a565b6108a48282600081811061088957610889611a47565b61089f9260206040909202019081019150611888565b611114565b5050565b6108194761026a565b60985460408051638b49fde760e01b815281516060936000936001600160a01b0390911692638b49fde792600480830193928290030181865afa1580156108fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092091906119c1565b90506000609860009054906101000a90046001600160a01b03166001600160a01b031663706ec2fe6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610977573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099b9190611a2c565b60408051600280825260608201909252919250816020015b60408051808201909152600080825260208201528152602001906001900390816109b357505060975481519194506001600160a01b03169084906000906109fc576109fc611a47565b6020026020010151600001906001600160a01b031690816001600160a01b0316815250508083600081518110610a3457610a34611a47565b60200260200101516020019061ffff16908161ffff16815250508183600181518110610a6257610a62611a47565b6020026020010181905250505090565b610a7a61130f565b6001600160a01b038116610af65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161067a565b61058d81611388565b80471015610b4f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161067a565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610b9c576040519150601f19603f3d011682016040523d82523d6000602084013e610ba1565b606091505b50509050806107f75760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161067a565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa925050508015610c94575060408051601f3d908101601f19168201909252610c9191810190611a73565b60015b610ca057506000919050565b80600003610cb15750600092915050565b60985460408051638b49fde760e01b815281516000936001600160a01b031692638b49fde792600480820193918290030181865afa158015610cf7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1b91906119c1565b90506000609860009054906101000a90046001600160a01b03166001600160a01b031663706ec2fe6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d969190611a2c565b9050610da06113e7565b6001600160a01b031682600001516001600160a01b03161480610dd85750610dc66113e7565b6097546001600160a01b039081169116145b610e4a5760405162461bcd60e51b815260206004820152603260248201527f53706c69743a2043616e206f6e6c792062652063616c6c6564206279206f6e6560448201527f206f662074686520726563697069656e74730000000000000000000000000000606482015260840161067a565b60408051600280825260608201909252600091816020015b6040805180820190915260008082526020820152815260200190600190039081610e6257505060975481519192506001600160a01b0316908290600090610eab57610eab611a47565b6020026020010151600001906001600160a01b031690816001600160a01b0316815250508181600081518110610ee357610ee3611a47565b60200260200101516020019061ffff16908161ffff16815250508281600181518110610f1157610f11611a47565b60200260200101819052506000806000600184510390505b801561105d576000848281518110610f4357610f43611a47565b60200260200101519050610f68816020015161ffff16896113f690919063ffffffff16565b909950935088610fe05760405162461bcd60e51b815260206004820152602860248201527f526f79616c747953706c69747465723a204d756c7469706c69636174696f6e2060448201527f4f766572666c6f77000000000000000000000000000000000000000000000000606482015260840161067a565b80516127109094049392840192611002906001600160a01b038c169086611441565b80600001516001600160a01b03168a6001600160a01b03167fe8de91d538b06154a2c48315768c5046f47e127d7fd3f726fd85cc723f29b0528660405161104b91815260200190565b60405180910390a35060001901610f29565b5080860391506110968360008151811061107957611079611a47565b6020908102919091010151516001600160a01b038a169084611441565b826000815181106110a9576110a9611a47565b6020026020010151600001516001600160a01b0316886001600160a01b03167fe8de91d538b06154a2c48315768c5046f47e127d7fd3f726fd85cc723f29b052846040516110f991815260200190565b60405180910390a3506001979650505050505050565b919050565b6097805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f9d900d71c28433348acb1bec780a061608a96b149370abce77fd54ba2d47940190600090a250565b600054610100900460ff166111e85760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161067a565b6108196114c1565b600054610100900460ff166108195760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161067a565b609854604080517fce1b815f00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163ce1b815f9160048083019260209291908290030181865afa1580156112d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f49190611a8c565b6001600160a01b0316826001600160a01b0316149050919050565b6113176113e7565b6001600160a01b03166113326033546001600160a01b031690565b6001600160a01b0316146108195760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067a565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006113f161154e565b905090565b6000808360000361140d575060019050600061143a565b8383028385828161142057611420611a5d565b041461143357600080925092505061143a565b6001925090505b9250929050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526107f790849061159b565b600054610100900460ff1661153e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161067a565b6108196115496113e7565b611388565b60006115593361126d565b8015611566575060143610155b1561159657507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec36013560601c90565b503390565b60006115f0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116839092919063ffffffff16565b90508051600014806116115750808060200190518101906116119190611aa9565b6107f75760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161067a565b6060611692848460008561169a565b949350505050565b6060824710156117125760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161067a565b600080866001600160a01b0316858760405161172e9190611aef565b60006040518083038185875af1925050503d806000811461176b576040519150601f19603f3d011682016040523d82523d6000602084013e611770565b606091505b50915091506117818783838761178c565b979650505050505050565b606083156117fb5782516000036117f4576001600160a01b0385163b6117f45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161067a565b5081611692565b61169283838151156118105781518083602001fd5b8060405162461bcd60e51b815260040161067a9190611b0b565b60006020828403121561183c57600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461186c57600080fd5b9392505050565b6001600160a01b038116811461058d57600080fd5b60006020828403121561189a57600080fd5b813561186c81611873565b600080604083850312156118b857600080fd5b82356118c381611873565b915060208301356118d381611873565b809150509250929050565b600080602083850312156118f157600080fd5b823567ffffffffffffffff8082111561190957600080fd5b818501915085601f83011261191d57600080fd5b81358181111561192c57600080fd5b8660208260061b850101111561194157600080fd5b60209290920196919550909350505050565b602080825282518282018190526000919060409081850190868401855b828110156119a257815180516001600160a01b0316855286015161ffff16868501529284019290850190600101611970565b5091979650505050505050565b805161ffff8116811461110f57600080fd5b6000604082840312156119d357600080fd5b6040516040810181811067ffffffffffffffff82111715611a0457634e487b7160e01b600052604160045260246000fd5b6040528251611a1281611873565b8152611a20602084016119af565b60208201529392505050565b600060208284031215611a3e57600080fd5b61186c826119af565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600060208284031215611a8557600080fd5b5051919050565b600060208284031215611a9e57600080fd5b815161186c81611873565b600060208284031215611abb57600080fd5b8151801515811461186c57600080fd5b60005b83811015611ae6578181015183820152602001611ace565b50506000910152565b60008251611b01818460208701611acb565b9190910192915050565b6020815260008251806020840152611b2a816040850160208701611acb565b601f01601f1916919091016040019291505056fea2646970667358221220a4f7bb2a8929ea8951da0ff52f58a011cf06040c0e48964cec81009ca943438164736f6c63430008120033

Deployed Bytecode

0x6080604052600436106100cb5760003560e01c80638da5cb5b11610074578063d78d610b1161004e578063d78d610b14610208578063ee295d621461022a578063f2fde38b1461024a57600080fd5b80638da5cb5b146101c2578063c1426d0e146101e0578063d1aa25d01461020057600080fd5b8063572b6c05116100a5578063572b6c051461015557806366d003ac14610175578063715018a6146101ad57600080fd5b806301ffc9a7146100e057806320dc8ff714610115578063485cc9551461013557600080fd5b366100db576100d93461026a565b005b600080fd5b3480156100ec57600080fd5b506101006100fb36600461182a565b610590565b60405190151581526020015b60405180910390f35b34801561012157600080fd5b506100d9610130366004611888565b610629565b34801561014157600080fd5b506100d96101503660046118a5565b610683565b34801561016157600080fd5b50610100610170366004611888565b6107fc565b34801561018157600080fd5b50609754610195906001600160a01b031681565b6040516001600160a01b03909116815260200161010c565b3480156101b957600080fd5b506100d9610807565b3480156101ce57600080fd5b506033546001600160a01b0316610195565b3480156101ec57600080fd5b506100d96101fb3660046118de565b61081b565b6100d96108a8565b34801561021457600080fd5b5061021d6108b1565b60405161010c9190611953565b34801561023657600080fd5b50609854610195906001600160a01b031681565b34801561025657600080fd5b506100d9610265366004611888565b610a72565b801561058d5760985460408051638b49fde760e01b815281516000936001600160a01b031692638b49fde792600480820193918290030181865afa1580156102b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102da91906119c1565b90506000609860009054906101000a90046001600160a01b03166001600160a01b031663706ec2fe6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610331573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103559190611a2c565b6040805160028082526060820190925291925060009190816020015b604080518082019091526000808252602082015281526020019060019003908161037157505060975481519192506001600160a01b03169082906000906103ba576103ba611a47565b6020026020010151600001906001600160a01b031690816001600160a01b03168152505081816000815181106103f2576103f2611a47565b60200260200101516020019061ffff16908161ffff1681525050828160018151811061042057610420611a47565b60200260200101819052506000806000600184510390505b80156104e657600084828151811061045257610452611a47565b60200260200101519050612710816020015161ffff1689028161047757610477611a5d565b8251919004948501949350610495906001600160a01b031684610aff565b80600001516001600160a01b03167f1445764fe3fdfc2a9812ff42e9b65c2e7896d5162851f78f7d4a5578f7346ff1846040516104d491815260200190565b60405180910390a25060001901610438565b508186039050610526818460008151811061050357610503611a47565b6020026020010151600001516001600160a01b0316610aff90919063ffffffff16565b8260008151811061053957610539611a47565b6020026020010151600001516001600160a01b03167f1445764fe3fdfc2a9812ff42e9b65c2e7896d5162851f78f7d4a5578f7346ff18260405161057f91815260200190565b60405180910390a250505050505b50565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f16cf0c0500000000000000000000000000000000000000000000000000000000148061062357507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b61063281610c18565b61058d5760405162461bcd60e51b815260206004820152601960248201527f53706c69743a2045524332302073706c6974206661696c65640000000000000060448201526064015b60405180910390fd5b600054610100900460ff16158080156106a35750600054600160ff909116105b806106bd5750303b1580156106bd575060005460ff166001145b61072f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161067a565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558015610770576000805461ff0019166101001790555b6098805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384161790556107a183611114565b6107a961116b565b6107b16111f0565b80156107f7576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b60006106238261126d565b61080f61130f565b6108196000611388565b565b61082361130f565b600181146108735760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207265636970656e7473206c656e6774680000000000000000604482015260640161067a565b6108a48282600081811061088957610889611a47565b61089f9260206040909202019081019150611888565b611114565b5050565b6108194761026a565b60985460408051638b49fde760e01b815281516060936000936001600160a01b0390911692638b49fde792600480830193928290030181865afa1580156108fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092091906119c1565b90506000609860009054906101000a90046001600160a01b03166001600160a01b031663706ec2fe6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610977573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099b9190611a2c565b60408051600280825260608201909252919250816020015b60408051808201909152600080825260208201528152602001906001900390816109b357505060975481519194506001600160a01b03169084906000906109fc576109fc611a47565b6020026020010151600001906001600160a01b031690816001600160a01b0316815250508083600081518110610a3457610a34611a47565b60200260200101516020019061ffff16908161ffff16815250508183600181518110610a6257610a62611a47565b6020026020010181905250505090565b610a7a61130f565b6001600160a01b038116610af65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161067a565b61058d81611388565b80471015610b4f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161067a565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610b9c576040519150601f19603f3d011682016040523d82523d6000602084013e610ba1565b606091505b50509050806107f75760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161067a565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa925050508015610c94575060408051601f3d908101601f19168201909252610c9191810190611a73565b60015b610ca057506000919050565b80600003610cb15750600092915050565b60985460408051638b49fde760e01b815281516000936001600160a01b031692638b49fde792600480820193918290030181865afa158015610cf7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1b91906119c1565b90506000609860009054906101000a90046001600160a01b03166001600160a01b031663706ec2fe6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d969190611a2c565b9050610da06113e7565b6001600160a01b031682600001516001600160a01b03161480610dd85750610dc66113e7565b6097546001600160a01b039081169116145b610e4a5760405162461bcd60e51b815260206004820152603260248201527f53706c69743a2043616e206f6e6c792062652063616c6c6564206279206f6e6560448201527f206f662074686520726563697069656e74730000000000000000000000000000606482015260840161067a565b60408051600280825260608201909252600091816020015b6040805180820190915260008082526020820152815260200190600190039081610e6257505060975481519192506001600160a01b0316908290600090610eab57610eab611a47565b6020026020010151600001906001600160a01b031690816001600160a01b0316815250508181600081518110610ee357610ee3611a47565b60200260200101516020019061ffff16908161ffff16815250508281600181518110610f1157610f11611a47565b60200260200101819052506000806000600184510390505b801561105d576000848281518110610f4357610f43611a47565b60200260200101519050610f68816020015161ffff16896113f690919063ffffffff16565b909950935088610fe05760405162461bcd60e51b815260206004820152602860248201527f526f79616c747953706c69747465723a204d756c7469706c69636174696f6e2060448201527f4f766572666c6f77000000000000000000000000000000000000000000000000606482015260840161067a565b80516127109094049392840192611002906001600160a01b038c169086611441565b80600001516001600160a01b03168a6001600160a01b03167fe8de91d538b06154a2c48315768c5046f47e127d7fd3f726fd85cc723f29b0528660405161104b91815260200190565b60405180910390a35060001901610f29565b5080860391506110968360008151811061107957611079611a47565b6020908102919091010151516001600160a01b038a169084611441565b826000815181106110a9576110a9611a47565b6020026020010151600001516001600160a01b0316886001600160a01b03167fe8de91d538b06154a2c48315768c5046f47e127d7fd3f726fd85cc723f29b052846040516110f991815260200190565b60405180910390a3506001979650505050505050565b919050565b6097805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f9d900d71c28433348acb1bec780a061608a96b149370abce77fd54ba2d47940190600090a250565b600054610100900460ff166111e85760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161067a565b6108196114c1565b600054610100900460ff166108195760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161067a565b609854604080517fce1b815f00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163ce1b815f9160048083019260209291908290030181865afa1580156112d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f49190611a8c565b6001600160a01b0316826001600160a01b0316149050919050565b6113176113e7565b6001600160a01b03166113326033546001600160a01b031690565b6001600160a01b0316146108195760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067a565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006113f161154e565b905090565b6000808360000361140d575060019050600061143a565b8383028385828161142057611420611a5d565b041461143357600080925092505061143a565b6001925090505b9250929050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526107f790849061159b565b600054610100900460ff1661153e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161067a565b6108196115496113e7565b611388565b60006115593361126d565b8015611566575060143610155b1561159657507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec36013560601c90565b503390565b60006115f0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116839092919063ffffffff16565b90508051600014806116115750808060200190518101906116119190611aa9565b6107f75760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161067a565b6060611692848460008561169a565b949350505050565b6060824710156117125760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161067a565b600080866001600160a01b0316858760405161172e9190611aef565b60006040518083038185875af1925050503d806000811461176b576040519150601f19603f3d011682016040523d82523d6000602084013e611770565b606091505b50915091506117818783838761178c565b979650505050505050565b606083156117fb5782516000036117f4576001600160a01b0385163b6117f45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161067a565b5081611692565b61169283838151156118105781518083602001fd5b8060405162461bcd60e51b815260040161067a9190611b0b565b60006020828403121561183c57600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461186c57600080fd5b9392505050565b6001600160a01b038116811461058d57600080fd5b60006020828403121561189a57600080fd5b813561186c81611873565b600080604083850312156118b857600080fd5b82356118c381611873565b915060208301356118d381611873565b809150509250929050565b600080602083850312156118f157600080fd5b823567ffffffffffffffff8082111561190957600080fd5b818501915085601f83011261191d57600080fd5b81358181111561192c57600080fd5b8660208260061b850101111561194157600080fd5b60209290920196919550909350505050565b602080825282518282018190526000919060409081850190868401855b828110156119a257815180516001600160a01b0316855286015161ffff16868501529284019290850190600101611970565b5091979650505050505050565b805161ffff8116811461110f57600080fd5b6000604082840312156119d357600080fd5b6040516040810181811067ffffffffffffffff82111715611a0457634e487b7160e01b600052604160045260246000fd5b6040528251611a1281611873565b8152611a20602084016119af565b60208201529392505050565b600060208284031215611a3e57600080fd5b61186c826119af565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600060208284031215611a8557600080fd5b5051919050565b600060208284031215611a9e57600080fd5b815161186c81611873565b600060208284031215611abb57600080fd5b8151801515811461186c57600080fd5b60005b83811015611ae6578181015183820152602001611ace565b50506000910152565b60008251611b01818460208701611acb565b9190910192915050565b6020815260008251806020840152611b2a816040850160208701611acb565b601f01601f1916919091016040019291505056fea2646970667358221220a4f7bb2a8929ea8951da0ff52f58a011cf06040c0e48964cec81009ca943438164736f6c63430008120033

Block Transaction Gas Used Reward
view all blocks produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.